[R] t value two.sided and one.sided

Marc Schwartz marc_schwartz at comcast.net
Fri May 11 02:11:32 CEST 2007


On Fri, 2007-05-11 at 00:14 +0100, gatemaze at gmail.com wrote:
> Hi,
> 
> on a
> > summary(lm(y~x))
> are the computed t-values for two.sided or one.sided. By looking on some
> tables they seem like they are for two.sided.

Yep.

>  Is it possible to have them
> for one.sided? If this makes sense...

Yep.

Using the example model 'lm.D9' from ?lm:

summ.lm <- summary(lm.D9)

> summ.lm

Call:
lm(formula = weight ~ group)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.0710 -0.4938  0.0685  0.2462  1.3690 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   5.0320     0.2202  22.850 9.55e-15 ***
groupTrt     -0.3710     0.3114  -1.191    0.249    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.6964 on 18 degrees of freedom
Multiple R-Squared: 0.07308,    Adjusted R-squared: 0.02158 
F-statistic: 1.419 on 1 and 18 DF,  p-value: 0.249 


Now get the one sided values:

> pt(coef(summ.lm)[, 3], summ.lm$df[2], lower = FALSE)
 (Intercept)     groupTrt 
4.773564e-15 8.754884e-01 

 
> pt(coef(summ.lm)[, 3], summ.lm$df[2], lower = TRUE)
(Intercept)    groupTrt 
  1.0000000   0.1245116 


See ?summary.lm, ?coef and ?pt

HTH,

Marc Schwartz



More information about the R-help mailing list