19
$\begingroup$

I am trying to produce a model for which I have a response variable which is a proportion between 0 and 1, this includes quite a few 0s and 1s but also many values in between. I am thinking about attempting a beta regression. The package I have found for R (betareg) only allows values in between 0 and 1 but not including 0 or 1 them selves. I have read elsewhere that theoretically the beta distribution should be able to handle values of 0 or 1 but I do not know how to handle this in R.I have seen some people add 0.001 to the zeros and take 0.001 from the ones, but I am not sure this is a good idea?

Alternatively I could logit transform the response variable and use linear regression. In this case I have the same problem with the 0 and 1's which cannot be log transformed.

$\endgroup$
  • $\begingroup$ Knowing the counts--not just the proportions--is crucial no matter what you do. But once you have the counts, the first model to consider, even if it's just a point of departure, is logistic regression. $\endgroup$ – whuber Jan 18 '13 at 22:03
  • $\begingroup$ Well, a beta is between 0 and 1 (almost surely). If you observe them you should use a model that gives a chance to observe your sample. A couple of answers seem to cover that kind of approach; I'd start with them. $\endgroup$ – Glen_b Jan 22 '13 at 10:49
19
$\begingroup$

You could use zero- and/or one inflated beta regression models which combine the beta distribution with a degenerate distribution to assign some probability to 0 and 1 respectively. For details see the following references:

Ospina, R., & Ferrari, S. L. P. (2010). Inflated beta distributions. Statistical Papers, 51(1), 111-126. Ospina, R., & Ferrari, S. L. P. (2012). A general class of zero-or-one inflated beta regression models. Computational Statistics and Data Analysis, 56(6), 1609 - 1623.

These models are easy to implement with the gamlss package for R.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Do you have an example of how to implement them on R? $\endgroup$ – Ouistiti May 3 '17 at 20:14
  • 2
    $\begingroup$ @Ouistiti the zoib package does it easily. $\endgroup$ – Mark White Nov 25 '17 at 17:09
13
$\begingroup$

The documentation for the R betareg package mentions that

if y also assumes the extremes 0 and 1, a useful transformation in practice is (y * (n−1) + 0.5) / n where n is the sample size.

http://cran.r-project.org/web/packages/betareg/vignettes/betareg.pdf

They give the reference Smithson M, Verkuilen J (2006). "A Better Lemon Squeezer? Maximum-Likelihood Regression with Beta-Distributed Dependent Variables." Psychological Methods, 11 (1), 54–71.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Would it also be possible to set observations of the response value to a very small value (e.g., 0.00001) instead of a true zero? $\endgroup$ – Jens de Bruijn Feb 13 at 10:38
1
$\begingroup$

Don't you do a logit transform to make the variable ranging from minus infinity to plus infinity? I am not sure if data having 0 and 1 should be a problem. Is that showing any error message? By the way, if you only have proportions your analysis will always come out wrong. You need to use weight=argument to glm with the number of cases.

If nothing works, you can use a median split or a quartile split or whatever cut point you think appropriate to split out the DV into several categories and then run an Ordinal logistic regression instead. That may work. Try these things.

I don't think personally that adding 0.001 to the zeros and taking 0.001 from the ones is a too bad idea, but it has some problems which will be discussed later. Just think, why don't you add and subtract 0.000000001 (or even more of the decimals)? That will better represent 0 and 1!! It may seem to you that it doesn't make much difference. But it actually does.

Let's see the following:

> #odds when 0 is replaced by 0.00000001

> 0.00000001/(1-0.00000001)
[1] 1e-08
> log(0.00000001/(1-0.00000001))
[1] -18.42068

> #odds when 1 is replaced by (1-0.00000001):

> (1-0.00000001)/(1-(1-0.00000001))
[1] 1e+08
> log((1-0.00000001)/(1-(1-0.00000001)))
[1] 18.42068

> #odds when 0 is replaced by 0.001

> 0.001/(1-0.001)
[1] 0.001001001
> log(0.001/(1-0.001))
[1] -6.906755

> #odds when 1 is replaced by (1-0.001):

> (1-0.001)/(1-(1-0.001))
[1] 999
> log((1-0.001)/(1-(1-0.001)))
[1] 6.906755

So, you see, you need to keep the odds as close as (0/1) and (1/0). You expect the log odds ranging from minus infinity to plus infinity. So, to add or subtract, you need to choose up to a really really long decimal place, so that the log odds becomes close to infinity (or very large)!! The extent you will consider large enough, solely depends on you.

| cite | improve this answer | |
$\endgroup$
1
$\begingroup$

Check out the following, where an ad hoc transformation is mentioned maartenbuis.nl/presentations/berlin10.pdf on slide 17. Also you could modeling 0 and 1 with two separate logistic regressions and then use Beta regression for those not at the boundary.

| cite | improve this answer | |
$\endgroup$
1
$\begingroup$

Came across a current online review piece on 'Zero-One Inflated Beta Models', by Karen Grace-Martin in "The Analysis Factor", outlining the proposed solution (noted above by Matze O in 2013) to address the 0/1 occurrence issue. To quote parts from the non-technical review:

So if a client takes their medication 30 out of 30 days, a beta regression won’t run. You can’t have any 0s or 1s in the data set.

Zero-One Inflated Beta Models

There is, however, a version of beta regression model that can work in this situation. It’s one of those models that has been around in theory for a while, but is only in the past few years become available in (some) mainstream statistical software.

It’s called a Zero-One-Inflated Beta and it works very much like a Zero-Inflated Poisson model.

It’s a type of mixture model that says there are really three processes going on.

One is a process that distinguishes between zeros and non-zeros. The idea is there is something qualitatively different about people who never take their medication than those who do, at least sometimes.

Likewise, there is a process that distinguishes between ones and non-ones. Again, there is something qualitatively different about people who always take their medication than those who do sometimes or never.

And then there is a third process that determines how much someone takes their medication if they do some of the time.

The first and second processes are run through a logistic regression and the third through a beta regression.

These three models are run simultaneously. They can each have their own set of predictors and their own set of coefficients...

Depending on the shape of the distribution, you may not need all three processes. If there are no zeros in the data set, you may only need to accommodate inflation at 1.

It’s highly flexible and adds important options to your data analysis toolbox."

Here is also a more recent December 2015 technical paper source for 'zoib: An R Package for Bayesian Inference for Beta Regression and Zero/One Inflated Beta Regression'. The authors note that the y variable, in a Zero/one inflated beta (ZOIB) regression model(s), can be applied when y takes values from closed unit interval [0, 1]. Apparently, the zoib model assumes that Yij follows a piecewise distribution (see system depicted in (1) on p.36).

| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

The beta model is for a binary variable that is modeled as Bernoulli-distributed with unknown probability $p$. The beta model calculates a likelihood over $p$, which is beta-distributed.

Your variable is a proportion. You could model the proportion as being beta-distributed with unknown parameters $a, b$. The model you want is the conjugate prior of the beta distribution, which will then calculate a likelihood over $a, b$.

I would have to derive the model again, but if I remember correctly, for proportions $x_1, \dotsc, x_n$ you return three expectation parameters: $n$, the number of points, and if my memory is right $\sum_j[\psi(\sum_i x_i) - \psi(x_j)]$ and $\sum_j[\psi(\sum_i 1-x_i) - \psi(1-x_j)]$. These are the parameters of a distribution over the parameters of your beta distribution, which model your proportions.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.