KNOWLEDGEBASE - ARTICLE #248

Comparing slopes of linear regression lines: If there are three or more lines, how can I account for multiple comparisons? How to get confidence interval of difference or ratio of slopes?

Using Prism's linear regression analysis

If you use linear regression to fit two or more data sets, Prism can automatically test whether slopes and intercepts differ. 

Overall comparison

  1. Create an XY table, choosing an appropriate subcolumn format for the Y values (for entry of one value, triplicates, mean/SD/n...).
  2. Enter your data. 
  3. Click Analyze and choose simple linear regression.
  4. In the "Parameters: Linear Regression" dialog, check the option, "Test whether slopes and intercepts are significantly different" .
  5. You'll find the results in the "Are lines different?" subpage of the linear regression results. 

Note that all the data must be entered on one data table. This article explains how to enter the data.

The P value answers the question: If all the data sets really came from populations with identical slopes, what is the probability that random sampling would result in slopes as disparate as the ones observed in this experiment. 

The calculations follow a method spelled in Chapter 18 of J Zar, Biostatistical Analysis, 2nd edition, Prentice-Hall, 1984. It is equivalent to analysis of covariance (ANCOVA). (It is still Chapter 18 in the Fourth edition)

Multiple comparisons tests

If you are only comparing two groups, you are done. 

If you are comparing more than two groups, you might want to test them two at a time with followup multiple comparisons tests. Prism cannot do this automatically, but here is a way to get the job done by entering the slopes and running an ANOVA:

  1. Create a new Grouped data table  with Y subcolumns formatted for entry of mean, SEM and n.
  2. Enter data into the first row only:
    1. Enter slopes into "mean".
    2. Enter the SE of slopes as "SEM".
    3. For the "n" subcolumn, enter a value equal to one more than the df value reported in the linear regression results. Why df+1? Because the ANOVA computations depend on knowing the df value, and Prism will subtract 1 from whatever you enter as n to calculate the df value it uses in ANOVA. If you enter df+1 as n, then when Prism subtracts 1, the correct df value will be used in the calculation. For linear regression, df equals n-2, where n is the number of xy pairs. Why minus two? Because you fit two parameters, slope and intercept. 
  3.  Click analyze, and choose one-way ANOVA from the list of Column analyses.
    1. On the first tab, choose ordinary ANOVA (not repeated measures, not nonparametric).
    2. On the second tab, choose your goal for multiple comparisons. Compare every slope with every slope? Or compare all with a control slope?
    3. On the third tab, choose the multiple comparisons test you want. 

 Note: Elsewhere, we explain how to test whether the slope of a linear regression differs from a specific, hypothetical value.

Using Prism's nonlinear regression analysis to also compute the confidence interval for the difference between slopes?

Prism's linear regression analysis can compare slopes and report a P value. But it doesn't report a confidence interval for the difference or ratio of the slopes. However Prism's nonlinear regression analysis can do this. This file does the calculations for you. It compares slopes, assuming that the intercepts are different. It uses global nonlinear regression to this model:

<A>Y= YIntercept + SlopeA*X
<B>Y= YIntercept + (SlopeA+SlopeDifference)*X

The first line fits a straight line to data set A. The second line fits a line to data set B, but the slope of this line is defined as the Slope of the first line plus a difference. This model is fit by "nonlinear" regression (which can fit linear models) sharing the parameter SlopeA between data sets. It reports that slope and the difference between slopes both with confidence intervals. It also compares the fit of this model to the fit of the same model but constraining SlopeDifference to zero, which means both slopes are identical. A small P value for the comparison is evidence against the null hypothesis that both slopes are the same. 

A second fit in the file is similar, but instead of fitting the difference between two slopes, fits the ratio of the two slopes, also with confidence interval. 



Keywords: compare slopes, post tests, bonferroni

Explore the Knowledgebase

Analyze, graph and present your scientific work easily with GraphPad Prism. No coding required.