LoslegenKostenlos loslegen

Compare two models

From previous exercise you have fitted a model with distance100 and arsenic as explanatory variables. In this exercise you will analyze the impact on the model fit for each of the added variables.

Recall that the models you fitted are as follows and have been preloaded in the workspace:

  1. model_dist = 'switch ~ distance100'

  2. model_dist_ars = 'switch ~ distance100 + arsenic

The dataset wells has also been preloaded in the workspace.

Diese Übung ist Teil des Kurses

Generalized Linear Models in Python

Kurs anzeigen

Anleitung zur Übung

  • Compute the difference in deviance when distance100 is added to the null model.
  • Compute the difference in deviance when arsenic is added to the model with distance100 variable.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Compute the difference in adding distance100 variable
diff_deviance_distance = ____.____ - ____.____

# Print the computed difference in deviance
print('Adding distance100 to the null model reduces deviance by: ', 
      round(____,3))

# Compute the difference in adding arsenic variable
diff_deviance_arsenic = ____.____ - ____.____

# Print the computed difference in deviance
print('Adding arsenic to the distance model reduced deviance further by: ', 
      round(____,3))
Code bearbeiten und ausführen