I am trying to fit a number of distributions to a set of data, I have used the fitdristr() funtion for most of the distributions, but Poisson is not one of the possible distributions. I found somewhee talking about using the gamlss package, but have been unable to find it again, any help would be greatly appreciated. Mark Miller
On Thu, 25 Aug 2005, Mark Miller wrote:> I am trying to fit a number of distributions to a set of data, I have used the > fitdristr() funtion for most of the distributions, but Poisson is not one of > the possible distributions. I found somewhee talking about using the gamlss > package, but have been unable to find it again, any help would be greatly > appreciated.If you mean fitdistr in package MASS, it can be used. But the mle for a Poisson is just the sample mean.> x <- rpois(250, 2.6) > mean(x)[1] 2.62> fitdistr(x, dpois, list(lambda=2))lambda 2.6203125 (0.1023841) You can even find the s.e. via mu/sqrt(n), here> mean(x)/sqrt(250)[1] 0.1657033 -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Thu, 25 Aug 2005, Prof Brian Ripley wrote:> On Thu, 25 Aug 2005, Mark Miller wrote: > >> I am trying to fit a number of distributions to a set of data, I have used >> the >> fitdristr() funtion for most of the distributions, but Poisson is not one >> of >> the possible distributions. I found somewhee talking about using the gamlss >> package, but have been unable to find it again, any help would be greatly >> appreciated. > > If you mean fitdistr in package MASS, it can be used. But the mle for a > Poisson is just the sample mean. > >> x <- rpois(250, 2.6) >> mean(x) > [1] 2.62 >> fitdistr(x, dpois, list(lambda=2)) > lambda > 2.6203125 > (0.1023841) > > You can even find the s.e. via mu/sqrt(n), here >> mean(x)/sqrt(250) > [1] 0.1657033Sorry, sqrt(mu/n). -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
I was wandering if anyone cold advise me on a good algorithm to turn a set of data from its original for into its cumulative form. I have written a piece of code that takes the data and does essentially what a histogram function would do, except add to the new bin the sum in the previous bin. Once that is done I divide by the frequency in the last bin plus 1. I know the ecdf() function exists in R, but I want to use it to fit the cumulative distributions to the data and ecdf() produces a non-subscriptable vector and so fitdistr() cannot be used on it. Thanks for any help you can give Mark Miller
Will ?cumsum help? Sean On 8/26/05 5:15 AM, "Mark Miller" <mmiller at nassp.uct.ac.za> wrote:> I was wandering if anyone cold advise me on a good algorithm to turn a set of > data from its original for into its cumulative form. I have written a piece > of code that takes the data and does essentially what a histogram function > would do, except add to the new bin the sum in the previous bin. Once that > is done I divide by the frequency in the last bin plus 1. I know the ecdf() > function exists in R, but I want to use it to fit the cumulative > distributions to the data and ecdf() produces a non-subscriptable vector and > so fitdistr() cannot be used on it. > > Thanks for any help you can give > Mark Miller > > ______________________________________________ > 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 >