Generalized gamma distributions


I was wondering whether there are any plans of adding generalized gamma distribution to Stan. It’s a commonly used distribution especially in survival analysis since it incorporates Weibull, gamma, and lognormal as special cases. The distribution is available in JAGS, however, I am planning to work with the stan_surv function from rstanarm, which I find extremely promising, so I would be interested in using Stan instead of JAGS.

I do not have sufficient knowledge to propose anything, but there were some posts suggesting how it could be done parameterizations:


The generalized gamma works fine in Stan currently, although you would need to grab one of the parametrizations people have posted and sort out the parameters.

There are some implementations of mine here: tooling/models/stan-lang/functions at master · sakrejda/tooling · GitHub

Those Stan functions are in a package and unit tested against the R implementations here: tooling/code/waitup/waitup/R at master · sakrejda/tooling · GitHub


Thank you!

If I understand correctly, it’s not part of the Stan language (as other distributions like normal, Cauchy, and etc…) yet, right? Is there a plan to add it there as well in the future?

I did want to add those distributions and we had some dev discussion about it but there wasn’t much support for including them in the language. They work fine as user defined functions though.

Not all the parametrizations of the generalized gamma work well near the boundaries, such as when the data is actually gamma distributed, but one of them was pretty stable (as was the weibull and the other outlier-friendly gamma in the package).

1 Like

OK, thank you very much! That completely answers my question.

@sakrejda which parameterization ended up being the most stable for you?

I think it’s totally OK to add standard distributions to Stan. I don’t think anyone will object. It’s just a matter of whether anyone’s willing to put in the work to code and review.