CommencerCommencer gratuitement

Predicting with glm()

Data scientists often use models to predict future situations. GLMs are one such tool and, when used for these situations, they are sometimes called supervised learning.

For this exercise, you will predict the expected number of daily civilian fire injury victims for the North American summer months of June (6), July (7), and August (8) using the Poisson regression you previously fit and the new_dat dataset.

Recall that the Poisson slope and intercept estimates are on the natural log scale and can be exponentiated to be more easily understood. You can do this by specifying type = "response" with the predict function.

Cet exercice fait partie du cours

Generalized Linear Models in R

Afficher le cours

Instructions

  • Print new_dat to see your new prediction situation.
  • Use the fit Poisson regression, poisson_out as the object and new_dat as the new data in predict(). Be sure to exponentiate your output by setting type = "response". Save the results as pred_out.
  • Print pred_out.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# print the new input months
print(___)

# use the model to predict with new data 
___ <- predict(object = ___, newdata = ___, type = "response")

# print the predictions
print(___)
Modifier et exécuter le code