[R] Comparing two regression lines

From: Christoph Scherber <Christoph.Scherber_at_agr.uni-goettingen.de>
Date: Wed, 04 Jun 2008 13:37:03 +0200

Dear R users,

Suppose I have two different response variables y1, y2 that I regress separately on the same explanatory variable, x; sample sizes are n1=n2.

Is it legitimate to compare the regression slopes (equal variances assumed) by using


where FACTOR gets "y1" if y1 is the response, and "y2" if y2 is the response?

The problem I see here is that the residual degrees of freedom obviously go up (n1-1+n2-1) although there were only n1=n2 "true" replications.

On the other hand, Zar (1984) and some other statistics textbooks base their calculations on a modified version of the t test (mainly using the residual SS from the two regressions), but when I calculated these tests by hand I found that the t-values are almost identical to the one I get using the lm(...) approach.

Part of the R script is appended below.

How would you proceed?

Many thanks for your help!

Best wishes,


lm1=lm(y1~x) # y1 and y2 are different response variables, scaled to [0;1] using a ranging transform lm2=lm(y2~x) # n is 12 for each regression





t=(528.54-446.004)/SED #residual SS from lm1 and lm2 divided by SED qt(0.025,20) #compare with t distribution at 20 d.f.


#(using R 2.6.2 on Windows XP)

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 04 Jun 2008 - 11:54:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 04 Jun 2008 - 16:30:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive