Session Ready
Exercise

Compute VIF

As you learned in the video one of the most widely used diagnostic for multicollinearity is the variance inflation factor or VIF, which is computed for each explanatory variable.

Recall from the video that the rule of thumb threshold is VIF at the level of 2.5, meaning if the VIF is above 2.5 you should consider there is effect of multicollinearity on your fitted model.

The previously fitted model and crab dataset are preloaded in the workspace.

Instructions
100 XP
  • From statsmodels import variance_inflation_factor.
  • From crab dataset choose weight, width and color and save as X. Add Intercept column of ones to X.
  • Using pandas function DataFrame() create an empty vif dataframe and add column names of X in column Variables.
  • For each variable compute VIF using the variance_inflation_factor()function and save in vif dataframe with VIF column name.