10-2. [R] nlm = non linear minimization (Jan26)

10-2. [R] nlm = non linear minimization (Jan26) - x see the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
# function to produce the negative log likelihood in form for nlm neg.log.lik = function ( lam, x) { n = length(x) L = n*log(lam) - lam*sum(x) L = -L attr(L, "gradient") = -n/lam + sum(x) L } # Set lam to specified value, 2 in this example # generate some random iid exponential, lam = 2 data x = rexp(48, rate = 2) # use nlm to minimize the negative log likelihood # store the result of nlm in model.fit model.fit = nlm( neg.log.lik , p = 1 ,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x) # see the output from nlm model.fit # to see the component that is argmin model.fit$estimate # nlm will also give the Hessian, the second partial derivatives model.fit = nlm( neg.log.lik , p = 1 , hessian = T , x) ±#!² ³²+"² ³ ´µ¶ ·´¶ ´· $00, ¸¶¶33 3¹/0±0/¹13+¹º±¶"±º1(05¶' 1(, !.#!.¶»0±0¼½¾½¶¿+) , 10% *#¶5» À !#À !4, ¹040...
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.

Ask a homework question - tutors are online