Re: [R] t-test problem

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Wed, 16 Jun 2010 22:33:31 -0700

On Wed, Jun 16, 2010 at 3:30 PM, Worik R <worikr_at_gmail.com> wrote:
> I have two pairs of related vectors
> x1,y1
>
> and
>
> x2,y2
>
> I wish to do a test for differences in means of x1 and y1, ditto x2 and y2.
>
> I am getting odd results.  I am not sure I am using 'pt' properly...
>
> I have not included the raw vectors as they are long.  I am interested if I
> am using R properly...
>
>> c(length(x1), length(y1), length(x2), length(y2))
> [1] 3436 1619 2677 2378
>
>
> First where the T-stat and the DF do not give the same result as 't.test'
> when passed into 'pt'
>
>> t.1 <- t.test(x1, y1)
>> 2 * pt(t.1$statistic, t.1$parameter)
>       t
> 1.353946

Sorry, I realized that is is fairly easy to test that it is an issue with which tail of the distribution you use. This should show what is going on better than my prior message.

1.353946/2 = 0.676973
1 - 0.676973 = 0.323027
0.323027 * 2 = 0.646054

in pt(), the default is lower.tail=TRUE. Switching it to FALSE just looks at the other tail of the distribution. It was difficult to see because of the multiplication by 2.

Josh

>> t.1$p.value
> [1] 0.646054
>
> I would have thought these would have been the same.  Like below....
>
>> t.2 <- t.test(x2, y2)
>> 2 * pt(t.2$statistic, t.2$parameter)
>        t
> 0.8679732
>> t.2$p.value
> [1] 0.8679732
>
> This is what I expect.
>
> clearly I misunderstand some thing.  What is it?
>
> cheers
> Worik
>
>        [[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.
>

-- 
Joshua Wiley
Ph.D. Student
Health Psychology
University of California, Los Angeles

______________________________________________
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.
Received on Thu 17 Jun 2010 - 05:38:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jun 2010 - 10:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive