1
$\begingroup$

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

$\endgroup$
5
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for the answer, how the first order interaction was calculated? $\endgroup$ – user162385 May 23 '17 at 7:09
2
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ More 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. $\endgroup$ – Tim May 23 '17 at 8:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.