Let's assume I am working with this dataset on R:
I cannot understand how Poisson regression works in R, I would assume that the following are equivalent:
But they are not. Why? Did I misunderstood what Poisson regression is in the first place?
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)
Code:
mod <- glm(y ~ x1 + x2, data=mydata, family=poisson())
Code:
mod <- lm(log(y) ~ x1 + x2, data=mydata)