1. Learn
  2. /
  3. Courses
  4. /
  5. Helsinki Open Data Science

Connected

Exercise

Making predictions

Okey, so let's assume that we have a linear model which seems to fit our standards. What can we do with it?

The model quantifies the relationship between the explanatory variable(s) and the dependent variable. The model can also be used for predicting the dependent variable based on new observations of the explanatory variable(s).

In R, predicting can be done using the predict() function. (see ?predict). The first argument of predict is a model object and the argument newdata (a data.frame) can be used to make predictions based on new observations. One or more columns of newdata should have the same name as the explanatory variables in the model object.

Instructions

100 XP
  • Create object m and print out a summary of the model
  • Create object new_attitudes
  • Adjust the code: Create a new data frame with a column named 'attitude' holding the new attitudes defined in new_attitudes
  • Print out the new data frame
  • predict() the new student's exam points based on their attitudes, using the newdata argument