chjackson / flexsurv

The flexsurv R package for flexible parametric survival and multi-state modelling
http://chjackson.github.io/flexsurv/
54 stars 28 forks source link

Problem with gengamma (reverse parameters) #59

Closed laclauc closed 4 years ago

laclauc commented 5 years ago

Dear chjackson,

There is a point that is quite unclear to me when using your code to generate generalized gamma distributions (all gengamma). In the parameters of the function, the so-called "shape" and "k" parameters seems to be reversed ( shape -> k and k->shape).

For instance in dgengamma.orig :

logdens <- log(shape) - lgamma(k) + (shape*k - 1)*log(x) - shape*k*log(scale) - (x/scale)^shape

should be

logdens <- log(k) - lgamma(shape) + (shape*k - 1)*log(x) - shape*k*log(scale) - (x/scale)^k

Could you please verify and confirm this point ?

Best regards, Charlotte Laclau

chjackson commented 5 years ago

I don't see the problem - it's consistent with the definition of the PDF given in the help page, which is from Stacy 1962. It's the same as on https://en.wikipedia.org/wiki/Generalized_gamma_distribution but with d = shape*k and p = shape

You might sometimes see the second and third parameters both referred to as "shape" parameters - is this where the confusion is from? For example with b=1 it reduces to the Gamma distribution - then k would be the shape...