I am trying to fit a gamma distribution to the failure time of a kind of bulb. I have 40 data. However only half of them are actually the failure time. The result 20 are times those bulbs being used (but they haven't failed yet).

How can I fit a gamma distribution to all the data I have?

  • 4
    $\begingroup$ Hi, welcome to SE. It sounds like the best approach is to use Survival Analysis techniques because some of your bulbs have censored lifetimes. Essentially, if you want to fit a Gamma distribution, the likelihood function needs to be adjusted for those censored observations. $\endgroup$ – StatsPlease Feb 11 '18 at 21:36
  • $\begingroup$ @StatsPlease Could you please provide more about the second way? It's coursework so I cannot choose other models to fit. $\endgroup$ – Harold Feb 11 '18 at 21:54
  • 3
    $\begingroup$ Many questions on site relate to estimation via maximum likelihood under censoring. A search should turn some of them up. While it's easy enough (as you can see at the 2nd wikipedia link) to write the log-likelihood fo the censored and uncensored observations (and to use a good optimization routine to maximize it), I'd use a survival analysis routine (like survreg in R) to fit a gamma to censored data myself - it takes care of a lot of the effort automatically $\endgroup$ – Glen_b -Reinstate Monica Feb 11 '18 at 22:08
  • $\begingroup$ Look at stats.stackexchange.com/questions/133347/… for instance $\endgroup$ – kjetil b halvorsen May 12 '18 at 20:15

Numerically solving the likelihood equation remains possible when some or all of the observations are censored.

For instance, suppose we have observations of failure times $\boldsymbol x = (x_1, \ldots, x_n)$, and observations of censoring times $\boldsymbol y = (c_1, \ldots, c_m)$, for a total sample of $m+n$ bulbs, where observations are IID gamma with shape $a$ and rate $b$. Then the likelihood is simply $$\mathcal L(a, b \mid \boldsymbol x, \boldsymbol c) = \prod_{i=1}^n \frac{b^a x_i^{a-1} e^{-b x_i}}{\Gamma(a)} \prod_{j=1}^m S_X(c_j),$$ where $S$ is the survival function of the lifetime; i.e. $$S_X(c_j) = \Pr[X > c_j] = \int_{x = c_j}^\infty \frac{b^a x^{a-1} e^{-b x}}{\Gamma(a)} \, dx = \Gamma(a;c_j).$$ A closed-form solution in the general case is not possible. Software exists to calculate the solution when the data are provided.


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