使用 t 检验比较实验条件

Comparing experimental conditions using t-test

我在各种条件下进行了一组实验 运行,我想使用 t 检验进行比较。当我执行 pairwise.t.test(mtcars$mpg, mtcars$am) 时,我自己的数据与 mtcars 具有相同的格式,我得到的 p 值比使用 t.test( mtcars$mpg,mtcars$am)。是预期的吗?我应该相信哪一个?

t.test(mtcars$mpg, mtcars$am)

Welch Two Sample t-test
data:  mtcars$mpg and mtcars$am
t = 18.413, df = 31.425, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
17.50519 21.86356
sample estimates:
mean of x mean of y 
20.09062   0.40625 

pairwise.t.test(mtcars$mpg, mtcars$am)$p.value
        0
1 0.0002850207

研究文档。 t.test 期望每组的值作为前两个参数。 pairwise.t.test 期望两个组的值作为第一个参数,分组因子作为第二个参数。此外,它们在合并方差方面有不同的默认值。

t.test(mtcars$mpg, mtcars$am)$p.value
#[1] 2.151228e-18

library(reshape2)
DF <- melt(mtcars[, c("mpg", "am")])
pairwise.t.test(DF$value, DF$variable, pool.sd = FALSE)$p.value
#            mpg
#am 2.151228e-18