Given a regression model $F(X) = y$, where $F(X) = \beta_0 + \beta_1:groupX + ... $ I want to test a null hypothesis that there is no difference in the coefficients between groups for each coefficient one at a time.

In other words, not just knowing the significance for each coefficient for group, one at a time. Instead, we want to test whether a given coefficient is the same for each group.

In my case, I have only two groups. But I assume this generalizes.

For example, consider the Iris dataset.

scatterplot(Sepal.Width~Sepal.Length | Species, regLine=TRUE, 
            smooth=FALSE, boxplots=FALSE, by.groups=TRUE, data=iris)

Say we are interested in the following model:

modComplete <- lm(Sepal.Width ~ -1 + Species + Species:Sepal.Length + Species:Petal.Length, data=iris)

How can I test the that for a significant difference in the coefficients for Sepal.Length and Petal.Length for each group groups?


1 Answer 1


You can add the binary grouping variable (G) as a predictor to your model together with its product with each predictor variable X (moderated regression), for example, G*X. The regression slope coefficients for the product terms indicate the difference in the slopes between the groups. You can test whether the regression coefficients for the product terms are significantly different from zero to test your desired hypothesis.

With more than two groups, you have to create multiple dummy variables and include all dummy variables as well as all product terms into your model.

An alternative is using multigroup analysis in software for structural equation modeling in which you can directly constrain regression coefficients across groups and compare constrained models against one in which the coefficients are free to vary across groups.

  • $\begingroup$ I see, that makes sense. So this 1/0 term will function similar to an intercept, only for the group-level effects. That makes a lot of sense. $\endgroup$ Commented Sep 15, 2023 at 17:15

Your Answer

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