
Interaction Effects
Read It: Interaction Effects
When developing multiple linear regression models, it is possible to account for interactions between the variables. For example, maybe variable 'x' is not a great predictor of 'y', but the combined effect of 'x' and 'z' is an important predictor. In this case, the interactions can improve the accuracy of our model. In Python, we signify interactions with an asterisk (*
) or a colon (:
), depending on the type of interaction. The *
, for example, indicates that Python should consider both the interaction between two terms and as separate predictors, while the :
tells Python that you only want to consider the interaction. Below, we demonstrate the use of these key symbols in Python.
Watch It: Video - Interaction Effects (8:43 minutes)
Try It: DataCamp - Apply Your Coding Skills
Edit the following code to implement multiple linear regression with interaction effects. Your response variable is 'y' and all other variables can be used as explanatory variables.