问题描述
在将成对 t 检验作为一种方式重复测量方差分析的事后审查时,我注意到一个奇怪的地方。当我合并标准偏差时,rstatix 库中 pair_t_test 的测试统计量不会改变——实际上没有任何输出改变。
我的理解是,合并标准差的全部意义在于更准确地估计检验统计量。但是,在尝试此操作时,我找不到输出中的差异(见下文)。
我的理解有误吗?合并标准差对多个成对比较(尽管存在球形度)有何影响?
我使用了以下数据设置:
library(rstatix)
library(tidyverse)
selfesteem.test <- selfesteem %>%
gather(key = "time",value = "score",t1,t2,t3) %>%
convert_as_factor(id,time)
在以下代码中使用合并标准偏差:
selfesteem.test %>%
pairwise_t_test(
score ~ time,paired = TRUE,p.adjust.method = "bonferroni",pool.sd = TRUE
)
结果:
# A tibble: 3 x 10
.y. group1 group2 n1 n2 statistic df p p.adj p.adj.signif
* <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <chr>
1 score t1 t2 10 10 -4.97 9 0.000772 0.002 **
2 score t1 t3 10 10 -13.2 9 0.000000334 0.000001 ****
3 score t2 t3 10 10 -4.87 9 0.000886 0.003 **
以下代码:
selfesteem.test %>%
pairwise_t_test(
score ~ time,pool.sd = FALSE
)
结果相同:
# A tibble: 3 x 10
.y. group1 group2 n1 n2 statistic df p p.adj p.adj.signif
* <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <chr>
1 score t1 t2 10 10 -4.97 9 0.000772 0.002 **
2 score t1 t3 10 10 -13.2 9 0.000000334 0.000001 ****
3 score t2 t3 10 10 -4.87 9 0.000886 0.003 **
解决方法
根据?pairwise_t_test
池化不能推广到配对测试,因此 pool.sd 和 paired 不能都为 TRUE。
如果 pool.sd = FALSE,则将标准的两样本 t 检验应用于所有可能的组对。此方法调用 t.test(),因此接受额外的参数,例如 var.equal。
此外,Usage 确实显示了否定 (!
)
pairwise_t_test( 数据, 公式, 比较 = NULL, ref.group = NULL,p.adjust.method = "holm",配对 = FALSE, pool.sd = !配对, 详细=假, ... )