Plotting Poisson regression

Generalized Linear Models in R

Richard Erickson

Instructor

When to use geom_smooth with Poisson

  • Works best with continuous predictor variables
  • e.g., increasing dose and number of cells with cancer per cm$^2$
  • Otherwise, use boxplot or similar plotting tool
Generalized Linear Models in R

Cancer cells dose study

  • Simulate data
  • Dose-response
    • x: Dose
    • y: Number of cancer cells per cm$^2$
Generalized Linear Models in R

Plot points

ggplot(data = dat, aes(x = dose, y = cells)) +
    geom_point()

ggplot with points

Generalized Linear Models in R

Jitter points

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05)

Example of jittered points with ggplot2.

Generalized Linear Models in R

geom_smooth()

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05)
   geom_smooth()

Example of default geom_smooth() on top of jittered points

Generalized Linear Models in R

GLMs with geom_smooth()

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05)
   geom_smooth(method = 'glm')

Example of GLM with with geom_smooth() and default GLM, a LM

Generalized Linear Models in R

Poisson GLM with geom_smooth()

ggplot(data = dat, aes(x = dose, y = cells)) +
   geom_jitter(width = 0.05, height = 0.05) +
   geom_smooth(method = 'glm', method.args = list(family = 'poisson'))

Example of a Poisson regression plot

Generalized Linear Models in R

Summary of steps

  • Plot non-overlapping points
  • Add in Poisson trend line
  • Polish figure (not-done here)
Generalized Linear Models in R

Let's practice!

Generalized Linear Models in R

Preparing Video For Download...