Session Ready
Exercise

Renaming GLM

R's generalized linear regression function, glm(), suffers the same usability problems as lm(): its name is an acronym, and its formula and data arguments are in the wrong order.

To solve this exercise, you need to know two things about generalized linear regression:

  1. glm() formulas are specified like lm() formulas: response is on the left, and explanatory variables are added on the right.
  2. To model count data, set glm()'s family argument to poisson, making it a Poisson regression.

Here you'll use data on the number of yearly visits to Snake River at Jackson Hole, Wyoming, snake_river_visits.

Instructions 1/3
undefined XP
  • 1
  • 2
  • 3
  • Run a generalized linear regression by calling glm(). Model n_visits vs. gender, income, and travel on the snake_river_visits dataset, setting the family to poisson.