# likelihood analysis for mean of truncated Poisson data
y <- c(1:6)
n <- c(1486,694,195,37,10,1)
logL <- function(x, y, n.obs) # x is theta
{ f <- dpois(y,x)/(1-dpois(0,x)) # dpois is Poisson PDF
sum(n*log(f)) } # log likelihood
theta <- seq(from=0.8, to=1, length=200)
L <- rep(NA, 200)
for (i in 1:200) L[i] <- logL(theta[i], y, n)
plot(theta, L, type="l", ylab="Log likelihood")
lik.ci(theta, L)
Run the code above in your browser using DataLab