Dear all, I am perplexed when trying to get the same results using pairwise.t.test and t.test. I'm using examples in the ISwR library,>attach(red.cell.folate)I can get the same result for pairwise.t.test and t.test when I set the variances to be non-equal, but not when they are assumed to be equal. Can anyone explain the differences, or what I'm doing wrong? Here's an example where I compare the first two ventilations with pairwise.t.test and t.test> pairwise.t.test(folate, ventilation, p.adj="none", pool.sd=F)Pairwise comparisons using t tests with non-pooled SD data: folate and ventilation N2O+O2,24h N2O+O2,op N2O+O2,op 0.029 - O2,24h 0.161 0.298 P value adjustment method: none> t.test(folate[1:8], folate[9:17], var.equal=F)Welch Two Sample t-test data: folate[1:8] and folate[9:17] t = 2.4901, df = 11.579, p-value = 0.02906 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 7.310453 113.050658 sample estimates: mean of x mean of y 316.6250 256.4444 So 0.029 and 0.02906 are identical but if I do the same with pool.sd and var.equal = T, I get different results> pairwise.t.test(folate, ventilation, p.adj="none", pool.sd=T)Pairwise comparisons using t tests with pooled SD data: folate and ventilation N2O+O2,24h N2O+O2,op N2O+O2,op 0.014 - O2,24h 0.155 0.408 P value adjustment method: none> t.test(folate[1:8], folate[9:17], var.equal=T)Two Sample t-test data: folate[1:8] and folate[9:17] t = 2.5582, df = 15, p-value = 0.02184 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 10.03871 110.32240 sample estimates: mean of x mean of y 316.6250 256.4444 So 0.014 and 0.02184 are not the same. [[alternative HTML version deleted]]
On Sep 10, 2010, at 16:01 , Jabez Wilson wrote:> Dear all, I am perplexed when trying to get the same results using pairwise.t.test and t.test. > I'm using examples in the ISwR library, >> attach(red.cell.folate) > I can get the same result for pairwise.t.test and t.test when I set the variances to be non-equal, but not when they are assumed to be equal. Can anyone explain the differences, or what I'm doing wrong? > Here's an example where I compare the first two ventilations with pairwise.t.test and t.test >> pairwise.t.test(folate, ventilation, p.adj="none", pool.sd=F) > Pairwise comparisons using t tests with non-pooled SD > data: folate and ventilation > N2O+O2,24h N2O+O2,op > N2O+O2,op 0.029 - > O2,24h 0.161 0.298 > P value adjustment method: none > >> t.test(folate[1:8], folate[9:17], var.equal=F) > Welch Two Sample t-test > data: folate[1:8] and folate[9:17] > t = 2.4901, df = 11.579, p-value = 0.02906 > alternative hypothesis: true difference in means is not equal to 0 > 95 percent confidence interval: > 7.310453 113.050658 > sample estimates: > mean of x mean of y > 316.6250 256.4444 > > So 0.029 and 0.02906 are identical but if I do the same with pool.sd and var.equal = T, I get different results >> pairwise.t.test(folate, ventilation, p.adj="none", pool.sd=T) > Pairwise comparisons using t tests with pooled SD > data: folate and ventilation > N2O+O2,24h N2O+O2,op > N2O+O2,op 0.014 - > O2,24h 0.155 0.408 > P value adjustment method: none > >> t.test(folate[1:8], folate[9:17], var.equal=T) > Two Sample t-test > data: folate[1:8] and folate[9:17] > t = 2.5582, df = 15, p-value = 0.02184 > alternative hypothesis: true difference in means is not equal to 0 > 95 percent confidence interval: > 10.03871 110.32240 > sample estimates: > mean of x mean of y > 316.6250 256.4444 > > So 0.014 and 0.02184 are not the same. > >The help page says: "The pool.SD switch calculates a common SD for all groups...." (NB: "all") So the denominator is not the same as when testing each pair separately. You can in fact do pairwise.t.test(folate, ventilation, p.adj="none", pool.sd=F,var.eq=T) -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
On Sep 10, 2010, at 9:01 AM, Jabez Wilson wrote:> Dear all, I am perplexed when trying to get the same results using pairwise.t.test and t.test. > I'm using examples in the ISwR library, >> attach(red.cell.folate) > I can get the same result for pairwise.t.test and t.test when I set the variances to be non-equal, but not when they are assumed to be equal. Can anyone explain the differences, or what I'm doing wrong? > Here's an example where I compare the first two ventilations with pairwise.t.test and t.test >> pairwise.t.test(folate, ventilation, p.adj="none", pool.sd=F) > Pairwise comparisons using t tests with non-pooled SD > data: folate and ventilation > N2O+O2,24h N2O+O2,op > N2O+O2,op 0.029 - > O2,24h 0.161 0.298 > P value adjustment method: none > >> t.test(folate[1:8], folate[9:17], var.equal=F) > Welch Two Sample t-test > data: folate[1:8] and folate[9:17] > t = 2.4901, df = 11.579, p-value = 0.02906 > alternative hypothesis: true difference in means is not equal to 0 > 95 percent confidence interval: > 7.310453 113.050658 > sample estimates: > mean of x mean of y > 316.6250 256.4444 > > So 0.029 and 0.02906 are identical but if I do the same with pool.sd and var.equal = T, I get different results >> pairwise.t.test(folate, ventilation, p.adj="none", pool.sd=T) > Pairwise comparisons using t tests with pooled SD > data: folate and ventilation > N2O+O2,24h N2O+O2,op > N2O+O2,op 0.014 - > O2,24h 0.155 0.408 > P value adjustment method: none > >> t.test(folate[1:8], folate[9:17], var.equal=T) > Two Sample t-test > data: folate[1:8] and folate[9:17] > t = 2.5582, df = 15, p-value = 0.02184 > alternative hypothesis: true difference in means is not equal to 0 > 95 percent confidence interval: > 10.03871 110.32240 > sample estimates: > mean of x mean of y > 316.6250 256.4444 > > So 0.014 and 0.02184 are not the same. >require(ISwR)> with(red.cell.folate[1:17, ], pairwise.t.test(folate, ventilation, pool.sd = TRUE))$p.valueN2O+O2,24h N2O+O2,op 0.02184081 NB: The pool.SD switch calculates a common SD for all groups and used that for all comparisons See the Details in ?pairwise.t.test HTH, Marc Schwartz