My question is related, but not the same as the following question: Fitting a Poisson GLM in R - issues with rates vs. counts
Here's some fake data:
### some fake data
x=c(1:14)
y=c(0, 1, 2, 3, 1, 4, 9, 18, 23, 31, 20, 25, 37, 45)
y_rate <- y / 1000
I'm going to use a Poisson GLM with a log link to predict y_rate
:
### model
pois_mdl <- glm(y_rate ~ x, family=poisson(link="log"))
summary(pois_mdl)
Plot the fit:
### plot
plot(x, y_rate)
lines(x, pois_mdl$fitted.values)
I am surprised that Poisson glm()
allows for non-integer values in the dependent variable. Draws from a Poisson distribution are always integers (regardless of the value of the mean parameter). Why doesn't glm()
blow up?