Shape and scale parameters of gamma distribution

I have a time series having zeroes. If I don't remove them, I couldn't get the parameters i.e. scale and shape parameters of a gamma distribution. So, is this advisable to remove zeroes to get these parameters. As in the following code.

Thanks

dff=data.frame(
  "Time"=seq(1:12),
  "rain"=c(0,5,2,3,0,5,8,9,15,0,8,7)
)

U=log(mean(dff$rain)/exp(mean(log(dff$rain))))

#1. Using whole dataset including 0s
(shape=ifelse(U<0.5772,
             1/U*(0.5000876+0.1648852*U-0.054427*U*U),
             1/U*(8.898919+9.059950*U+0.9775373*U*U)/(17.7928+11.968477*U+U*U)))
(scale=mean(dff$rain)/shape)
#2. If remove "0". I got the result as
dff=dff %>% 
  filter(rain>0)
U=log(mean(dff$rain)/exp(mean(log(dff$rain))))
(shape=ifelse(U<0.5772,
              1/U*(0.5000876+0.1648852*U-0.054427*U*U),
              1/U*(8.898919+9.059950*U+0.9775373*U*U)/(17.7928+11.968477*U+U*U)))
(scale=mean(dff$rain)/shape)
# or I used 
fit <- dglm(dff$rain~1, family=Gamma(link="log"), mustart=mean(dff$rain))
mu <- exp(1.251322) # from the summary: estiamte of Mean Coefficients.
shape <- exp(1.251322) # from the summary: estiamte of dispersion Coefficients.
scale <- mu/shape
c(shape, scale)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.