Poisson regression

Generalized Linear Models in R

Richard Erickson

Instructor

Football/soccer example

Generalized Linear Models in R

Example plot of Poisson distributions with lambda of 2 and 10 and normal distributions with the same parameters.

Generalized Linear Models in R

Poisson distribution

  • Discrete integers: x = 0, 1, 2, 3, ...

  • Mean and variance parameter $\lambda$

  • $P(x) = \frac{\lambda^x e^{-\lambda}}{x!}$

  • Fixed area/time (e.g., goal per one game)

Generalized Linear Models in R

Poisson distribution in R

    dpois(x = ..., lambda = ...)
Generalized Linear Models in R

GLM with R requirements

  • Discrete counts: 0, 1, 2, 3...
  • Defined area and time
  • Log-scale coefficients
Generalized Linear Models in R

GLM with Poisson in R

glm(y ~ x, data = dat, family = 'poisson')
Generalized Linear Models in R

When not to use Poisson distribution

  • Non-count or non-positive data (e.g., 1.4 or -2)
  • Non-constant sample area or time (e.g., trees km$^{-1}$ vs. trees m$^{-1}$)
  • Mean $\gtrsim$30
  • Over-dispersed data
  • Zero-inflated data
Generalized Linear Models in R

Formula intercepts

  • Comparison or intercept
  • Comparison formula = y ~ x
  • Intercept formula = y ~ x - 1
Generalized Linear Models in R

Goals per game

  • Two players, which approach do we use?
  • If we want to know difference between players, use comparison:

     glm(goal ~ player, data = scores, family = "poisson")
    
  • If we want to know average per player, use intercepts:

     glm(goal ~ player - 1, data = scores, family = "poisson")
    
Generalized Linear Models in R

Let's practice!

Generalized Linear Models in R

Preparing Video For Download...