Re: [R] regression slope

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Wed 21 Jul 2004 - 04:28:05 EST

Adaikalavan Ramasamy wrote:

> 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
> 

I think the preferred way of doing this is with confint:

ink2"># 3 sigma limits
confint(m1, parm = "x", level = 1 - pt(-3, m1$df.resid) * 2) # 95% confidence (default)
confint(m1, parm = "x")

> 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:

>&
gt;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:

>&
gt;fm1 <- lm (x ~ y)
>&
gt;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

______________________________________________
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 04:45:26 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:08 EST