# Ways of comparing linear regression interepts and slopes?

Let's say I have a repeated-measures design in which participants take part in a task where they have to rate the attractiveness of 50 different faces in 4 different conditions of facial expression type. Condition A is a baseline with neutral expression, condition B is happy, condition C sad and condition D angry.

I've run individual linear regressions with conditions B, C and D as the dependent variable and condition A as a predictor, generating 3 different regression equations. I would like to find a way to statistically compare these equations in terms of their slope and intercept.

Specifically, the theory I am trying to test predicts there will be no change in slope between them, but condition B should raise the intercept, condition D should lower it and there should be no change in C. In other words, the different conditions should result in a uniform shift up or down in terms of attractiveness.

Is there any way to test this statistically?

You can compare slopes and intercepts using dummy variables. You need one less dummy variable that the number of regressions you are comparing. If you have two regression lines the dummy variable $$d1$$ has values of $$1$$ or $$0$$. Assuming you have multiple sample $$y$$ and $$x$$, some of them will be from one group, lets call it $$Group\space A$$, the others will be from another $$Group\space B$$. To the set of $$x$$ - $$y$$ variables you would add $$d1$$ with value $$0$$ for observations from $$Group\space A$$ and value $$1$$ for observations from $$Group\space B$$. You now fit a model where $$y$$ ~ $$x,\space d1$$ and $$x*d1$$. Multiple regression will give you coefficients $$b0, b1, b2$$ and $$b3$$ for the $$intercept$$, $$x$$, $$d1$$ and $$d1*x$$. The equation just fitted is

$$y = b0 + b1*x + b2*d1 + b3*x*d1$$

For $$Group\space A$$ where $$d1 = 0$$ the equation is

$$y = b0 + b1*x$$ (I)

For $$Group\space B$$ where $$d1 = 1$$ the equation is

$$y = b0 + b1*x + b2*d1 + b3*d1*x = (b0 + b2) + (b1 + b3)*x$$ (II)

The intercept is $$(b0 + b2)$$, the slope is $$(b1 + b3)$$

If the coefficient for $$d1$$ is statistically significant then the slopes and intercepts are calculated as in (II), otherwise there is no differences and the model is (I).

The process can be extended to as many groups just adding more dummy variables $$d1,\space d2...$$, etc.

If you have 3 groups as you describe this is the table for the dummy variables values:

$$Group\space A: d1 = 0;\space d2 = 0$$
$$Group\space B: d1 = 1;\space d2 = 0$$
$$Group\space C: d1 = 1;\space d2 = 1$$

The equation to be fitted is

$$y$$ ~ $$x\space d1\space d2\space x*d1\space x*d2$$

The regression equation will be:

$$y = b0 + b1*x + b2*d1 + b3*d2 + b4*x*d1 + b5*x*d2$$

$$Group\space A,\space d1 = 0, d2 = 0$$
$$y = b0 + b1*x$$

$$Group\space B,\space d1 = 1, d2 = 0$$
$$y = (b0 + b2) + (b1 + b4)*x*d1$$
$$(b0 + b2)$$ is the slope; $$(b1 + b4)$$ is the intercept.

$$Group\space C,\space d1 = 1, d2 = 1$$
$$y = (b0 + b2 + b3) + (b1 + b4 + b5)*x*d1*d2$$
$$(b0 + b2 + b3)$$ is the slope; $$(b1 + b4 + b5)$$ is the intercept.

Hope this helps. Is quite straightforward.

• Thanks for the response, very helpful. Just a quick follow up if you don’t mind: I understand that the significance of the d1 and d2 coefficients would indicate a difference between the models, but is there a way to unpack this difference? What I mean is that I would like to be able to report whether there is a significant difference between the models in slope and intercept separately as the theory I want to test predicts a change in intercept but not in slope. Is there a way to calculate a p value for change in slope, and a separate one for change in intercept? – RarelySee Aug 27 '16 at 16:39
• Yes. You unpack the difference by looking at the coefficients of the dummy variables. If the p value of the coefficient is less than 0.05 you include that coefficient in the model. In the example above, lets say that b0 has p > 0.05. – LDBerriz Aug 27 '16 at 20:42
• Group A would have no intercept. Group B would have and intercept equal to b2 with its significance determined by its p value. Group C would have an intercept equal to b2 + b3 with a p value of the highest of the p values of b2 and b3. The same applies to the slopes. If b4 has p>0.05 the slopes of Group A and B are equal. The slope of group C is different to the other two with P value equal to the P value of b5. – LDBerriz Aug 27 '16 at 20:43
• Hi! This is more than useful. Although can you give me a journal reference? Or is there a commonly known name for this method? Thanks! – Zsolt Szatmari May 8 '17 at 10:11
• Reference: SAS for linear models. Freund, Little, Stroup. I have an early version of this book where the method is described. I have seen it described somewhere else. This is an old technique which I first learned for two groups more than 30 years ago. – LDBerriz May 8 '17 at 10:20