EME 210
Data Analytics for Energy Systems

(link is external) (link is external)

Interaction Effects

PrintPrint

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)

Click here for a transcript.

ADD TRANSCRIPT TEXT HERE

Credit: © Penn State is licensed under CC BY-NC-SA 4.0(link is external)

 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. 

1
2
# libraries
import pandas as pd
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1/0 0/0


 Assess It: Check Your Knowledge

Knowledge Check