Press "Enter" to skip to content

GLM in R: Generalized Linear Model

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, July, and August using the Poisson regression you previously fit and the newDat 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.

Exercise

TRY IT YOURSELF: Access the exercise in our Generalized Linear Models in R course here.

  • Print newDat to see your new prediction situation.
  • Use the fit Poisson regression, poissonOut as the object and newDat as the new data in predict(). Be sure to exponentiate your output by setting type = "response". Save the results as predOut.
  • Print predOut.
# print the new input months
print(___) # use the model to predict with new data
___ <- predict(object = ___, newdata = ___, type = "response") # print the predictions
print(___)

Video

To learn more about generalized linear models in R, please see this video from our course Generalized Linear Models in R.

[embedded content]

This content is taken from DataCamp’s Generalized Linear Models in R course by Richard Erickson.

8 Comments

  1. Like!! I blog quite often and I genuinely thank you for your information. The article has truly peaked my interest.

  2. SMS July 1, 2020

    bookmarked!!, I like your blog!

  3. SMS July 1, 2020

    I used to be able to find good info from your blog posts.

Leave a Reply

Your email address will not be published.