{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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

View Full Document Right Arrow Icon
# 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 NLik = function(a,x){ lam = a[1] alpha = a[2] n = length(x)
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern