16
$\begingroup$

Consider gamma random variable $X\sim\Gamma(\alpha, \theta)$. There are neat formulas for the mean, variance, and skewness:

\begin{align} \mathbb E[X]&=\alpha\theta\\ \operatorname{Var}[X]&=\alpha\theta^2=1/\alpha\cdot\mathbb E[X]^2\\ \operatorname{Skewness}[X]&=2/\sqrt{\alpha} \end{align}

Consider now a log-transformed random variable $Y=\log(X)$. Wikipedia gives formulas for the mean and the variance:

\begin{align} \mathbb E[Y]&=\psi(\alpha)+\log(\theta)\\ \operatorname{Var}[Y]&=\psi_1(\alpha)\\ \end{align}

via digamma and trigamma functions which are defined as the first and the second derivatives of the logarithm of the gamma function.

What is the formula for the skewness?

Will tetragamma function appear?

(What made me wonder about this is a choice between lognormal and gamma distributions, see Gamma vs. lognormal distributions. Among other things, they differ in their skewness properties. In particular, skewness of the log of lognormal is trivially equal to zero. Whereas skewness of the log of gamma is negative. But how negative?..)

$\endgroup$
  • 1
    $\begingroup$ Does this help? Or this? $\endgroup$ – S. Kolassa - Reinstate Monica Nov 9 '17 at 10:16
  • $\begingroup$ I am not quite sure what log-gamma distribution is. If it's related to gamma as lognormal is related to normal, then I am asking about something else (because "lognormal", confusingly, is distribution of exp(normal) not of log(normal)). $\endgroup$ – amoeba says Reinstate Monica Nov 9 '17 at 10:17
  • 1
    $\begingroup$ @Glen_b: To be honest, I'd say that calling the exponential of the normal a "lognormal" is far more inconsistent and confusing. Although, unfortunately, more established. $\endgroup$ – S. Kolassa - Reinstate Monica Nov 9 '17 at 11:13
  • 2
    $\begingroup$ @Stephan see also log-logistic, log-Cauchy, log-Laplace etc etc. It's a more clearly established convention than the opposite $\endgroup$ – Glen_b -Reinstate Monica Nov 9 '17 at 11:32
  • 1
    $\begingroup$ Yep; I have been careful not to say "log-gamma" anywhere in relation to this distribution for this reason. (I have used it in the past in a consistent manner to the log-normal) $\endgroup$ – Glen_b -Reinstate Monica Nov 9 '17 at 13:04
12
+100
$\begingroup$

The moment generating function $M(t)$ of $Y=\ln X$ is helpful in this case, since it has a simple algebraic form. By the definition of m.g.f., we have $$\begin{aligned}M(t)&=\operatorname{E}[e^{t\ln X}]=\operatorname{E}[X^t]\\ &=\frac{1}{\Gamma(\alpha)\theta^\alpha}\int_0^\infty x^{\alpha+t-1}e^{-x/\theta}\,dx\\ &=\frac{\theta^{t}}{\Gamma(\alpha)}\int_0^\infty y^{\alpha+t-1}e^{-y}\,dy\\ &=\frac{\theta^t\Gamma(\alpha+t)}{\Gamma(\alpha)}.\end{aligned}$$

Let's verify the expectation and the variance you gave. Taking derivatives, we have $$M'(t)=\frac{\Gamma'(\alpha+t)}{\Gamma(\alpha)}\theta^t+\frac{\Gamma(\alpha+t)}{\Gamma(\alpha)}\theta^t\ln(\theta)$$ and $$M''(t)=\frac{\Gamma''(\alpha+t)}{\Gamma(\alpha)}\theta^t+\frac{2\Gamma'(\alpha+t)}{\Gamma(\alpha)}\theta^t\ln(\theta)+\frac{\Gamma(\alpha+t)}{\Gamma(\alpha)}\theta^t\ln^2(\theta).$$ Hence, $$\operatorname{E}[Y]=\psi^{(0)}(\alpha)+\ln(\theta),\qquad\operatorname{E}[Y^2]=\frac{\Gamma''(\alpha)}{\Gamma(\alpha)}+2\psi^{(0)}(\alpha)\ln(\theta)+\ln^2(\theta).$$ It follows then $$\operatorname{Var}(Y)=\operatorname{E}[Y^2]-\operatorname{E}[Y]^2=\frac{\Gamma''(\alpha)}{\Gamma(\alpha)}-\left(\frac{\Gamma'(\alpha)}{\Gamma(\alpha)}\right)^2=\psi^{(1)}(\alpha).$$

To find the skewness, note the cumulant generating function (thanks @probabilityislogic for the tip) is $$K(t)=\ln M(t)=t\ln\theta+\ln\Gamma(\alpha+t)-\ln\Gamma(\alpha).$$ The first cumulant is thus simply $K'(0)=\psi^{(0)}(\alpha)+\ln(\theta)$. Recall that $\psi^{(n)}(x)=d^{n+1}\ln\Gamma(x)/dx^{n+1}$, so the subsequent cumulants are $K^{(n)}(0)=\psi^{(n-1)}(\alpha)$, $n\geq2$. The skewness is therefore $$\frac{\operatorname{E}[(Y-\operatorname{E}[Y])^3]}{\operatorname{Var}(Y)^{3/2}}=\frac{\psi^{(2)}(\alpha)}{[\psi^{(1)}(\alpha)]^{3/2}}.$$

As a side note, this particular distribution appeared to have been thoroughly studied by A. C. Olshen in his Transformations of the Pearson Type III Distribution, Johnson et al.'s Continuous Univariate Distributions also has a small piece about it. Check those out.

$\endgroup$
  • 3
    $\begingroup$ You should differentiate $K (t)=\log [M (t)]=t\log [\theta]+\log [\Gamma (\alpha+t)]-\log [\Gamma (\alpha)] $ instead of $M (t) $ as this is the cumulant generating function - more directly related to central moments - $skew=K^{(3)}(0)=\psi^{(2)}(\alpha) $ where $\psi^{(n)}(z) $ is the polygamma function $\endgroup$ – probabilityislogic Nov 9 '17 at 13:55
  • 1
    $\begingroup$ @probabilityislogic: very good call, changed my answer $\endgroup$ – Francis Nov 9 '17 at 14:07
  • $\begingroup$ @probabilityislogic This is a great addition, thanks a lot. I just want to note, lest some readers be confused, that skewness is not directly given by the third cumulant: it's the third standardized moment, not the third central moment. Francis has it correct in his answer, but the last formula in your comment is not quite right. $\endgroup$ – amoeba says Reinstate Monica Nov 9 '17 at 22:32
13
+50
$\begingroup$

I. Direct computation

Gradshteyn & Ryzhik [1] (sect 4.358, 7th ed) list explicit closed forms for $$\int_0^\infty x^{\nu-1}e^{-\mu x}(\ln x)^p dx$$ for $p=2,3,4$ while the $p=1$ case is done in 4.352 (assuming you regard expressions in $\Gamma, \psi$ and $\zeta$ functions as closed form) -- from which it is definitely doable up to kurtosis; they give the integral for all $p$ as a derivative of a gamma function so presumably it's feasible to go higher. So skewness is certainly doable but not especially "neat".

Details of the derivation of the formulas in 4.358 are in [2]. I'll quote the formulas given there since they're slightly more succinctly stated and put 4.352.1 in the same form.

Let $\delta= \psi(a)-\ln \mu$. Then:

\begin{align} \int_0^\infty x^{a-1} e^{-\mu x} \ln x \,dx &=\frac{\Gamma(a)}{\mu^a}\left\{ \delta \right\} \\ \int_0^\infty x^{a-1} e^{-\mu x} \ln^2\!x \,dx &=\frac{\Gamma(a)}{\mu^a}\left\{ \delta^2+\zeta(2,a) \right\} \\ \int_0^\infty x^{a-1} e^{-\mu x} \ln^3\!x \,dx &=\frac{\Gamma(a)}{\mu^a}\left\{ \delta^3+3\zeta(2,a)\delta-2\zeta(3,a) \right\} \\ \int_0^\infty x^{a-1} e^{-\mu x} \ln^4\!x \,dx &=\frac{\Gamma(a)}{\mu^a}\left\{ \delta^4+6\zeta(2,a)\delta^2-8\zeta(3,a)\delta + 3\zeta^2(2,a)+6\zeta(4,a)) \right\} \end{align}

where $\zeta(z,q)=\sum_{n=0}^\infty \frac{1}{(n+q)^z}$ is the Hurwitz zeta function (the Riemann zeta function is the special case $q=1$).

Now on to the moments of the log of a gamma random variable.

Noting firstly that on the log scale the scale or rate parameter of the gamma density is merely a shift-parameter, so it has no impact on the central moments; we may take whichever one we're using to be 1.

If $X\sim \text{Gamma}(\alpha,1)$ then $$E(\log^{p}\!X) = \frac{1}{\Gamma(\alpha)}\int_0^\infty \log^{p}\!x\, x^{\alpha-1} e^{-x} \,dx.$$

We can set $\mu=1$ in the above integral formulas, which gives us raw moments; we have $E(Y)$, $E(Y^2)$, $E(Y^3)$, $E(Y^4)$.

Since we have eliminated $\mu$ from the above, without fear of confusion we're now free to re-use $\mu_k$ to represent the $k$-th central moment in the usual fashion. We may then obtain the central moments from the raw moments via the usual formulas.

Then we can obtain the skewness and kurtosis as $\frac{\mu_3}{\mu_2^{3/2}}$ and $\frac{\mu_4}{\mu_2^{2}}$.


A note on terminology

It looks like Wolfram's reference pages write the moments of this distribution (they call it ExpGamma distribution) in terms of the polygamma function.

By contrast, Chan (see below) calls this the log-gamma distribution.


II. Chan's formulas via MGF

Chan (1993) [3] gives the mgf as the very neat $\Gamma(\alpha+t)/\Gamma(\alpha)$.

(A very nice derivation for this is given in Francis' answer, using the simple fact that the mgf of $\log(X)$ is just $E(X^t)$.)

Consequently the moments have fairly simple forms. Chan gives:

$$E(Y)=\psi(\alpha)$$

and the central moments as

\begin{align} E(Y-\mu_Y)^2 &= \psi'(\alpha) \\ E(Y-\mu_Y)^3 &= \psi''(\alpha) \\ E(Y-\mu_Y)^4 &= \psi'''(\alpha) \end{align}

and so the skewness is $\psi''(\alpha)/(\psi'(\alpha)^{3/2})$ and kurtosis is $\psi'''(\alpha)/(\psi'(\alpha)^{2})$. Presumably the earlier formulas I have above should simplify to these.

Conveniently, R offers digamma ($\psi$) and trigamma ($\psi'$) functions as well as the more general polygamma function where you select the order of the derivative. (A number of other programs offer similarly convenient functions.)

Consequently we can compute the skewness and kurtosis quite directly in R:

skew.eg <- function(a) psigamma(a,2)/psigamma(a,1)^(3/2)
kurt.eg <- function(a) psigamma(a,3)/psigamma(a,1)^2

Trying a few values of a ($\alpha$ in the above), we reproduce the first few rows of the table at the end of Sec 2.2 in Chan [3], except that the kurtosis values in that table are supposed to be excess kurtosis, but I just calculated kurtosis by the formulas given above by Chan; these should differ by 3.

(E.g. for the log of an exponential, the table says the excess kurtosis is 2.4, but the formula for $\beta_2$ is $\psi'''(1)/\psi'(1)^2$ ... and that is 2.4.)

Simulation confirms that as we increase sample size, the kurtosis of a log of an exponential is converging to around 5.4 not 2.4. It appears that the thesis possibly has an error.

Consequently, Chan's formulas for central moments appear to actually be the formulas for the cumulants (see the derivation in Francis' answer). This would then mean that the skewness formula was correct as is; because the second and third cumulants are equal to the second and third central moments.

Nevertheless these are particularly convenient formulas as long as we keep in mind that kurt.eg is giving excess kurtosis.

References

[1] Gradshteyn, I.S. & Ryzhik I.M. (2007), Table of Integrals, Series, and Products, 7th ed.
Academic Press, Inc.

[2] Victor H. Moll (2007)
The integrals in Gradshteyn and Ryzhik, Part 4: The gamma function
SCIENTIA Series A: Mathematical Sciences, Vol. 15, 37–46
Universidad Técnica Federico Santa María, Valparaíso, Chile
http://129.81.170.14/~vhm/FORM-PROOFS_html/final4.pdf

[3] Chan, P.S. (1993),
A statistical study of log-gamma distribution,
McMaster University (Ph.D. thesis)
https://macsphere.mcmaster.ca/bitstream/11375/6816/1/fulltext.pdf

$\endgroup$
  • 1
    $\begingroup$ Cool. Thanks a lot! According to the encyclopedia entry that Stephan linked to above, the final answer for skewness is $\psi''(\alpha)/\psi'(\alpha)^{3/2}$ (which almost qualifies as "neat"!). So it seems that all the scary zetas will have to cancel out. $\endgroup$ – amoeba says Reinstate Monica Nov 9 '17 at 11:34
  • 1
    $\begingroup$ Sorry only just now saw your comment (I've been editing for about an hour or so); that's correct, though if the Encyclopedia gives kurtosis the way Chan gives it in his thesis, it seems that it's wrong (as given above), but readily corrected. The neat formulas appear to be for cumulants rather than standardized central moments. $\endgroup$ – Glen_b -Reinstate Monica Nov 9 '17 at 12:55
  • $\begingroup$ Yes, the Encyclopedia does give the same formula for kurtosis. $\endgroup$ – amoeba says Reinstate Monica Nov 9 '17 at 13:15
  • $\begingroup$ Hmm, I mean to refer to the things normally denoted $\gamma_1$ and $\gamma_2$. I will fix. $\endgroup$ – Glen_b -Reinstate Monica Nov 9 '17 at 13:51
  • 2
    $\begingroup$ I should probably add the note that the Hurwitz zeta function can be expressed in terms of the polygamma function, and vice versa: $$\psi^{(n)}(z)=(-1)^{n+1}\,\Gamma(n+1)\,\zeta(n+1,z)$$ So, the answer to the @amoeba's question of "will the tetragamma function appear?" is YES. $\endgroup$ – J. M. is not a statistician Nov 9 '17 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.