Session Ready
Exercise

Coefficients in terms of odds

Previously you have fitted a logistic regression model for the probability of switching the well given the arsenic levels. In this exercise, you will see how another variable distance100 relates to the probability of switching and interpreting the coefficient values in terms of odds.

Recall that the logistic regression model is in terms of log odds, so to obtain by how much would the odds multiply given a unit increase in x you would exponentiate the coefficient estimates. This is also called odds ratio.

Recall that odds are a ratio of event occurring to the event not occurring. For example, if the odds of winning a game are 1/2 or 1 to 2 (1:2), it means that for every one win there are 2 losses.

The dataset wells is loaded in the workspace.

Instructions
100 XP
  • Import statsmodels library and glm function from statsmodels.formula.api. Also import numpyas np.
  • Using glm() fit a logistic regression model where switch is predicted by distance100.
  • Extract model coefficients using .params.
  • Compute the multiplicative effect on the odds using numpy exp() function.