Exercise

Deviance and linear transformation

As you have seen in previous exercises the deviance decreased as you added a variable that improves the model fit. In this exercise you will consider the well switch data example and the model you fitted with distance variable, but you will assess what happens when there is a linear transformation of the variable.

Note that the variable distance100 is the original variable distance divided by 100 to make for more meaningful representation and interpretation of the results. You can inspect the data with wells.head() to view the first 5 rows of data.

The wells dataset and the model 'swicth ~ distance100' has been preloaded as model_dist.

Instructions

100 XP
  • Import statsmodels as sm and the glm() function.
  • Fit a logistic regression model with distance as the explanatory variable and switch as the response and save as model_dist_1.
  • Check and print the difference in deviance of the current model and the model with distance100 as the explanatory variable.