# Why are Poisson regression coefficients biased?

Suppose I run a simple Poisson regression, where

$$Y \sim \text{Pois} (5X)$$

If I run a Poisson regression of $$Y$$ on $$X$$, I am expecting to get back $$5$$. Instead I get numbers much higher. Why is that?

result <- c()

for(i in 1:1000) {
x <- runif(100)
y <- rpois(100, 5 *x)
m <- glm(y ~ x, family = 'poisson')

result <- c(result, exp(coef(m)))
}


The default link function is the log function for Poisson, this means:

$$\mathbb{E}[y]=\exp\left(\log(5)+\log(x)\right)$$

If you specify your glm model as y ~ log(x) then you should recover "1" as the coefficient and "log(5)" as the intercept

That isn't how poisson regression works. The link function for poisson regression is the log, so if you did something like

x<-runif(100)
eta<- 5*x
lam<- exp(eta)
y<-rpois(length(lam), lam)
model<- glm(y~x, family = 'poisson')


Then you would recover the proper estimates for the coefficient of x and the intercept.

You could however recover the correct coefficients from your code if you were to use the identity link function. For instance

x <- runif(100)
y <- rpois(100, 5 *x)
m <- glm(y ~ x, family = poisson(link = 'identity'), start = c(2,2))


Note that R will warn you in this case that the optimization algorithm is having a tough time because the mean is not constrained to be positive, leading to problems in the evaluation of the log likelihood. The log link ensures that the linear predictor (which is unconstrained) does not result in such problems.