How family=Poisson works in glm function in R?

KNR

New Member
#1
Let's assume I am working with this dataset on R:
Code:
n <- 40
x1 <- rnorm(n, mean=3, sd=1)
x2 <- rnorm(n, mean=4, sd=1.25)
y <- 2*x1 + 3*x2 + rnorm(n, mean=2, sd=1)
mydata <- data.frame(x1, x2, y)
I cannot understand how Poisson regression works in R, I would assume that the following are equivalent:
Code:
mod <- glm(y ~ x1 + x2, data=mydata, family=poisson())
Code:
mod <- lm(log(y) ~ x1 + x2, data=mydata)
But they are not. Why? Did I misunderstood what Poisson regression is in the first place?
 

Buckeye

Active Member
#2
Poisson regression is often used to model count data (taking values: 0, 1, 2, 3). Poisson regression also models rates (you can supply an offset to the model for this purpose). For example, the number of patients arriving at a hospital within a given day. Your dependent variable is not a count variable. At best, the first code is modeling y as a rate. But, I'm not too sure. The second piece of code is just a linear, OLS model with a logged dependent variable. It has no relation to a Poisson regression model.
 
Last edited: