Forums | OpenR
OpenR: R & Statistics
/
question about bonferroni pairwise.test
14 April 2022, 11:34 PM
As preparing for group presentation of Bonferroni t-test, I met a problem: How exactly the pairwise.test figure out or calculate the result p-value numbers.
My understanding is that when we apply p.adj = 'none', the result would be the t-test p-values for each pair, and when apply p.adj = 'bonf', the result would different from the former.
But as I try to use t.test() in R to verify the p-values, and I got different results from pairwise.test( p.adj = 'none') and I donot know why, should they be the same?
And as for results from pairwise.test( p.adj = 'bonf') , it is more confusing how the result numbers are calculated.
Could you please help me with this question? Many thanks.
my code for comparing the pvalues from t.test and pairwise.test( p.adj = 'none') is below.
data(airquality)
#test for ozone value for month 5 and 7
var.test(airquality$Ozone[airquality$Month == '5'],airquality$Ozone[airquality$Month == '7'],
alternative = "two.sided", ratio = 1)
#variance is equal
t.test(airquality$Ozone[airquality$Month == '5'],airquality$Ozone[airquality$Month == '7'],
var.equal = TRUE,
alternative = "two.sided", mu = 0)
#test for ozone value for month 5 and 9
var.test(airquality$Ozone[airquality$Month == '5'],airquality$Ozone[airquality$Month == '9'],
alternative = "two.sided", ratio = 1)
#variance is equal
t.test(airquality$Ozone[airquality$Month == '5'],airquality$Ozone[airquality$Month == '9'],
var.equal = TRUE,
alternative = "two.sided", mu = 0)
#pairwise.test, but use 'none' for adjustment.
pairwise.t.test(airquality$Ozone,airquality$Month, p.adj = "none")
Edits to this post:
-
Peng Zhao - 15 April 2022, 10:01 AM
15 April 2022, 11:22 AM
You have to specify not using pooled sd and the variances are equal:
pairwise.t.test(airquality$Ozone,airquality$Month, pool.sd = FALSE,var.equal = TRUE, p.adj = "none")
See the help document for details.
15 April 2022, 11:49 AM
Thanks for replying! It solved and the result matched when applying no adjustment in pairwise.test.
And as for the bonferroni adjustment I figure out in R.