maximum likelihood

Mathematics 344
Estimation - Gamma Example
f (x; α, λ) =
λα α−1 −λx
x
e
Γ(α)
µ = 1/λ
February 4, 2015
σ 2 = 1/λ2
Method of moments estimates
n−1 2
1
=
s
λ2
n
1
= x̄
λ
Maximum Likelihood Estimates
L(α, λ; x) =
`(α, λ; x) =
λα
Γ(α)
n
(x1 · · · xn )α−1 e−λ(x1 +···+xn )
Page 2
Maximization using numerical methods
testdata <- rgamma(30, 5, 2)
loglik <- function(p, x) {
sum(dgamma(x, p[1], p[2], log = T))
}
summary(nlmax(loglik, p = c(5, 2), x = testdata))
Warning:
Warning:
Warning:
NaNs produced
NaNs produced
NA/Inf replaced by maximum positive value
Maximum: -40.4999
Estimate:8.4118 2.9830
Gradient:-1.052e-06 2.120e-06
Iterations: 12
Relative gradient is close to zero, current iterate is probably an
approximate solution.[Code=1]
R has a function for MLE (but it’s off limits for homework!)
fitdistr(testdata, "gamma")
shape
rate
8.4120
2.9831
(2.1303) (0.7784)