Session Ready
Exercise

A Poisson GLM

A Poisson generalized linear model is a way of fitting count data to explanatory variables. You get out parameter estimates and standard errors for your explanatory variables, and can get fitted values and residuals.

The glm() function fits Poisson GLMs. It works just like the lm() function, but you also specify a family argument. The formula has the usual meaning - response on the left of the ~, and explanatory variables on the right.

To cope with count data coming from populations of different sizes, you specify an offset argument. This adds a constant term for each row of the data in the model. The log of the population is used in the offset term.

Instructions
100 XP

The london health data set has been loaded with the sp package also ready.

  • Run a Poisson generalized linear model of how the count of flu cases, Flu_OBS, depends on the Health Deprivation index value, HealthDeprivation.

    • The first argument is the formula (response vairable on the left).
    • The family argument is a function, poisson.
  • Look at the summary table of coefficients and decide if HealthDeprivation is significant. You should see stars.

  • Calculate the residuals of the GLM model by passing the model object to residuals().

    • Assign this to the Flu_Resid column of london.
  • Use spplot() to draw a map of the residuals.