Hi folks!
I run the following code to get a CI for a Poisson with lambda=12.73

library(MASS)

set.seed(125)

x <- rpois(100,12.73)

lambda_hat<-fitdistr(x, dpois, list(lambda=12))$estimate

#Confidence Intervals - Normal Approx.

alpha<-c(.05,.025,.01)

for(n in 1:length(alpha)) {

LowerCI<-mean(x)-(qnorm(1-alpha[n]/2, mean = 0, sd =
1)*sqrt(var(x)/length(x)))

UpperCI<-mean(x)+(qnorm(1-alpha[n]/2, mean = 0, sd =
1)*sqrt(var(x)/length(x)))

cat("For
Alpha=",alpha[n],"LowerCI=",LowerCI,"<","Lambda=",mean(x),"<","UpperCI=",UpperCI,"\n")


 }


When I do something like:

 qpois(.975, 12.73, lower.tail = TRUE, log.p = FALSE)
[1] 20
> qpois(.025, 12.73, lower.tail = TRUE, log.p = FALSE)
[1] 6

I get quite a different result.  Is this the difference between the normal
approx and an (almost) exact Poisson CI?  Thx!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to