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 2,382 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
- 138,066
-
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.
- 627
- 1
- 4
- 15
-
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.matrixfunction. – Tim May 23 '17 at 08:17