In this section we test whether the slopes for two independent populations are equal, i.e. we test the following null hypothesis:

H_{0}: *β*_{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 *s _{Res}*, the null hypothesis, H

_{0}: 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 *s*_{b1–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 *s*_{b1–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).

**Observation**: For Example 1, the formula

=SlopesTest(A5:A19,B5:B19,D5:D20,E5:E20,FALSE,TRUE)

generates the output in range M29:N32 of Figure 3, while the formula

=SlopesTest(A5:A19,B5:B19,D5:D20,E5:E20)

generates the output in range O29:O32.

**Figure 3 – Comparing slopes using Real Statistics function**

Hi,

You have a cell wrong in the excel sheet. Please fix it if you can. In Figure 2, cell M11 should be equal to (b1-b2)/(sb1-b2), NOT (b1-b2)/(sb1-sb2)

Thanks Aravindh,

That was a great catch. I have made the change that you suggested. Thanks for your help.

Charles

Dear Dr. Zaiontz

thank you for your useful example. I have a question:

As I found in your example, this method will be useful if linear regression consider. If we have some data that power regression will fit, in this case what should we do? can we use directly with those data or we should change them to linear regression (by log transferred for example)? for example, if we want to compare the regression line between fish male and female height and weight (which is power regression), we can use directly from those data?

Dear Ahmad Noori,

I believe that what you have suggested should work since you are only using a transformation. The formulas for comparing the slopes need to be applied after the transformation so that you are comparing the slopes of two (straight) lines.

Charles

Thank you for your laconic comments. What about “a” (Y intercepts) between two lines? Is this factor important if we want to compare the slopes between two lines or only the “b” (slope) should be compared?

Do you have a textbook or a paper you can cite to justify these equations? I’m fairly certain the test you present here is incorrect. The test statistic should be (b1 – b2) / sqrt(SE(b1)^2 + SE(b2)^2), where SE(b1) is given not by steyx (this is the standard error of the predicted y value) nor by the equation you give for s_b1. See, e.g., this link: (http://stats.stackexchange.com/questions/44838/how-are-the-standard-errors-of-coefficients-calculated-in-a-regression) on accurate calculation of these standard errors.

Andrew,

I used David Howell’s textbook entitled “Statistical Methods for Psychology”, Wadsworth CENGAGE Learning, 2010. Shortly I will recheck my test samples using your approach and the approach I used on the website.

Charles

Thanks for your quick reply, Charles. I actually caught the source of my confusion, and I’m now convinced that your approach is actually correct! Sorry about that.

Thank you for this, your slopestest function saved me a lot of trouble!

Sir

I am a little confusing about the “pool the estimates of the error variances” . The formula (S_res squre) you used in this website is different with the formula you used in Excel workbook.

Colin

Sir

Please ignore my question, you are right.

Colin

Hi Dr. Zaiontz,

This is exactly the type of information that I was looking for to complete a study that I was working on. I was wondering two questions;

1st) can you explain more about about I would go about finding the X/Y values of the lines in order to perform these calculations? I’m using a trendline in time-series line graph and I can see that there is definitely statistical significance, but I need to express it mathematically.

2nd) Do you know if this method is possible using SPSS?

Hi Johnathan,

I am very pleased that the information is relevant for your needs. Regarding your questions:

1) I am not sure what you mean. The X/Y values are the data that you are testing.

2) I don’t use SPSS, but I believe that the answer is yes. E.g. the following webpage references doing this in SPSS: http://core.ecu.edu/psyc/wuenschk/MV/multReg/Potthoff.pdf

Charles