[R] gamma regression & zeros

Ben Bolker bbolker at gmail.com
Tue Mar 26 04:55:00 CET 2013


Sören Prehn <Prehn <at> iamo.de> writes:


> Dear all, I have a problem with gamma regression (glm - family =
> Gamma) and zeros in R. The problem is the following when I try to
> estimate a dataset without zeros (endogenous variable) there is no
> problem. However, if I try to do the same with zeros I always get an
> error message. In STATA and MATLAB I can do a gamma regression with
> zeros.  What could be the problem? If someone could help me I would
> really appreciate this.

 It's hard to know what Stata and MATLAB are doing to allow you
to fit this model.  As long as the scale parameter is >=1 everything
should be OK, but as soon as the scale parameter drops below 1 the
likelihood (density) is infinite:

dgamma(0,shape=1)
## [1] 1
dgamma(0,shape=0.9999)
## [1] Inf
 
It's conceivable that you could succeed in this task by constraining
the shape parameter to be >=1; e.g.

library(bbmle)
mle2(y~dgamma(shape=1+exp(logshape),scale=exp(logscale)),
   parameters=list(logshape~...,logscale~...), data= ...)

We would need more detail though.



More information about the R-help mailing list