[R] Coverage probability for a Poisson parameter
JS Huang
js.huang at protective.com
Fri Feb 13 22:59:57 CET 2015
Hi,
Given the function cover, it's very likely that you will get 0 for both s1
and s1 with small value of lambda1 and lambda2. In that case the sum s will
be 0. With s being 0, you will have issue with the expression in pi <-
s2/s and root <- ((s2/s)*(1-s2/s)+k/(4*s))^(1/2). You need to take care of
the case that s is 0 before proceeding calculating pi and root.
cover <- function(theta, lambda1, lambda2, 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
root <- ((s2/s)*(1-s2/s)+k/(4*s))^(1/2)
low <- (s2+k/2)/(s+k)-((z*sqrt(s))/(s+k))*root
hig <- (s2+k/2)/(s+k)+((z*sqrt(s))/(s+k))*root
if (theta >= low & theta <= hig){1} else {0}
}
--
View this message in context: http://r.789695.n4.nabble.com/Coverage-probability-for-a-Poisson-parameter-tp4702535p4703238.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list