Interaction terms
In the video you learned how to include interactions in the model structure when there is one continuous and one categorical variable. In this exercise you will analyze the effects of interaction between two continuous variables.
You will use centered variables instead of original values to be able to interpret the coefficient effects more easily, i.e. from the level of the mean values rather than 0 which may not be logical for the study at hand. In other words we don't want to interpret the model by assuming 0 for arsenic
or distance100
variables.
The model 'switch ~ distance100 + arsenic'
has been preloaded as model_dist_ars
in the workspace.
Also wells
dataset is preloaded.
This exercise is part of the course
Generalized Linear Models in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import libraries
import statsmodels.api as sm
from statsmodels.formula.api import glm
# Fit GLM and print model summary
model_int = ____('____ ~ ____(____) + ____(____) + ____(____):____(____)',
data = ____, family = ____).____
# View model results
print(____.____)