{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

Info icon This 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 ,
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

{[ 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