Ted this was very helpful.

To be crystal clear I'll rephrase you.

What I am interested in is the probability that my 'T' is in the tail.  For
a two sided test I do not care which tail.  Since (all things being equal)
the distribution of T is around 0 if the my T is greater than 0 I compare it
to the upper tail, and if it is less than 0 I compare it to the lower tail.

'pt' that gives the probability for one tail.  I must be careful to choose
the correct tail, and multiply by 2.

Thank you again, Ted and everybody else who helped.

As an aside this is why I wish I had done more statistical *theory* rather
than applied statistics, of which I have done quite a bit.  I do not know if
it is just me, but it is me, theoretical underpinnings for this stuff is
*very* important.  This is a very simple concept and I spent a whole day
(with the invaluable help of this list) trying to get my head around what I
would have seen straight away with a better education.

I cannot express my wonder and appreciation for the R community, its
patience and perseverance.  It is a truly marvellous thing.

Worik Stanton
Dunedin
New Zealand

On Fri, Jun 18, 2010 at 12:43 AM, Ted Harding
<ted.hard...@manchester.ac.uk>wrote:

> On 16-Jun-10 22:30:39, Worik R 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
> >> 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
>
> The P-value is the tail-area (or the sum of the two tail-areas
> for a two-sided test). The value of pt() is the total probability
> to the left of the upper tail. Taking your results above:
>
> [1]:
>   t.1 <- t.test(x1, y1)
>  2 * pt(t.1$statistic, t.1$parameter)
>  #        t
>  #  1.353946
>  t.1$p.value
>  #  [1] 0.646054
>
> The "t.1$p.value" result will (by default) be the two-tailed test,
> so one tail will have probability equal to half the P-value,
> while the value of pt() will be Prob(T <= t1$statistic).
> Hence the former will be 2*(1 - the latter) **provided the t-statistic
> is positive** -- otherwise, if the t-statistic is negative, the
> former is twice the latter.
>
> . Check:
>
>  2*(1 - 1.353946/2)
>  # [1] 0.646054
>
>  2*(1 - 0.646054/2)
>  # [1] 1.353946
>
> So this indicates that the t-value (which you did not quote) was
> positive.
>
> [2]:
>   t.2 <- t.test(x2, y2)
>  2 * pt(t.2$statistic, t.2$parameter)
>  #        t
>  #  0.8679732
>  t.2$p.value
>  #  [1] 0.8679732
>
>   2*(1 - 0.8679732/2)
>  # [1] 1.132027
>
> (so no agreement), but:
>
>  2*(0.8679732/2)
>  # 0.8679732
>
> so here the t-value was negative. And that is the difference between
> thw two cases.
>
> Ted.
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 17-Jun-10                                       Time: 13:43:37
> ------------------------------ XFMail ------------------------------
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to