it is easy to fit a distribution using fitdistr poisdata <- rpois(n = 100, lambda = 2) poismle <- fitdistr(poisdata, "Poisson") poismle but i would like to know whether its possible to get an identical result using glm. I use poistab <- data.frame(table(poisdata)) colnames(poistab) <- c("width","freq"); poistab[,"width"] <- as.numeric(poistab[,"width"]) glm(freq ~ 1-width, family = poisson, data = poistab) but the results are always different. cheers, vumani
"Vumani Dlamini" <dvumani at hotmail.com> writes:> it is easy to fit a distribution using fitdistr > > poisdata <- rpois(n = 100, lambda = 2) > poismle <- fitdistr(poisdata, "Poisson") > poismle > > but i would like to know whether its possible to get an identical result > using glm. I use > > poistab <- data.frame(table(poisdata)) > colnames(poistab) <- c("width","freq"); > poistab[,"width"] <- as.numeric(poistab[,"width"]) > glm(freq ~ 1-width, family = poisson, data = poistab) > > but the results are always different.Well, the freq values in that setup are not independent Poisson variates. For a start, they sum to constant! Try instead exp(coef(glm(poisdata~1,family=poisson))) -- 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
On Wed, 8 Mar 2006, Vumani Dlamini wrote:> it is easy to fit a distribution using fitdistr > > poisdata <- rpois(n = 100, lambda = 2) > poismle <- fitdistr(poisdata, "Poisson") > poismle > > but i would like to know whether its possible to get an identical result > using glm.Yes. Easy. glm(poisdata ~ 1, family = poisson)> > poistab <- data.frame(table(poisdata)) > colnames(poistab) <- c("width","freq"); > poistab[,"width"] <- as.numeric(poistab[,"width"]) > glm(freq ~ 1-width, family = poisson, data = poistab) > > but the results are always different.Well, they would be. I don't know what this is doing, but it certainly isn't fitting a poisson distribution to poisdata. -thomas