Solved – Generalized Gamma GLM

the generalized gamma distribution is a generalization of the two-parameter gamma distribution:

However I cannot find an implementation in R (or python) that let's me use this in a GLM framework, so something like
glm(y ~ x, family(GenGamma)).

I could only find a distribution definition in the flexsurv package, but only for a survival usage.

Is there a way to use the generalized gamma in a GLM setting?


method 1. suggested by @Glen_b works quite well:

library(flexsurv) df <- data.frame(y = runif(100, 1, 10), x1 = rnorm(100)) flexsurvreg(Surv(y) ~ x1, data = df, dist = "gengamma") 

There are several reasonably clear options.

  1. You can use the survival model. Treat the response values as all-uncensored survival times. I've used this strategy to fit Weibull models for example; it often works quite well.

    There's an example here that shows doing it with a Weibull model for non-survival data. [There's a second example here of using it to simply fit a Weibull distribution in a case where the usual fitdistr approach was having trouble.]

    Those two examples should be sufficient to convey the general idea, and apply it to the generalized gamma.

  2. If you know the "power" parameter ($p$ in the Wikipedia link) you can transform the data to a Gamma and use GLM.

  3. If $p$ is unknown, you can use the fact that conditional on $p$ you can fit a GLM (and then ML estimation of the scale parameter for that, such as via the relevant function in MASS – which is using a similar idea) to get a profile likelihood for $p$, to obtain an overall MLE for $p$ and the gamma parameters.

  4. Alternatively you can try to use direct optimization of the likelihood.

Similar Posts:

Rate this post

Leave a Comment