# [R] Significance of slopes

Petr PIKAL petr.pikal at precheza.cz
Wed Dec 10 07:57:53 CET 2008

Hi

r-help-bounces at r-project.org napsal dne 09.12.2008 23:21:17:

> Hi Christian,
> please give always reproducible code,
> so we can see what have done
> and  give you the best answer.
>
> lm function, generally
> as in this  example form lm man page ( ?lm)
>
>
> > trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
> >ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
> >reg=lm(trt~ctl)
> >summary(reg)
>
> Call:
> lm(formula = trt ~ ctl)
>
> Residuals:
>      Min       1Q   Median       3Q      Max
> -1.09389 -0.33069 -0.15249  0.05128  1.45497
>
> Coefficients:
>             Estimate Std. Error t value Pr(>|t|)
> (Intercept)   7.7957     2.1661   3.599  0.00699 **
> ctl          -0.6230     0.4279  -1.456  0.18351
> ---
> Signif. codes:  0 â€˜***â€™ 0.001 â€˜**â€™ 0.01 â€˜*â€™ 0.05 â€˜.â€™ 0.1
â€˜ â€™ 1
>
> Residual standard error: 0.7485 on 8 degrees of freedom
> Multiple R-squared: 0.2095,    Adjusted R-squared: 0.1106
> F-statistic:  2.12 on 1 and 8 DF,  p-value: 0.1835
>
>
> Returns you all the  answer (almost) for the  questions that you ask;
> the p-value of the intercept line, is the p-value from the
> test( t test)  if the intercept is  different form zero.
> the ctl line has also the same interpretation, regarding the value
returned.
> Meaning no is not significantly different form zero.
>
> If you want to test if the  estimates ( slopes or intercept) are
> different from a specific value as in your case different for 0.5
> you can apply a test.

Or use offset

test for slope == -1
reg=lm(trt~ctl+offset(-1*ctl))
summary(reg)

Call:
lm(formula = trt ~ ctl + offset(-1 * ctl))

Residuals:
Min       1Q   Median       3Q      Max
-1.09389 -0.33069 -0.15249  0.05128  1.45497

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   7.7957     2.1661   3.599  0.00699 **
ctl           0.3770     0.4279   0.881  0.40391
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.7485 on 8 degrees of freedom
Multiple R-squared: 0.2095,     Adjusted R-squared: 0.1106
F-statistic:  2.12 on 1 and 8 DF,  p-value: 0.1835

test for slope == 0.5
reg=lm(trt~ctl+offset(0.5*ctl))

Regards
Petr

> Type on R
> ?t.test
> and you can find the  all the information you need.
>
> Hope this helps
>
> Best Regards
>
> Anna
>
> Anna Freni Sterrantino
> Ph.D Student
> Department of Statistics
> University of Bologna, Italy
> via Belle Arti 41, 40124 BO.
>
>
>
>
> ________________________________
> Da: Christian Arnold <chrarnold at web.de>
> A: r-help at r-project.org
> Inviato: MartedĂ¬ 9 dicembre 2008, 21:54:23
> Oggetto: [R] Significance of slopes
>
> Hello R community,
>
> I have a question regarding correlation and regression analysis. I have
two
> variables, x and y. Both have a standard deviation of 1; thus,
correlation and
> slope from the linear regression (which also must have an intercept of
zero) are equal.
> I want to probe two particular questions:
> 1) Is the slope significantly different from zero? This should be easy
with
> the lm function, as the p-value should reflect exactly that question. If
I am
> wrong, lease correct me.
> 2) Is the slope significantly different from a non-zero value (e.g.
0.5)? How
> can I probe that hypothesis? Any ideas?
>
> I apologize if this question is too trivial and already answered
somewhere,
> but I did not find it.
>
> [[elided Yahoo spam]]
> Christian
>
> ______________________________________________
> 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.
>
>
>
>
>    [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.