[R] generating a paired t-test with multiple levels of a factor

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Mar 27 23:14:52 CET 2008


Michael A. Miller wrote:
>>>>>> "James" == James Root <jcroot at gmail.com> writes:
>>>>>>             
>
>     > Is there a way to run all paired t-tests where a paired
>     > t-test is run for every possible combination?
>
> Sounds like pairwise.t.test is the sort of thing you are looking
> for...
>
>   
Yes, except that it was designed for independent samples t-tests, so you 
need to be careful about not mixing up the pairs. This appears to do the 
trick:

> pairwise.t.test(a,col(a),paired=T,pool=F,p.adj="none")

        Pairwise comparisons using t tests with non-pooled SD 

data:  a and col(a) 

  1       2       3       4       5       6      
2 1.4e-08 -       -       -       -       -      
3 1.2e-06 0.65530 -       -       -       -      
4 1.7e-07 0.05903 0.09535 -       -       -      
5 6.1e-08 0.02352 0.17532 0.53276 -       -      
6 0.00355 0.29816 0.10283 0.04843 0.07627 -
7 0.00077 0.14419 0.06035 0.00691 0.02340 0.51667
P value adjustment method: none 

> a
    c0  c3  c6  c9 c12 c18 c24
24 150 122 103 109 103  87 109
25 173 127 117 124 143 123 144
26 191 174 165 160 177 184  NA
27 191 159 157 161 150 187 215
28 230 150 144 153 125 124 152
29 145 134 167 141 112 212 194
30 128  92  89  78  83  78  80
31 102  86  80  76  82  79  68
32 180 124 116 117 124  NA  NA
33 153  96  97  96  93 156 110
34 115  79  79  79  73  69  72
35 150 113 124 102 100 109 101
36 182 147 156  79 135  NA 162
37 175 146 157 140 143 158 162
38 146  86  81  80  87  89  95
39  92  80  95  95  86 119  NA
40 228 177 185 181 190 182 192
41 178 119 107  NA 102 110  94
42 213 185 152 142 158 178 194
43 161 107 104 107  NA 118 129


> Mike
>
> ______________________________________________
> 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.
>   


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list