# [R] Maximum Likelihood Estimation Poisson distribution mle {stats4}

peter dalgaard pdalgd at gmail.com
Thu Jul 5 14:41:18 CEST 2012

```On Jul 5, 2012, at 10:48 , chamilka wrote:

> Hi everyone!
> I am using the mle {stats4} to estimate the parameters of distributions by
> MLE method. I have a problem with the examples they provided with the
> mle{stats4} html files. Please check the example and my question below!
> *Here is the mle html help file *
> http://stat.ethz.ch/R-manual/R-devel/library/stats4/html/mle.html
> http://stat.ethz.ch/R-manual/R-devel/library/stats4/html/mle.html
>
> *In the example provided with the help *
>> od <- options(digits = 5)
>> x <- 0:10    *#generating Poisson counts*
>> y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)  *#generating the
>> frequesncies*
>>
> ## Easy one-dimensional MLE:
>> nLL <- function(lambda) -sum(stats::dpois(y, lambda, log=TRUE))  *#they
>> define the Poisson negative loglikelihood*
>> fit0 <- mle(nLL, start = list(lambda = 5), nobs = NROW(y)) * #they
>> estimate the Poisson parameter using mle*
>> fit0  *#they call the output*
>
> Call:
> mle(minuslogl = nLL, start = list(lambda = 5), nobs = NROW(y))
>
> Coefficients:
> lambda
> 11.545       * #this is their estimated Lambda Vallue.*
>
> *Now my question is in a Poisson distribution the Maximum Likelihood
> estimator of the mean parameter lambda is  the sample mean, so if we
> calculate the sample mean of that generated Poisson distribution manually
> using R we get  the below!*
>
>> sample.mean<- sum(x*y)/sum(y)
>> sample.mean
>  3.5433
>
> *This is the contradiction!! *
> Here I am getting the estimate as 3.5433(which is reasonable as most of the
> values are clustered around 3), but mle code gives the estimate 11.545(which
> may not be correct as this is out side the range 0:10)
>

You misunderstand the setup. y are 11 Poisson counts, x is a dose variable used further down in the example. So

> mean(y)
 11.54545

Your sample.mean would be relevant if there were 127 count measurements, 26 of which were 0, 17 were 1, etc. But then the likelihood would be different:

> x <- 0:10
> nLL <- function(lambda) -sum(y*stats::dpois(x, lambda, log=TRUE))
> mle(nLL, start = list(lambda = 5), nobs = NROW(y))

Call:
mle(minuslogl = nLL, start = list(lambda = 5), nobs = NROW(y))

Coefficients:
lambda
3.54328

>
> --
> View this message in context: http://r.789695.n4.nabble.com/Maximum-Likelihood-Estimation-Poisson-distribution-mle-stats4-tp4635464.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help