In this section we test whether the slopes for two independent populations are equal, i.e. we test the following null hypothesis:
H0: β1 = β2 i.e. β1 – β2 = 0
The test statistic is
If the null hypothesis is true then
If the two error variances are equal, then as for the test for the differences in the means, we can pool the estimates of the error variances, weighing each by their degrees of freedom, and so
Since we can replace the numerators of each by the pooled value , we have
Note that the while the null hypothesis that β = 0 is equivalent to ρ = 0, the null hypothesis that β1 = β2 is not equivalent to ρ1 = ρ2.
Example 1: We have two samples, each comparing life expectancy vs. smoking. The first sample is for males and the second for females. We want to determine whether there is any significant difference in the slopes for these two populations. We assume that the two samples have the values in Figure 1 (for men the data is the same as that in Example 1 of Regression Analysis):
Figure 1 – Data for Example 1
As can be seen from the scatter diagrams in Figure 1, it appears that the slope for women is less steep than for that of men. In fact, as can be seen from Figure 2, the slope of the regression line for men is -0.6282 and the slope for women is -0.4679, but is this difference significant?
As can be seen from the calculations in Figure 2, using both pooled and unpooled values for sRes, the null hypothesis, H0: the slopes are equal, cannot be rejected. And so we cannot conclude that there is any significant difference between the life expectancy of males and females for any incremental amount of smoking.
Figure 2 – t-test to compare slopes of regression lines
Real Statistics Function: The following supplemental array function is provided by the Real Statistics Resource Pack. Here Rx1, Ry1 are ranges containing the X and Y values for one sample and Rx2, Ry2 are the ranges containing the X and Y values for a second sample.
SlopesTest(Rx1, Ry1, Rx2, Ry2, b, lab): outputs the standard error of the difference in slopes sb1–b2, t, df and p-value for the test described above for comparing the slopes of the regression lines for the two samples.
If b = True (the default) then the pooled standard error sb1–b2 is used (as in cell T10 of Figure 2); otherwise the non-pooled standard error is used (as in cell M10 of Figure 2).
If lab = True then the output is a 4 × 2 range where the first column contains labels and the second column contains the values described above and if lab = False (the default) only the data is outputted (in the form of a 4 × 1 range).
The SlopesTest function only produces the correct results if there are no missing data elements in Rx1, Ry1, Rx2, Ry2.
Observation: For Example 1, the formula
generates the output in range M29:N32 of Figure 3, while the formula
generates the output in range O29:O32.
Figure 3 – Comparing slopes using Real Statistics function