# [R] Likelihood optimization numerically

Date: Sat, 26 Jan 2008 22:47:40 -0800 (PST)

Dear List,

I am not sure how should i optimize a log-likelihood numerically: Here is a Text book example from Statistical Inference by George Casella, 2nd Edition Casella and Berger, Roger L. Berger (2002, pp. 355, ex. 7.4 # 7.2.b):

data = x = c(20.0, 23.9, 20.9, 23.8, 25.0, 24.0, 21.7, 23.8, 22.8, 23.1, 23.1, 23.5, 23.0, 23.0) n <- length(x)

# likelihood from a 2 parameter Gamma(alpha, beta), both unknown llk = -n*log(gamma(alpha)) - n*alpha*log(beta) + (alpha - 1)*(sum(log(x))) - (sum(x))/beta

```# analytic 1st derivative solution w.r.t alpha, assuming beta known
# by putting MLE of beta = sum(x)/(n*alpha)
# (to simplify as far as possible analytically)
```
llk.1st = - n*digamma(alpha) -n*(log(sum(x)/(n*alpha))+1) + (sum(log(x)))

It feels like i should use
nls(... , trace=T, start=c(alpha=...),nls.control(maxiter=100,tol=.1)) but not sure "how".

Can anyone provide me hint?

> R.Version()
\$platform
[1] "i386-pc-mingw32"
\$arch
[1] "i386"

\$os
[1] "mingw32"

\$system
[1] "i386, mingw32"

\$status
[1] ""

\$major
[1] "2"

\$minor
[1] "6.1"
\$year
[1] "2007"

\$month
[1] "11"

\$day
[1] "26"

\$`svn rev`
[1] "43537"

\$language
[1] "R"

\$version.string
[1] "R version 2.6.1 (2007-11-26)"

Be a better friend, newshound, and

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 Sun 27 Jan 2008 - 06:55:00 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 Sun 27 Jan 2008 - 10:30:09 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.