[R] Comparing two regression line slopes

Arien Lam a.lam at geo.uu.nl
Wed Apr 15 11:47:41 CEST 2009


Benedikt,

Is this homework? Let's see, the same question as last week, when Eik
Vetorazzi showed you how to interpret the test value.
The significance of this test depends on your pre-specified alpha. Don't
rely on an arbitrary value of 0.05. It would be a good idea to do some
reading (any introductory statistics book would suffice, there are some
excellent suggestions on this list if you care to look for them).

Hope this helps,
Arien

On Wed, April 15, 2009 11:31, Alain Guillet wrote:
> Hello benedikt,
>
> You say the slopes differ significantly if the p-value is less than a
> given threshold, most of the time 0.05.
>
> Please, note that fitting a linear regression through three points is
> senseless...
>
> Regards,
> Alain
>
>
> Benedikt Niesterok wrote:
>> Hello R users,
>> I've used the following help:
>>
>>
>>> "Comparing two regression line slopes"
>>> I knew the method based on the following statement :
>>> t = (b1 - b2) / sb1,b2
>>> where b1 and b2 are the two slope coefficients and sb1,b2 the pooled
>>> standard error of the slope (b)
>>>
>>> which can be calculated in R this way:
>>>  > df1 <- data.frame(x=1:3, y=1:3+rnorm(3))
>>>  > df2 <- data.frame(x=1:3, y=1:3+rnorm(3))
>>>  > fit1 <- lm(y~x, df1)
>>>  > s1 <- summary(fit1)$coefficients
>>>  > fit2 <- lm(y~x, df2)
>>>  > s2 <- summary(fit2)$coefficients
>>>  > db <- (s2[2,1]-s1[2,1])
>>>  > sd <- sqrt(s2[2,2]^2+s1[2,2]^2)
>>>  > df <- (fit1$df.residual+fit2$df.residual)
>>>  > td <- db/sd
>>>  > 2*pt(-abs(td), df)
>>>
>> Using my data I finally get the value of the test, which is: 2.245e-7.
>> Do my slopes differ significantly now?
>> Thanks for help,  Benedikt
>>
>>
>> --
>>
>> ______________________________________________
>> 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.
>>
>>
>
> --
> Alain Guillet
> Statistician and Computer Scientist
>
> SMCS - Institut de statistique - Université catholique de Louvain
> Bureau d.126
> Voie du Roman Pays, 20
> B-1348 Louvain-la-Neuve
> Belgium
>
> tel: +32 10 47 30 50
>
> ______________________________________________
> 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.
>


-- 
drs. H.A. (Arien) Lam (Ph.D. student)
Department of Physical Geography
Faculty of Geosciences
Utrecht University, The Netherlands

E-mail:     a.lam at geo.uu.nl
Web:        http://www.geo.uu.nl/staff/a.lam

Telephone:  +31(0)30-253 2988 (direct), 2749 (secretary)
Fax:        +31(0)30-2531145

Visiting address: Room Zon 121, Heidelberglaan 2, Utrecht
Postal address: P.O.Box 80.115, 3508 TC Utrecht




More information about the R-help mailing list