[R] Coverage probability for a Poisson parameter
JS Huang
js.huang at protective.com
Sat Feb 14 01:21:26 CET 2015
Hi,
Some suggestion about the arguments of the function defined below. Since
theta is calculated with the value of lambda1 and lambda2, there is no need
to include theta in the argument. Or, your function can be defined as
function(lambda1, lambda2, significance.level)
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-tp4702535p4703248.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list