Maximum Likelihood Estimation Poisson distribution mle {stats4}

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Maximum Likelihood Estimation Poisson distribution mle {stats4}

chamilka
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

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
[1] 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)

Why this contradiction?
Reply | Threaded
Open this post in threaded view
|

Re: Maximum Likelihood Estimation Poisson distribution mle {stats4}

S Ellison-2
> -----Original Message-----
> > sample.mean<- sum(x*y)/sum(y)
> > sample.mean
> [1] 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)
>
> Why this contradiction?
>
>

Ermm.. the sample mean is mean(y) which is 11.545

I deduce that you and the help page have different views on what the sample y represents.

i also note that x does not figure at all in the help page's log-likelihood, suggesting that y is a simple set of counts, whereas you have interpreted x as the number of instances of each y. That appears not to be the case.

S


 

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Maximum Likelihood Estimation Poisson distribution mle {stats4}

Peter Dalgaard-2
In reply to this post by chamilka

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
> [1] 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)
>
> Why this contradiction?

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

> mean(y)
[1] 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.
>
> ______________________________________________
> [hidden email] mailing list
> 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.

--
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Maximum Likelihood Estimation Poisson distribution mle {stats4}

chamilka
In reply to this post by S Ellison-2
Thank you S Ellison-2 for your reply. I will understand it with Prof.Peter Dalgaard's answer..
Reply | Threaded
Open this post in threaded view
|

Re: Maximum Likelihood Estimation Poisson distribution mle {stats4}

chamilka
In reply to this post by Peter Dalgaard-2
Thank you very much Professor .Peter Dalgaard for your kind explanations.. This made my work easy.. I am struggling with this for more than 2 days and now I got the correct reply.
Thank again.