Skip to content
Back to formatted view

Raw Message

Message-ID: <497F84BD.2070407@gmail.com>
Date: 2009-01-27T22:03:41Z
From: Zhou Fang
Subject: How to compare two  regression line slopes
In-Reply-To: <CA635738-A34E-4BED-B00C-541D86F16B6D@ulb.ac.be>

Hi,

Yes, the two methods are equivalent.

The p-value R calculates is based on the same t-statistic used in your 
manual analysis. You can see this by doing the second method:

y2 = rbind(df1, df2)
y2 = cbind(c(0,0,0,1,1,1), y2)
summary(lm(y2[,3] ~ y2[,1] + y2[,2] + y2[,2]*y2[,1]))

Look at the values you previously calculated and see where they reappear...
print(td)
print(db)
print(sd)

Looked at from the other way, the models with the D's and so on is one 
way to explain where the t-test comes from. Just do H0: b2=0 vs H1: 
b2!=0, and sprinkle some independence and normality assumptions.

It's probably preferable to use the automatic lm based method, because 
then you specify the model explicitly, while with the seemingly recipe 
based approach the actual models and hypotheses your are testing may not 
be clear. Plus you get nice diagnostic statistics and pretty graphs. The 
downside is that you might get lured into complacency...

Zhou Fang

PS: Your model equation isn't right. In both, we are also allowing the 
intercept to vary between groups. So really you want
y = c + D.b0 + b1.x + D.b2.x