Session Ready
Exercise

Building a stepwise regression model

In the absence of subject-matter expertise, stepwise regression can assist with the search for the most important predictors of the outcome of interest.

In this exercise, you will use a forward stepwise approach to add predictors to the model one-by-one until no additional benefit is seen. The donors dataset has been loaded for you.

Instructions
100 XP
  • Use the R formula interface with glm() to specify the base model with no predictors. Set the explanatory variable equal to 1.
  • Use the R formula interface again with glm() to specify the model with all predictors.
  • Apply step() to these models to perform forward stepwise regression. Set the first argument to null_model and set direction = "forward". This might take a while (up to 10 or 15 seconds) as your computer has to fit quite a few different models to perform stepwise selection.
  • Create a vector of predicted probabilities using the predict() function.
  • Plot the ROC curve with roc() and plot() and compute the AUC of the stepwise model with auc().