From: <markleeds_at_verizon.net>

Date: Fri, 23 May 2008 16:28:25 -0500 (CDT)

}

}

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 23 May 2008 - 21:30:55 GMT

Date: Fri, 23 May 2008 16:28:25 -0500 (CDT)

for learning purposes and also to help someone, i used roger peng's
document to get the mle's of the gamma where the gamma is defined as

f(y_i) = (1/gammafunction(shape)) * (scale^shape) * (y_i^(shape-1)) * exp(-scale*y_i)

( i'm defining the scale as lambda rather than 1/lambda. various books

define it differently ).

can anyone tell me what i'm doing wrong. maybe my starting values are too far off ? thanks.

make.negloglik <- function(data, fixed=c(FALSE,FALSE)) {

op[!fixed] <- p shape <- exp(op[1]) scale <- exp(op[2]) a <- length(data)*shape*log(scale) b <- (shape-1)*sum(log(data)) c <- -1.0*scale*sum(data) -(a + b + c)

}

}

vsamples<- c(14.7, 18.8, 14, 15.9, 9.7, 12.8)
nLL <- make.negloglik(vsamples)

temp <- optim(c(scale=1,shape=1), nLL, method="BFGS")[["par"]]
estimates <- log(temp)

print(estimates)

check <- estimates[1]/mean(vsamples)

print(check)

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 23 May 2008 - 21:30:55 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sat 24 May 2008 - 07:30:43 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*