15.3 Poisson regression with a continuous predictor

Simulate \(y\) data for Poisson regression with one continuous predictor \(x_1\), \[y \sim Poisson(\lambda), \\ \lambda = e^{\beta_0 + \beta_1x},\]

and then plot.

Code
dg$y = rpois(n = n, lambda = exp(0+ 2*x1))

g = ggplot(dg, 
           aes(x1, y)) + 
  geom_jitter(width  = 0, 
              height = 0.2, 
              alpha  = 0.3)

g %>% 
  pub(xlim = c(0,1))

[1] 37.35768
[1] 80
[1] 20
[1] 137.3577