BaşlayınÜcretsiz Başlayın

Checking model fit

In the video you analyzed the example of an improvement in the model fit by adding additional variable on the wells data. Continuing with this data set you will see how further increase in model complexity effects deviance and model fit.

The dataset wells have been preloaded in the workspace.

Bu egzersiz

Generalized Linear Models in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Fit a logistic regression model with switch as the response and distance100 and arsenic as explanatory variables.
  • Compute the difference in deviance of the intercept only model and the model including all the variables.
  • Print the computed difference.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import statsmodels
import ____.____ as sm
from ____.____.____ import glm

# Define model formula
formula = '____ ~ ____'

# Fit GLM
model_dist_ars = glm(____, ____ = ____, ____ = sm.____.____).____

# Compare deviance of null and residual model
diff_deviance = ____.____ - ____.____

# Print the computed difference in deviance
____(____)
Kodu Düzenle ve Çalıştır