[R] Coverage probability for a Poisson parameter
JS Huang
js.huang at protective.com
Fri Feb 13 22:15:32 CET 2015
Hi,
In your function cover, lambda1 and lambda2 are used but not in the
argument of the function. I suppose that you need to have lambda1 and
lambda2 in the argument of the function cover, like function(lambda1,
lambda2, n, significance.level).
Give it a try.
cover <- function(lambda, n, significance.level) {
s1 <- rpois(1,lambda1)
s2 <- rpois(1,lambda2)
theta <- lambda2/(lambda1+lambda2)
s <- s1+s2
z <- qnorm(1-0.05/2)
k <- z^2
pi <- s2/s
lower <- (pi+(k/(2*s))-z*sqrt((pi*(1-pi)+(k/4*s))/s))/(1+k/s)
upper <- (pi+(k/(2*s))+z*sqrt((pi*(1-pi)+(k/4*s))/s))/(1+k/s)
if (theta >= lower & theta <= upper){1} else {0}
}
--
View this message in context: http://r.789695.n4.nabble.com/Coverage-probability-for-a-Poisson-parameter-tp4702535p4703230.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list