Session Ready
Exercise

Crime and poverty

The data frame Crime gives some FBI statistics on crime in the various US states in 1960.

  • The variable R gives the crime rate in each state.
  • The variable X gives the number of families with low income (i.e. less than half the median).
  • The variable W gives the average assets of families in the state.

You're going to build separate models R ~ X and R ~ W to estimate what the effect on the crime rate is of each of those variables. Then you'll construct R ~ X + W, using each of the explanatory variables as a covariate for the other.

Instructions
100 XP
  • Using a linear architecture and the Crime data, train model_1 and model_2 with formulas R ~ X and R ~ W, respectively.
  • Find the output of each model using evaluate_model().
  • Copy and paste values from the evaluate_model() output to calculate for each model the change in crime rate from the first level of the explanatory variable to the second level (i.e. X = 100 to X = 200 and W = 400 to W = 600).
  • Using lm(), train model_3 with the formula R ~ X + W. In effect, X serves as a covariate for W and vice versa.
  • Evaluate model_3.
  • Again, copy and paste values from the evaluate_model() output to calculate the change in crime rate associated with a decrease of 100 (from 200 to 100) in X, holding W constant at 600. Call this change_with_X_holding_W_constant. Likewise, calculate the change in crime rate associated with a decrease of 200 (from 600 to 400) in W, holding X constant at 200. Call this change_with_W_holding_X_constant. Note that you get very different results with and without covariates.