Transcription of Maximum Likelihood Programming in R
{{id}} {{{paragraph}}}
Maximum Likelihood Programming in RMarco R. SteenbergenDepartment of Political ScienceUniversity of North Carolina, Chapel HillJanuary 2006 Contents1 Introduction22 Syntactic Declaring the Log- Likelihood Function .. Optimizing the Log- Likelihood .. 43 Output54 Obtaining Standard Errors55 Test Statistics and Output Control711 IntroductionThe Programming language R is rapidly gaining ground among political method-ologists. A major reason is that R is a flexible and versatile language, whichmakes it easy to program new routines. In addition, R algorithms are generallyvery is well-suited for Programming your own Maximum Likelihood , there are several procedures for optimizing Likelihood functions. Here Ishall focus on theoptimcommand, which implements the BFGS and L-BFGS-Balgorithms, among throughoptimis relatively straight-forward, since it is usually not necessary to provide analytic first and secondderivatives.
l = ¡:5nln(2…)¡:5nln(¾2)¡ 1 2¾2 X i (yi ¡„)2 We can program this function in the following way: normal.lik1<-function(theta,y)f mu<-theta[1] sigma2<-theta[2] n<-nrow(y) 2We ask for ¡1 £ l because the optim command minimizes a function by default. Mini-mization of ¡l is the same as maximization of l, which is what we want. 3
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}