[R] Discrepancy with p.value from t.test
Albyn Jones
jones at reed.edu
Wed Nov 2 02:41:08 CET 2011
The print method is the issue:
> t.out <- t.test(b1,b2,var.equal=T)
> t.out$p.value
[1] 4.108001e-38
> t.out$statistic
t
-15.93656
albyn
On Tue, Nov 01, 2011 at 02:40:15PM -0500, Jonathan Thayn wrote:
> Sometimes the p.value returned by t.test() is the same that I calculate using pt() and sometimes it's not. I don't understand the difference. I'm sure there is a simple explanation but I haven't been able to find it, even after looking at the code for t.test.default. I apologize if this is a basic and obvious question. For example:
>
> > data(sleep)
> > t.test(extra~group,data=sleep,var.equal=T)
>
> # the p.value returned is 0.07939
>
> > 2*pt(-1.8608,18) # using the t.statistic and the df returned above
> [1] 0.0791887
>
> These p.values are the same. However, they are different when I use a different dataset:
>
> > data(beavers)
> > b1 <- beaver1$temp
> > b2 <- beaver2$temp
> > t.test(b1,b2,var.equal=T)
>
> # the p.value returned is 2.2e-16
>
> > 2*pt(-15.9366,212) # using the t.statistic and the df returned above
> [1] 4.10686e-38
>
>
> Jonathan B. Thayn, Ph.D.
> Illinois State University
> Department of Geography and Geology
> 200A Felmley Hall
> Normal, Illinois 61790
>
> (309) 438-8112
> jthayn at ilstu.edu
> my.ilstu.edu/~jthayn
>
>
>
>
> [[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.
>
--
Albyn Jones
Reed College
jones at reed.edu
More information about the R-help
mailing list