[R] basic question about t-test with adjusted p value

Erik Iverson eriki at ccbr.umn.edu
Sat Aug 7 22:24:35 CEST 2010


On 08/07/2010 03:08 PM, Josef.Kardos at phila.gov wrote:
> I have read the R manual and help archives, sorry but I'm still stuck.
>
> How would I do a t-test with an adjusted p-value?

Please be more specific about what you mean by 'adjusted p-value'. See below...

>
> Suppose that I use t.test ( ) , with the function argument alternative =
> "two.sided",  and data such that degrees of freedom = 20.  The function
> calculates a t-statistic of 2.086, and p-value =0.05
>
> How do I then adjust the p-value?  My thought is to do
> p.adjust (pt(2.086, df=20),"BH")
> but that doesn't change anything (returns 0.975)

A couple things here.

1) You can get the p-value returned from t.test by inspecting the object with 
?str, and noting that it's stored in an element called p-value.

So,

p.val <- t.test(extra ~ group, data = sleep)$p.value

assigns the p-value to an object called p.val.

2) You're calling p.adjust with a single p-value, so what kind of adjustment did 
you have in mind? You would normally be adjusting p-values because of a multiple 
comparison issue (i.e., multiple tests performed).  You'd pass p.adjust the 
*vector* of p-values, and a method to adjust them by.  Your vector is of length 
1, so in p.adjust's opinion, there is nothing to adjust for.

So, what do *you* mean by 'adjusted p-value'?  `Why are you looking to adjust?` 
is another way of stating that.



More information about the R-help mailing list