提问人:rempsyc 提问时间:11/11/2023 最后编辑:Robert Longrempsyc 更新时间:11/21/2023 访问量:61
对 R 中的差异损耗进行统计测试?
Statistically testing for differential attrition in R?
问:
上下文
我有一个随机对照试验,有三组和三个时间测量(前、后、随访)。我注意到,从前到后,再从后到随访,不同组的流失率似乎不同。评价员询问差异性损耗是否具有统计学意义。
Reprex的
下面是示例数据:
data <- data.frame(
group = c("Control", "Treatment1", "Treatment2"),
pre = c(150, 150, 150),
post = c(150, 100, 80),
follow = c(120, 90, 70)
)
data
#> group pre post follow
#> 1 Control 150 150 120
#> 2 Treatment1 150 100 90
#> 3 Treatment2 150 80 70
创建于 2023-11-10 with reprex v2.0.2
问题
我真的可以一次只用 6 个值进行统计检验吗?我正在考虑两个测试:一个是前到后损耗,另一个是从后到随访的损耗测试。如果是这样,什么测试?
我从这个来源和这个来源读到,在这种情况下使用了两种主要测试:(a)差异损耗率测试和(b)选择性损耗测试。 这些测试是否适合我的数据?如何在 R 中进行这些测试?
答:
对于差分损耗率测试,您可以考虑使用独立性卡方检验,如果您有足够大的样本 - 对于小样本,此测试的功效较低。另一种方法是费舍尔精确检验。以下是我们如何对事前到事后以及事后到随访进行差异损耗率测试
# Calculate the number of dropouts and completers at each stage
data$dropout_pre_post <- data$pre - data$post
data$dropout_post_follow <- data$post - data$follow
# Create a contingency table for pre to post
# This is a test of attrition from pre to post:
table_pre_post <- matrix(c(data$pre, data$dropout_pre_post), ncol = 2)
# Fisher's Exact Test
fisher.test(table_pre_post)
# And similarly for post to follow-up:
# Create a contingency table for post to follow-up
table_post_follow <- matrix(c(data$post, data$dropout_post_follow), ncol = 2)
# Fisher's Exact Test
fisher.test(table_post_follow)
由于只有三个组和少量,电源可能是一个问题。除非差异非常大,否则这些测试可能无法检测到差异。对 p 值的解释要谨慎,尤其是在样本数量较小的情况下。 如果可能,通过对损耗原因的定性评估来补充这些测试,这可能会为了解损耗是差异性还是选择性差异性提供额外的见解。
对于选择性损耗检验,该检验评估辍学的特征是否与留在研究中的特征不同,您可以使用逻辑回归模型,该模型可用于将辍学概率建模为组和其他相关协变量的函数。
另一种也许更合适的可能性是生存分析,正如德米特里·帕纳诺斯(Demetri Pananos)在对问题的评论中所建议的那样。这可能需要对数据进行重塑,但这是专门为“事件发生时间”数据而设计的,您似乎拥有这些数据。
评论
pre
dropout_pre_post
post
post
to,而不是比较 ,以便行总数等于原始样本量。我取消将其标记为答案,直到得到纠正或澄清。pre
dropout_pre_post
dropout_pre_post
在与统计学家的会议上,还有人建议,可以比较均值并使用 t 检验(或针对小样本的 Mann-Whitney U 检验,其中正态性假设变得难以评估)来比较感兴趣的因变量的辍学和完成者,以评估辍学是否与这些变量的完成者不同。
示例 reprex:
library(report)
# Prepare data
data <- mtcars
names(data)[2] <- "group"
names(data)[9] <- "dropout"
data$group <- as.factor(ifelse(data$group == 4, "Control",
ifelse(data$group == 6, "Treatment1",
"Treatment2")))
data$dropout <- as.factor(data$dropout)
# t test
x <- t.test(data$mpg ~ data$dropout)
report(x)
#> Effect sizes were labelled following Cohen's (1988) recommendations.
#>
#> The Welch Two Sample t-test testing the difference of data$mpg by data$dropout
#> (mean in group 0 = 17.15, mean in group 1 = 24.39) suggests that the effect is
#> negative, statistically significant, and large (difference = -7.24, 95% CI
#> [-11.28, -3.21], t(18.33) = -3.77, p = 0.001; Cohen's d = -1.41, 95% CI [-2.26,
#> -0.53])
# Could also be checked for a specific group, if desired
data_Treatment2 <- data[data$group == "Treatment2", ]
x <- t.test(data_Treatment2$mpg ~ data_Treatment2$dropout)
report(x)
#> Effect sizes were labelled following Cohen's (1988) recommendations.
#>
#> The Welch Two Sample t-test testing the difference of data_Treatment2$mpg by
#> data_Treatment2$dropout (mean in group 0 = 15.05, mean in group 1 = 15.40)
#> suggests that the effect is negative, statistically not significant, and very
#> small (difference = -0.35, 95% CI [-2.34, 1.64], t(10.19) = -0.39, p = 0.704;
#> Cohen's d = -0.17, 95% CI [-1.05, 0.71])
创建于 2023-11-20 with reprex v2.0.2
评论