[R] Confidence interval based on MLE

Ben Bolker bbolker at gmail.com
Sun Feb 6 15:56:29 CET 2011


Jinsong Zhao <jszhao <at> yeah.net> writes:

> 
> Hi there,
> 
> I have fitted a sample (with size 20) to a normal and/or logistic 
> distribution using fitdistr() in MASS or fitdist() in fitdistrplus 
> package. It's easy to get the parameter estimates. Now, I hope to report 
> the confidence interval for those parameter estimates. However, I don't 
> find a function that could give the confidence interval in R.
> 
> I hope to write a function, however, I don't find some detailed 
> information on the CI based on MLE. Would you please to give me some 
> hints on the CI calculation based on MLE?

   Well, for the normal distribution I believe that the standard-error-
based confidence intervals are the same as those based on the MLE,
but in general I would suggest something along these lines:

> library(bbmle)
> z <- rnorm(20)
> m <- mle2(z~dnorm(mean=mu,sd=sd),start=list(mu=0,sd=1),data=data.frame(z))
Warning message:
In dnorm(x, mean, sd, log) : NaNs produced
> confint(m)
Profiling...
         2.5 %   97.5 %
mu -0.07880835 0.985382
sd  0.87314467 1.633600



More information about the R-help mailing list