Skip to content
Sarthak Bagaria

Maximum Likelihood Estimator of the parameter α of Gamma(α,1) distribution

Sarthak Bagaria

Solution to Q1: Gamma Sample Generation

We use the standard routine rgamma in R language, which uses the following method for generation of Gamma sample:

For 𝜶<𝟏

A rejection technique [1] is used based on the majoring function

g(x)=xα1/Γ(α)if 0<x1;g(x)=ex/Γ(α)if 1x.

Since ex1 if 0<x and xα11 if α1 and 1x the inequality exxα1/Γ(α)=f(x)g(x) is valid for all x>0. The function

h(x)=xα1ea/(e+a)if 0<x1;h(x)=exea/(e+a)if 1x

is a probability density that is proportional to g(x). Sampling from h(x) is no problem since both parts have easily invertible integrals: with a probability of e/(e+a) an x below 1 (first part of h(x)) is sampled, otherwise the second part of h(x) is used. The rejection test is based on f(x)/g(x) which is ex or xα1.

For 𝜶𝟏

Ahrens and Dieter’s modified rejection method [2] is used.

Applying the transformation x=(α1/2+t/2)2, the resulting transformed function g(t) is close to the standard normal density f(t). The mode of g(t) is at t=0, but g(0) is a little larger than f(0)=1/2π. Also, g(t) intersects the standard normal density f(t) only once at some t=τ(a)<0. Consequently, g(t)f(t) for all t0. This calls for the following modification of Von Neumann’s acceptance-rejection technique:
Generate a standard normal deviate T [3]. If T0, accept x=(α1/2+T/2)2 as a gamma(α) sample. For Tτ(α), where f(t) majorizes g(t), the ratio r(T)=g(T)/f(T) can be compared with a (0, 1)-uniform deviate U for an ordinary rejection test. (For simplicity this test is also applied when τ(a)<T<0. In this case r(t)>1 and T is always accepted.) Obviously rejection occurs with probability P(H)=τ(f(t)g(t))𝑑t=τ(g(t)f(t)). Hence, whenever a negative T is rejected, it must be replaced with a new Tτ(α), and this has to be a sample from the difference distribution whose probability density function is proportional to g(t)f(t) in [τ,). Sampling from this difference is done by means of a double-exponential hat.

Solution to Q2: Maximum Likelihood Estimation of α

We use the standard routine fitdistr in R language, with BFGS method. For Gamma distribution reasonable starting values for the iterative method can be computed by the routine itself.

BFGS Method [4]

In Newton’s method, we find the new iterate xk+1 as a function of xk as follows. For any point x define p=xxk, the second order Taylor expansion around xk is given by

mk(p)=fk+pTfk+12pTBkp

This defines a quadratic model of the function near the point xk . Its gradient with respect to x is mk(p)=fk+Bkp, and it is minimized at pk=Bk1fk.

Working with the inverse Hessian Hk in place of Bk, the secant equation becomes Hkyk1=sk1. The optimization is then : minimize HHk1W subject to H=HT, Hyk1=sk1, which has the unique solution

Hk=(Ipksk1yk1T)Hk1(Ipk1yk1sk1T)+sk1pk1sk1T

where sk1=xkxk1, yk1=fkfk1, W is any matrix satisfying Wyk1=sk1, and HHk1W=W12(HHk1)W12.

Each step of the BFGS method has the form

xk+1=xkαkHkfk,k=0,1,2,

where αk is computed from a line search procedure to satisfy the Wolfe conditions:

f(xk+αkpk)f(xk)+c1αkfkTpk,
f(xk+αkpk)Tpkc2fkTpk

with 0<c1<c2<1.

Solution to Q3 & Q4: Results

The following graphs were plotted for values of MLE of α against the values of α0, the parameter used for generation of sample. α0 ranges from .1 to 10 in steps of .1, and for each value of α0, estimates for 20 samples are calculated. n is the number of Gamma variates in a single sample.

Example outputs from different samples with α for α0=5:

n=10:
5.3144648(0.6950958);4.5355942(0.6368612);4.6917132(0.6489457);
5.743960(0.725238);4.0315324(0.5962093);5.2970827(0.6938487);

n=50:
4.6669183(0.2893656);4.6980724(0.2904354);4.9866184(0.3001651);
4.7338926(0.2916606);4.7629318(0.2926501);4.927377(0.298193);

n=100:
5.4493586(0.2228456);5.1090057(0.2151015);5.5133350(0.2242719);
4.9219525(0.2107262);5.2803015(0.2190328);5.3109010(0.2197278);

n=500:
4.99358132(0.09499359);5.15714169(0.09669357);5.15428979(0.09666418);
5.11426871(0.09625083);5.01874406(0.09525706);4.95975300(0.09463824);

The quantities in brackets are the estimated standard errors due to numerical optimization, which, we see, decrease as the sample size n is increased. Also, the variance of the estimates is less for large sample sizes.

[Uncaptioned image]
[Uncaptioned image]
[Uncaptioned image]
[Uncaptioned image]

And though we have different algorithms for sample generation for the cases α0<1 and α01, the sampling and estimation methods do not differentiate between integer and non-integer α0 values, and the precision achieved is similar in two cases.

For example, when n=50 and α=5.1:
5.3183637(0.3109812);4.9230182(0.2980474);4.8010873(0.2939454);
5.1262415(0.3047635);5.3411929(0.3117119);5.0274508(0.3015171);

Examples of generated Samples:

[Uncaptioned image]
[Uncaptioned image]
[Uncaptioned image]
[Uncaptioned image]

Code for plots (in R language)


library(MASS)
n=50                       #number of variates in each sample
alpha=.1*(1:100)           #range of alpha for sample generation
s=20Ψ                      #number of samples for each value of alpha
assign("x", c())
assign("y", c())
assign("z", c())
for (a in alpha)
  for (i in 1:s) {
    x <- c(x,(a))
    y <- c(y,fitdistr(rgamma(n,(a)), "gamma", rate=1, method="BFGS"))
  }
for (i in 1:(s*length(alpha))) z[i] = y[[5*i-4]]
plot(
 Ψx,z, type="l", main=expression(paste("MLE of ",alpha)),
 Ψsub=substitute(paste("n = ", n), list(n=n)),
 Ψxlab=expression(alpha[0]), ylab=expression(alpha)
Ψ)

Code for single estimation (in R language)


n=50Ψ                      #number of variates in each sample
a=2                        #value of alpha for generation of sample
fitdistr(rgamma(n,a), "gamma", rate=1, method="BFGS")


References

  • [1] Ahrens, J. H. and Dieter, U. (1974). Computer methods for sampling from gamma, beta, Poisson and binomial distributions. Computing, 12, 223–246
  • [2] Ahrens, J. H. and Dieter, U. (1982). Generating gamma variates by a modified rejection technique. Communications of the ACM, 25, 47–54
  • [3] Ahrens, J. H. and Dieter, U. (1972). Computer methods for sampling from the exponential and normal distributions. Communications of the ACM, 15, 873-882
  • [4] Jorge Nocedal and Stephen J. Wright (2000). Numerical Optimization