Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mean of generalized gamma distribution #12

Open
mr-infty opened this issue May 31, 2024 · 1 comment
Open

Mean of generalized gamma distribution #12

mr-infty opened this issue May 31, 2024 · 1 comment

Comments

@mr-infty
Copy link

Problem

The doc of GG claims that the mean of the distribution corresponding to the parameters (\mu, \sigma, \nu) is equal to \mu, but that does not appear to be true.

Details

The formula for the probability density given in the documentation matches up with the generalized Gamma distribution defined in https://arxiv.org/pdf/1005.3274, under the following mapping of parameters:

(\mu, \sigma, \nu) \mapsto (\theta = \mu (\sigma^2 \nu^2)^{1 / \nu}, \alpha = 1/(\sigma^2 \nu^2), \nu).

The formula for the mean given in loc. cit. then shows that the mean of the distribution is

\theta \frac{\Gamma(\alpha + 1/\beta)}{\Gamma(\alpha)}

which does not appear to equal \mu unless \nu = 1.

Numerical evaluations seem to support this claim.

@zeileis
Copy link
Member

zeileis commented Jun 2, 2024

I agree. The \description{} in the Rd file (in gamlss.dist) seems to be incorrect and too simple:

https://github.com/gamlss-dev/gamlss.dist/blob/main/man/GG.Rd#L12-L16

The actual code for both $mean and $variance in the family is much more involved:

https://github.com/gamlss-dev/gamlss.dist/blob/main/R/GG.R#L89-L94

The computations appear to be in sync with empirical computations based on simulated data. Consider the following three theoritcal distributions:

library("distributions3")
library("gamlss.dist")
d <- GAMLSS("GG", mu = c(0.5, 1, 2), sigma = c(1.5, 1, 0.5), nu = c(2, 0.5, 1))
cbind(mean(d), sqrt(variance(d)))
##           [,1]      [,2]
## [1,] 0.2577079 0.4284701
## [2,] 1.2500000 1.3110111
## [3,] 2.0000000 1.0000000

And the following simulations from it:

set.seed(0)
y <- random(d, 10000)
cbind(apply(y, 1, mean), apply(y, 1, sd))
##           [,1]      [,2]
## [1,] 0.2526009 0.4211723
## [2,] 1.2449258 1.2982611
## [3,] 2.0047618 1.0025138

These seem to agree reasonably well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants