I want to test whether the coefficients of two independent variables ($x_1, x_2$) are different in two groups.

I know I can use a dummy variable $d$ which equals $1$ for group $1$ and equals $0$ for group $2$, and then get the regression model $y=β_0+β_1d+β_2x+β_3xd$ to see whether $β_3$ significantly differs from $0$. But in this model, there is only one independent variable $x$. How can I use a dummy variable when I have more than one independent variable?


1 Answer 1


You just need two interaction terms. Your model would be:
$$ y=β_0+β_1d+β_2x_1+β_3x_2 + \beta_4x_1d + \beta_5x_2d $$ From there, if you wanted to test them individually, you would just inspect the $t$-test that came standardly with your output for each of the two interactions. If you wanted to test them both together, you would drop the two interaction terms and fit a nested model. Then you would perform a nested model test.

  • $\begingroup$ Thanks so much. And may I know more about the nested model test? Is it to test whether the model B: y=β0+β1d+β2x1+β3x2+β4x1d+β5x2d is better than model A: y=β0+β2x1+β3x2? $\endgroup$
    – moon star
    Feb 20, 2018 at 19:27
  • $\begingroup$ @moonstar, yes, you take your "A" as the null, & see if you should reject that in favor of "B". If the test is significant, there is information in those 2 interaction terms (somewhere). Regarding nested model tests, it may help to read my answer here: esting for moderation with continuous vs. categorical moderators. $\endgroup$ Feb 20, 2018 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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