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.
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.