In linear regression we can use A:B to show the first order interaction of variable A and B. But it is hard to know what effect was caused by A and what was caused by B. So I want to understand how exactly A:B worked
Asked
Active
Viewed 1,688 times
2 Answers
5
it is hard to know what effect was caused by A and what was caused by B
Actually it is not hard, but impossible. First, interaction term in regression tells you on effect of A and B together, rather then about their individual effects. Second, regression per se does not tell you anything about causality.

Tim
- 108,699
- 20
- 212
- 390
-
Thanks for the answer, how the first order interaction was calculated? – user162385 May 23 '17 at 07:09
2
In R syntax A:B includes $A \times B$ in the regression model so
lm(y~A+B+A:B,data=mydata)
is fitting $$ Y=\beta_0+\beta_1A+\beta_2B+\beta_3AB+\epsilon $$ There is a discussion of this in the book "An Introduction to Statistical Learning" by James et al.

PM.
- 587
- 1
- 3
- 13
-
1More precisely: it's $A\times B$ or if both A and B are discrete, it's all combinations of pairs of values of A and B that were found in data. The resulting model matrix is obtained through `model.matrix` function. – Tim May 23 '17 at 08:17