This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: .grad[,"mu"] = -(xbar-mu)/sig2 .grad[,"sig2"] = n/(2*sig2) - b/(2*sig2^2) attr(L, "gradient") = .grad L } # simulate some data mu.true = 2 sig2.true = 4 n = 20 x.dat = rnorm(n, mean = mu.true, sd = sqrt(sig2.true) ) a.0 = c(0,1) x.fit = nlm(NLik, p=a.0 ,x=x.dat) x.fit #calculate MLE using analytic formula mu.hat = mean(x.dat) sig2.hat = sum( (x.dat - mu.hat)^2)/length(x.dat) mu.hat Page 1 of 2 25/01/2011 http://www.stats.uwo.ca/faculty/kulperger/Stat3858/Computing/RScripts/Normal-est-nlm. .. sig2.hat # also # n = length(x.dat) # sig2.hat = var(x.dat)*(n-1)/n Page 2 of 2 25/01/2011 http://www.stats.uwo.ca/faculty/kulperger/Stat3858/Computing/RScripts/Normal-est-nlm. .....
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.
- Spring '11