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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.