An interaction term is a term introduced to capture the interaction between two variables.
$Y_i = \beta_0 + \beta_1 Z_i + \beta_2 X_i + \beta_3 Z_i X_i + \epsilon_i$
With an interaction term, the slope of each factor can vary based on the value for the continuous variable $X$.
According to the **hierarchical principle**, if we include an interaction term in the model, we should also include the main effects (individual predictors) even if the associated p-values are not significant.
In [[R]] the interaction term can be included as
```R
lm(Y ~ Z + X + Z*X)
```
For a two-level factor with one covariate, a t-test will suffice to determine whether to include the interaction term. A partial F-test is better for models with more than two groups and/or more than one continuous covariate.