# Poisson confidence interval in poisson.test similar

Here is my data. I observed 3 intervals (for example each 1 month long). In each interval my random variable assumed the following values 10, 15, 12.

I would like to estimate confidence interval for mean of Poisson random variable. R has function poisson.test takes only vector of length one or two. How do I need to reshape my data to use this test? Or is there another function in R?

A few options:

Fit a Poisson Generalized Linear Model with the Poisson family and only an intercept (this will estimate the mean, but on the log scale):

tmp <- data.frame(y = c(10, 15, 12))
fit <- glm(y ~ 1, data=tmp, family=poisson())
fit
summary(fit)
confint(fit)
exp(confint(fit))


Or use the fact that Poisson values are summable, so pass the sum of your data points to poisson.test with the Time variable set to the number of observations (number of months):

poisson.test(sum(tmp$y), T=nrow(tmp))  Or use maximum likelihood estimation, the mle function in the stats4 package is one option: library(stats4) nll <- function(lambda) -sum(stats::dpois(tmp$y, lambda, log=TRUE))
fit2 <- mle(nll, start=list(lambda=5), nobs=nrow(tmp))
(tmp2 <- summary(fit2))
tmp2@coef + c(-2, 2)* tmp2@coef # Wald
confint(fit2) # profiling (likelihood ratio)


There are probably other options as well, but this should get you started. The methods above all give different but similar intervals, so you should understand what the assumptions and advantages/disadvantages of each are in choosing.

• Thank you very much! I like summable part - it looks the most pure to me. I still cannot understand MLE for discrete random variables. – user1700890 Dec 23 '19 at 17:14
• @user1700890, remember that while the variable may be discrete the parameter is still considered continuous, that may help with the understanding. Try a value of the parameter (a "Guess") and the fixed data and compute the likelihood (or the log likelihood), try a new guess and see if that has higher likelihood, put the likelihood function into an optimization procedure and find the maximum (or a close estimate). – Greg Snow Dec 26 '19 at 17:05
• @user1700890, Maximum likelihood can be used to estimate parameters in Poisson regression, but the glm function in R actually uses Iterated Weighted Least Squares (which approximates the maximum likelihood, but can give slightly different answers in some cases). – Greg Snow Dec 26 '19 at 17:07
• @COOLSerdash, oops, somehow in my copy/paste a line was left out, I have added it in above. Basically tmp2 is the summary information from fit2 which contains the estimated mean and standard deviation from the fit. Thanks for catching my mistake. – Greg Snow Dec 26 '19 at 17:08
• @user1700890, it has been a long time since I took the class on the IRWLS algorithm, so don't take this as official. The Poisson pmf influences the weights, but the weights are refit each iteration. – Greg Snow Dec 26 '19 at 23:25