[R] fitting a distribution using glm
tlumley at u.washington.edu
Wed Mar 8 16:02:46 CET 2006
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")
> but i would like to know whether its possible to get an identical result
> using glm.
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.
More information about the R-help