Gregor Gorjanc
2006-Feb-10 12:35 UTC
[R] Fitdistr and MLE for parameter lambda of Poisson distribution
Hello! I would like to get MLE for parameter lambda of Poisson distribution. I can use fitdistr() for this. After looking a bit into the code of this function I can see that value for lambda and its standard error is estimated via estimate <- mean(x) sds <- sqrt(estimate/n) Is this MLE? With my poor math/stat knowledge I thought that MLE for Poisson parameter is (in mixture of LaTeX code) l(\lambda|x) \propto \sum^n_{i=1}(-\lambda + x_iln(\lambda)). Is this really equal to (\sum^n_{i=1} x_i) / n -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
Peter Dalgaard
2006-Feb-10 13:39 UTC
[R] Fitdistr and MLE for parameter lambda of Poisson distribution
Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si> writes:> Hello! > > I would like to get MLE for parameter lambda of Poisson distribution. I > can use fitdistr() for this. After looking a bit into the code of this > function I can see that value for lambda and its standard error is > estimated via > > estimate <- mean(x) > sds <- sqrt(estimate/n) > > Is this MLE? With my poor math/stat knowledge I thought that MLE for > Poisson parameter is (in mixture of LaTeX code) > > l(\lambda|x) \propto \sum^n_{i=1}(-\lambda + x_iln(\lambda)). > > Is this really equal to (\sum^n_{i=1} x_i) / nYes.... Maximizing l(lambda) is the same as maximizing sum(x)/n ln lambda - lambda Now either take the derivative and set equal to zero, or rewrite further as equivalent to ln (lambda/(sum(x)/n)) - (lambda/(sum(x)/n)) and notice that ln(x) - x has a global maximum at x=1 (since ln is strictly concave and the tangent at x=1 is the line y = x - 1) (I think this is in the first 20 pages I ever read on theoretical statistics ...)> -- > Lep pozdrav / With regards, > Gregor Gorjanc > > ---------------------------------------------------------------------- > University of Ljubljana PhD student > Biotechnical Faculty > Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan > Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si > > SI-1230 Domzale tel: +386 (0)1 72 17 861 > Slovenia, Europe fax: +386 (0)1 72 17 888 > > ---------------------------------------------------------------------- > "One must learn by doing the thing; for though you think you know it, > you have no certainty until you try." Sophocles ~ 450 B.C. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Gregor Gorjanc
2006-Feb-10 16:25 UTC
[R] Fitdistr and MLE for parameter lambda of Poisson distribution
Peter Dalgaard wrote:> Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si> writes: > > >>Hello! >> >>I would like to get MLE for parameter lambda of Poisson distribution. I >>can use fitdistr() for this. After looking a bit into the code of this >>function I can see that value for lambda and its standard error is >>estimated via >> >>estimate <- mean(x) >>sds <- sqrt(estimate/n) >> >>Is this MLE? With my poor math/stat knowledge I thought that MLE for >>Poisson parameter is (in mixture of LaTeX code) >> >>l(\lambda|x) \propto \sum^n_{i=1}(-\lambda + x_iln(\lambda)). >> >>Is this really equal to (\sum^n_{i=1} x_i) / n > > > Yes.... > > Maximizing l(lambda) is the same as maximizing > > sum(x)/n ln lambda - lambda > > Now either take the derivative and set equal to zero, or > > rewrite further as equivalent to > > ln (lambda/(sum(x)/n)) - (lambda/(sum(x)/n)) > > and notice that ln(x) - x has a global maximum at x=1 (since ln is > strictly concave and the tangent at x=1 is the line y = x - 1) > > > (I think this is in the first 20 pages I ever read on theoretical > statistics ...)Thank you very much for this. It shows, how much I still need to learn. -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
Gregor Gorjanc
2006-Feb-14 08:57 UTC
[R] Fitdistr and MLE for parameter lambda of Poisson distribution
Bernardo Rangel tura wrote:> At 09:35 AM 2/10/2006, Gregor Gorjanc wrote: > >> Hello! >> >> I would like to get MLE for parameter lambda of Poisson distribution. I >> can use fitdistr() for this. After looking a bit into the code of this >> function I can see that value for lambda and its standard error is >> estimated via >> >> estimate <- mean(x) >> sds <- sqrt(estimate/n) >> >> Is this MLE? With my poor math/stat knowledge I thought that MLE for >> Poisson parameter is (in mixture of LaTeX code) >> >> l(\lambda|x) \propto \sum^n_{i=1}(-\lambda + x_iln(\lambda)). >> >> Is this really equal to (\sum^n_{i=1} x_i) / n >> >> -- >> Lep pozdrav / With regards, >> Gregor Gorjanc > > > Gregor, > > If I understood your LaTeX You is rigth. > > If you don??t know have a command wich make this for you: fitdistr() > > Look: > > >> d<- rpois(50,5) >> d > [1] 6 4 6 4 5 5 4 11 7 5 7 3 5 10 4 9 4 2 4 5 4 4 > 9 3 10 > [26] 4 3 9 6 7 5 4 2 7 3 6 7 8 6 6 3 3 3 2 5 4 3 > 8 5 7 >> library(MASS) >> fitdistr(d,"Poisson") > lambda > 5.3200000 > (0.3261901)Thanks for this, but I have already said in the first mail, that fitdistr can help me with this. I was just "surprised" or knowledge undernourished, that there is closed form solution for this. Look into the source of fitdistr. -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
Bernardo Rangel tura
2006-Feb-14 09:30 UTC
[R] Fitdistr and MLE for parameter lambda of Poisson distribution
At 09:35 AM 2/10/2006, Gregor Gorjanc wrote:>Hello! > >I would like to get MLE for parameter lambda of Poisson distribution. I >can use fitdistr() for this. After looking a bit into the code of this >function I can see that value for lambda and its standard error is >estimated via > >estimate <- mean(x) >sds <- sqrt(estimate/n) > >Is this MLE? With my poor math/stat knowledge I thought that MLE for >Poisson parameter is (in mixture of LaTeX code) > >l(\lambda|x) \propto \sum^n_{i=1}(-\lambda + x_iln(\lambda)). > >Is this really equal to (\sum^n_{i=1} x_i) / n > >-- >Lep pozdrav / With regards, > Gregor GorjancGregor, If I understood your LaTeX You is rigth. If you don??t know have a command wich make this for you: fitdistr() Look: > d<- rpois(50,5) > d [1] 6 4 6 4 5 5 4 11 7 5 7 3 5 10 4 9 4 2 4 5 4 4 9 3 10 [26] 4 3 9 6 7 5 4 2 7 3 6 7 8 6 6 3 3 3 2 5 4 3 8 5 7 > library(MASS) > fitdistr(d,"Poisson") lambda 5.3200000 (0.3261901) []s Tura
ankush2kn at yahoo.com
2009-Oct-27 03:25 UTC
[R] MLE for lambda of Poisson distribution using fitdistr
Hi, I am using the fitdistr of MASS to get the MLE for the lambda of a Poisson distribution. When i run the fitdistr command, i get an output that looks like - lambda 3.750000 (0.03343) Couple of questions - 1. is the MLE 0.03343 for the lambda of the given distribution then? 2. How would I calculate the variance of the MLE for the lambda? Thanks much! Ankush -- This message was sent on behalf of ankush2kn at yahoo.com at openSubscriber.com http://www.opensubscriber.com/message/r-help at stat.math.ethz.ch/3316818.html
David Winsemius
2009-Oct-27 12:17 UTC
[R] MLE for lambda of Poisson distribution using fitdistr
On Oct 26, 2009, at 11:25 PM, ankush2kn at yahoo.com wrote:> Hi, > > I am using the fitdistr of MASS to get the MLE for the lambda of a > Poisson distribution. > When i run the fitdistr command, i get an output that looks like - > > lambda > 3.750000 > (0.03343) > > Couple of questions - > 1. is the MLE 0.03343 for the lambda of the given distribution then? > 2. How would I calculate the variance of the MLE for the lambda?It would be more typical statistical usage to have output of the form: estimate ( se(estimate) ) .... so I was expecting 3.75 to be the estimate. Looking at the help page and running str(.) on the fitdistr object of the first example confirms my expectations. Why did you think the help page was suggesting otherwise? -- David Winsemius, MD Heritage Laboratories West Hartford, CT
Kjetil Halvorsen
2009-Oct-27 12:23 UTC
[R] MLE for lambda of Poisson distribution using fitdistr
What is wrong with using mean(x) to get the MLE of the poisson lambda? Kjetil On Tue, Oct 27, 2009 at 9:17 AM, David Winsemius <dwinsemius at comcast.net> wrote:> > On Oct 26, 2009, at 11:25 PM, ankush2kn at yahoo.com wrote: > >> Hi, >> >> I am using the fitdistr of MASS to get the MLE for the lambda of a Poisson >> distribution. >> When i run the fitdistr command, i get an output that looks like - >> >> ? ?lambda >> ? ?3.750000 >> ? ?(0.03343) >> >> Couple of questions - >> 1. is the MLE 0.03343 for the lambda of the given distribution then? >> 2. How would I calculate the variance of the MLE for the lambda? > > It would be more typical statistical usage to have output of the form: > ?estimate ( se(estimate) ) .... so I was expecting 3.75 to be the estimate. > Looking at the help page and running str(.) on the fitdistr object of the > first example confirms my expectations. Why did you think the help page was > suggesting otherwise? > > -- > > David Winsemius, MD > Heritage Laboratories > West Hartford, CT > > ______________________________________________ > R-help at r-project.org 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 Ehlers
2009-Oct-27 14:15 UTC
[R] MLE for lambda of Poisson distribution using fitdistr
Kjetil Halvorsen wrote:> What is wrong with using > mean(x) > to get the MLE of the poisson lambda? >and mean(x)/length(x) to get its estimated variance. -Peter Ehlers> Kjetil > > On Tue, Oct 27, 2009 at 9:17 AM, David Winsemius <dwinsemius at comcast.net> wrote: >> On Oct 26, 2009, at 11:25 PM, ankush2kn at yahoo.com wrote: >> >>> Hi, >>> >>> I am using the fitdistr of MASS to get the MLE for the lambda of a Poisson >>> distribution. >>> When i run the fitdistr command, i get an output that looks like - >>> >>> lambda >>> 3.750000 >>> (0.03343) >>> >>> Couple of questions - >>> 1. is the MLE 0.03343 for the lambda of the given distribution then? >>> 2. How would I calculate the variance of the MLE for the lambda? >> It would be more typical statistical usage to have output of the form: >> estimate ( se(estimate) ) .... so I was expecting 3.75 to be the estimate. >> Looking at the help page and running str(.) on the fitdistr object of the >> first example confirms my expectations. Why did you think the help page was >> suggesting otherwise? >> >> -- >> >> David Winsemius, MD >> Heritage Laboratories >> West Hartford, CT >> >> ______________________________________________ >> R-help at r-project.org 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. >> > > ______________________________________________ > R-help at r-project.org 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.