[R] regression slope
Adaikalavan Ramasamy
ramasamy at cancer.org.uk
Tue Jul 20 19:44:30 CEST 2004
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 at 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
>
More information about the R-help
mailing list