# How to test whether coefficients of variables in a regression are different

What is the proper test to determine whether the coefficients of variables in the same linear regression model are different from each other?

Specifically, the variables I am referring to are different levels of a categorical variable and the coefficients may be close enough to each other that there actually is no difference. If they were not correlated, I would merely obtain a z-score (difference between the estimates divided by the square root of the sum of the standard error, squared). However, not sure what to do in this situation.

Fit the model where you constrain the coefficients to be equal and compare that to the unconstrained model. E.g. if you have two predictors and fit the model

$$y_i = \beta_0 + \beta_1 X_{1i} + \beta_2 X_{2i} + \epsilon_i$$

as the unconstrained model. Then compare this to the model

$$y_i = \beta_0 + \beta_1 (X_{1i} + X_{2i}) + \epsilon_i$$

And compare using the likelihood ratio test. Operationally, you can do this by by defining a new variable that is the sum of the two predictors and put that into the model.

• Are you sure X2 in your second equation? Why would you combine both X1 and X2? Jan 30, 2017 at 3:17
• @StudentT Because that's the same as forcing them to have the same coefficient. If $\beta_1 = \beta_2$ in the full model (the first model), you'd get the second model. Jan 30, 2017 at 3:21
• Ok. But does that make the two models non-nested? LR test should only work on nested models. Jan 30, 2017 at 3:26
• @StudentT, yes. The sub-model is the subspace where $\beta_1 = \beta_2$. Any possible model fitted in the submodel could also be captured in the larger model simply by estimating $\beta_1$ and $\beta_2$ to be the same. You can define nested models that aren't just a matter of deleting predictors. The model is nested as long as the span of the space covered by the sub-model is a subset of that spanned by the full model space, which is the case here. Jan 30, 2017 at 3:27
• @gammer, I understand the logic. However, I don't know how to do this without specifying it manually. I'm running this in R using the LM function, which creates the dummy variables automatically for me. How would I ask it to combine two of the categories? Is there a simpler way than just recoding the categories so that category 1 and category 2 both become category 1. Jan 30, 2017 at 14:53