12. [R] calculation of MLE for Gamma distribution(illinois rainfall data;Ch 10) (Jan24)

12[R calculation - calculation of MLE for Gamma distribution illinois 1960 rainfall data(see chapter 10 This function computes the method of

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # calculation of MLE for Gamma distribution # illinois 1960 rainfall data (see chapter 10) # This function computes the method of moments estimator and its approximate variance gamma.moment.est.2 = function (x) { note = "Fit a Gamma distribution by method of moments" mu.1 = mean(x) mu.2 = mean(x^2) var.x = mu.2-mu.1^2 V.hat = var(cbind(x,x^2)) lam.hat = mu.1/(mu.2-mu.1^2) alpha.hat = mu.1*lam.hat # estimate of variance for lam.hat based on delta method a2 = array( c(mu.1^2+mu.2, -mu.1)/((mu.2-mu.1^2)^2) ,c(2,1)) tau.lam = t(a2)%*%V.hat%*%a2 a1 = array( c( 2*mu.1*mu.2, -mu.1^2)/((mu.2-mu.1^2)^2) ,c(2,1)) tau.alpha = t(a1)%*%V.hat%*%a1 list(theta.hat=c(lam.hat,alpha.hat),mu.1=mu.1,mu.2=mu.2,V.hat=V.hat,tau1=tau.alpha,tau2=tau.lam) } # the MLE needs to be computed using an interative method, as there is no explicit solution to the MLE # it appears easier to use the minimizer optim, but two R functions to find the MLE are given here # this function gives the negative log likelihood in a form to be used in the nonlinear minimier nlm...
View Full Document

This note was uploaded on 01/17/2012 for the course AM 1234 taught by Professor Qqqq during the Spring '11 term at UWO.

Page1 / 2

12[R calculation - calculation of MLE for Gamma distribution illinois 1960 rainfall data(see chapter 10 This function computes the method of

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online