1 / 10

Estimation of the Gamma Function

Estimation of the Gamma Function. Lecture XIXB. Estimate the gamma distribution using maximum likelihood:. Note that if we define two statistics. dta <- read.table ("Gamma Data 2007.dta") t1 <- sum( dta ) t2 <- sum(log( dta ))

mahsa
Download Presentation

Estimation of the Gamma Function

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Estimation of the Gamma Function Lecture XIXB

  2. Estimate the gamma distribution using maximum likelihood:

  3. Note that if we define two statistics

  4. dta <- read.table("Gamma Data 2007.dta") t1 <- sum(dta) t2 <- sum(log(dta)) fr <- function(b) { nrow(dta)*lgamma(b[1])+nrow(dta)*b[1]*log(b[2]) - (b[1]-1)*t2+1/b[2]*t1 } gfr <- function(b) { cbind(nrow(dta)*digamma(b[1])+nrow(dta)*log(b[2])-t2, nrow(dta)*b[1]/b[2]-1/b[2]^2*t1) } res <- optim(c(1.0,1.0),fr,gfr,method="BFGS") R-Code for Maximum Likelihood

  5. We know that the first four moments of the gamma distribution are Estimate the gamma distribution using method of moments.

  6. Actually the code minimized a squared error term

  7. dta <- read.table("Gamma Data 2007.dta") t1 <- mean(dta) t2 <- var(dta) fr <- function(b) { (b[1]*b[2] - t1)^2 + (b[1]*b[2]^2 - t2)^2 } gfr <- function(b) { cbind(2*(b[1]*b[2] - t1)*b[2] + 2*(b[1]*b[2]^2 - t2)*b[2]^2, 2*(b[1]*b[2] - t1)*b[1] + 4*(b[1]*b[2]^2 - t2)*b[1]*b[2]) } res <- optim(c(3.0,1.0),fr,gfr,method="BFGS") Exact Method of Moments

  8. Overidentified method of moments estimator

  9. dta <- read.table("Gamma Data 2007.dta") t1 <- mean(dta) t2 <- var(dta) t3 <- mean((dta-t1)^3) t4 <- mean((dta-t1)^4) fr <- function(b) { (b[1]*b[2] - t1)^2 + (b[1]*b[2]^2 - t2)^2 + (2/sqrt(b[1]) - t3)^2 + (6/b[1] - t4)^2 } gfr <- function(b) { cbind(2*(b[1]*b[2] - t1)*b[2] + 2*(b[1]*b[2]^2 - t2)*b[2]^2 -2*(2/sqrt(b[1]) - t3)/(b[1])^(3/2) - 12*(6/b[1] - t4)/b[1]^2, 2*(b[1]*b[2] - t1)*b[1] + 4*(b[1]*b[2]^2 - t2)*b[1]*b[2]) } res <- optim(c(3.0,2.0),fr,gfr,method="BFGS") Overidentified MOM

More Related