Re: [R] regression slope

From: Adaikalavan Ramasamy <ramasamy_at_cancer.org.uk>
Date: Wed 21 Jul 2004 - 03:44:30 EST

I would try to construct the confidence intervals and compare them to the value that you want
> x <- rnorm(20)
> y <- 2*x + rnorm(20)
> summary( m1 <- lm(y~x) )

<snip>
Coefficients:

            Estimate Std. Error t value Pr(>|t|)
(Intercept)   0.1418     0.1294   1.095    0.288
x             2.2058     0.1289  17.108  1.4e-12 ***
<snip>
That says that the slope estimate is 2.2058 with standard error of
0.1289. So the approximate 99% CI is 2.2058 +/- 3*0.1289 = (1.819,
2.593) which is clearly greater than 1.

> summary(m1)[[4]][2,1] + 3* summary(m1)[[4]][2,2]
[1] 2.592629
> summary(m1)[[4]][2,1] - 3* summary(m1)[[4]][2,2]
[1] 1.819026

For your next question, you simply compare the CI of one slope to another and see if they overlap.

There is probably a way to construct proper significance testing to get p-values and such. You can try reading MASS4 or hopefully someone in the list might provide with a neater answer.

On Tue, 2004-07-20 at 17:02, Avril Coghlan wrote:
> Hello,
>
> I'm a newcomer to R so please
> forgive me if this is a silly question.
>
> It's that I have a linear regression:
> fm <- lm (x ~ y)
> and I want to test whether the
> slope of the regression is significantly
> less than 1. How can I do this in R?
>
> I'm also interested in comparing the
> slopes of two regressions:
> fm1 <- lm (x ~ y)
> fm2 <- lm (a ~ b)
> and asking if the slope of fm1 is
> less than the slope of fm2. Is this
> easy to do in R?
>
>
> I will be very grateful for any help.
>
> regards,
> Avril Coghlan
> (University College Dublin, Ireland)
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 21 03:53:17 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:37:15 EST