5

For microsimulations, I (i) want to estimate parameters of an empirical distribution and (ii) draw a random sample based on the estimations. My random variable $Y$ seems to follow a Generalized Beta distribution of the second kind (GB2). The pdf is defined on $\mathbb{R}_+$ by: $$ GB2(y;a,b,p,q) = \frac{|a|y^{ap-1}}{b^{ap}B(p,q)(1+(y/b)^a)^{p+q}} $$

I already estimated the parameters of the Generalized Beta (Second Kind) distribution using the GB2 stata package. Now, I wonder how to draw a random sample using the parameter estimates. What would be the normal procedure to generate random samples in this case?

Xi'an
  • 90,397
  • 9
  • 157
  • 575
Francesco
  • 85
  • 3

2 Answers2

9

If you consider the density$$f(y;a,b)=\frac{|a|y^{ap-1}}{b^{ap}B(p,q)(1+(y/b)^a)^{p+q}},$$b appears as a scale parameter. This means that, if $Z\sim f(z;a,1)$, then $bZ\sim f(z;a,b)$. So we can assume $b=1$ wlog. Now,$$f(y;a,1)=\frac{|a|y^{ap-1}}{B(p,q)(1+y^a)^{p+q}}=\frac{|a|\{y^{a}\}^{(ap-1)/a}}{B(p,q)(1+y^a)^{p+q}}$$involves only $y^a$. This suggests the change of variable $z=y^a$ or $y=z^{1/a}$. The Jacobian of this transform is $$\frac{\text{d}y}{\text{d}z}=\frac{1}{a}z^{a^{-1}-1}$$ and the density $$g(z;a)=\frac{|a|z^{(ap-1)/a}}{B(p,q)(1+z)^{p+q}}\,\frac{1}{|a|}z^{a^{-1}-1}= \frac{z^{p-a^{-1}+a^{-1}-1}}{B(p,q)(1+z)^{p+q}}=\frac{z^{p-1}}{B(p,q)(1+z)^{p+q}}$$This happens to be the density of an unormalised $F(2p,2q)$ distribution, defined as the distribution of the ratio of two independent $\chi^2$ random variables with degrees of freedom $2p$ and $2q$.

Therefore, to simulate from this $GB_2(a,b,p,q)$ distribution, follow the steps:

  1. simulate $U_1\sim\chi^2_{2p}$, $U_2\sim\chi^2_{2q}$
    1. take $Z=U_1\big/U_2$
    2. take $Y=Z^{a^{-1}}$
    3. take $X=bY$
Xi'an
  • 90,397
  • 9
  • 157
  • 575
2

While Xi'an's answer of course already addresses the underlying theory, you may also find the GB2 package in R to be convenient.

In particular, rgb2(x, shape1, scale, shape2, shape3) will produce random draws.

Christoph Hanck
  • 25,948
  • 3
  • 57
  • 106