[R] fitting a distribution using glm

Vumani Dlamini dvumani at hotmail.com
Wed Mar 8 15:08:21 CET 2006


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




More information about the R-help mailing list