比较两个或多个独立配对 t 检验

机器算法验证 方差分析 t检验 重复测量 多重比较 配对数据
2022-03-25 05:38:32
  • 我们可以比较两个或多个独立配对 t 检验的结果吗?

例如:我想测试药物1和药物2是否能有效减肥。我有一个对照组(将服用安慰剂药物),一个用于药物 1 的测试组和另一个用于药物 2 的测试组,它们的大小都相同。

我不想进行方差分析,而是进行三个独立的配对 t 检验,即对每一组进行一个配对 t 检验(测量之前的体重和之后的体重)。假设对于对照组的配对 t 检验,我看到平均体重减轻 0.6 公斤,测试组(药物 1)的平均体重减轻 1.3 公斤,而另一个测试组(药物 2)则有平均体重减轻1.4公斤。

我可以比较三个配对 t 检验的输出吗?从这些独立的测试中,我可以说药物 1 和药物 2 比安慰剂药物更有效吗?

编辑:重复测量方差分析的问题是,如果我添加了一个可变时间t1(之前)和t2(之后),模型会假设t1已经依赖于组。例如,如果我的数据如下所示:

id   drug    t1-weight t2-weight
 1     1        3.4       3.1
 2   placebo    3.8       3.7
 3     2        4.0       3.7
 4   placebo    3.3       3.2
 5     1        4.4       4.4
...   ...       ...       ...
 

方差分析不认为测量的值是t1是否已经受到药物类型的影响?这是一个问题,因为在t1没有一种药物会产生影响,因为该措施是在给药之前进行的。我认为这里唯一的方法是进行配对 t 检验。但是,我该如何比较它们呢?

如果我需要添加另一个变量,例如性别(男性和女性)的变量来检查性别是否也影响治疗,这个问题也会更加复杂?

4个回答

Dunnett 检验是各种处理与对照的单向 ANOVA 的典型检验。与在基线假设下使用 Bonferoni 校正的多个独立 t 检验相比,它的统计功效略高。

请参阅有关 Dunnett 测试的 Wikipedia 条目: https ://en.wikipedia.org/wiki/Dunnett%27s_test

任何优秀的实验设计教科书都会讨论单向方差分析和 Dunnett 检验。请参阅此 STATS 503 课程: https ://online.stat.psu.edu/stat503/lesson/3/3.1

以下是 R 代码中的示例分析:

require(DescTools)
#> Loading required package: DescTools
require(ggplot2)
#> Loading required package: ggplot2

# Simulate Data
set.seed(184873)
NperTreat <- 20
dat <- data.frame(group = factor(rep(c("Control", "Treat1", "Treat2"), each = NperTreat)),
                  t1 = rnorm(3*NperTreat, 74.7, 15.46),
                  t2 = c(rnorm(NperTreat, 74.7, 15.46),
                         rnorm(NperTreat, 74.7 - 2, 15.46),
                         rnorm(NperTreat, 74.7 - 15, 15.46)))
dat$weight_difference <- dat$t2 - dat$t1

ggplot(dat, aes(x = group, y = weight_difference)) + geom_boxplot()

mod1 <- aov(weight_difference ~ group, data = dat)
summary(mod1)
#>             Df Sum Sq Mean Sq F value Pr(>F)  
#> group        2   6043    3022   4.827 0.0116 *
#> Residuals   57  35684     626                 
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# There is at least one difference between the group means p = 0.00116

DescTools::DunnettTest(dat$weight_difference, g = dat$group, control = "Control")
#> 
#>   Dunnett's test for comparing several treatments with a control :  
#>     95% family-wise confidence level
#> 
#> $Control
#>                       diff    lwr.ci    upr.ci   pval    
#> Treat1-Control  -0.9113978 -18.85869 17.035898 0.9903    
#> Treat2-Control -21.7305135 -39.67781 -3.783218 0.0153 *  
#> 
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# there is insufficient evidence to conclude treatment1 is differnt from control p = 0.9903
# treatment 2 is different from control by an estimated 21 kg p = 0.0153

################################################################################

# Two independent t-tests have less power than Dunnett's to detect a difference
#   a test at alpha =  0.05 / 2 is equivalent to a confidence level of 1 - 0.05 / 2

with(dat, t.test(weight_difference[group == "Treat1"], 
                 weight_difference[group == "Control"], 
                 conf.level = 0.975))
#> 
#>  Welch Two Sample t-test
#> 
#> data:  weight_difference[group == "Treat1"] and weight_difference[group == "Control"]
#> t = -0.10537, df = 37.985, p-value = 0.9166
#> alternative hypothesis: true difference in means is not equal to 0
#> 97.5 percent confidence interval:
#>  -21.09656  19.27376
#> sample estimates:
#>  mean of x  mean of y 
#> -1.8206320 -0.9092341
with(dat, t.test(weight_difference[group == "Treat2"], 
                 weight_difference[group == "Control"], 
                 conf.level = 0.975))
#> 
#>  Welch Two Sample t-test
#> 
#> data:  weight_difference[group == "Treat2"] and weight_difference[group == "Control"]
#> t = -2.9104, df = 34.572, p-value = 0.006276
#> alternative hypothesis: true difference in means is not equal to 0
#> 97.5 percent confidence interval:
#>  -39.226556  -4.234471
#> sample estimates:
#>   mean of x   mean of y 
#> -22.6397477  -0.9092341

################################################################################

# with additional co-variates, you can switch to a regression

dat$age <- runif(NperTreat*3, 18, 65)

lm1 <- lm(weight_difference ~ group + age, data = dat)
summary(lm1)
#> 
#> Call:
#> lm(formula = weight_difference ~ group + age, data = dat)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -50.505 -19.415   2.283  16.157  60.701 
#> 
#> Coefficients:
#>              Estimate Std. Error t value Pr(>|t|)   
#> (Intercept)   1.96136   11.56566   0.170  0.86595   
#> groupTreat1  -1.17136    8.02909  -0.146  0.88453   
#> groupTreat2 -21.55551    8.00057  -2.694  0.00929 **
#> age          -0.06888    0.24229  -0.284  0.77723   
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 25.23 on 56 degrees of freedom
#> Multiple R-squared:  0.1461, Adjusted R-squared:  0.1003 
#> F-statistic: 3.193 on 3 and 56 DF,  p-value: 0.03038

# There is at least one significant explanatory variable p = 0.03038
# After accounting for age, there is insufficient evidence to conclude there is a difference due to treatment 1 p = 0.88453
# After accounting for age, there is a significant effect due to Treatment 2 p = 0.00929

使用 t2 和 t1 之间的差异作为特征应该可以工作;可以使用 ANOVA 来检验均值的相等性。

请注意,有一些事后测试可以让您更深入地了解发现的差异(如果有的话)。这使您可以识别哪个意味着偏离。这些事后测试考虑到正在进行多项测试;即包括“Bonferroni 测试”。

如果要将性别添加为第二个变量,也可以使用双向 ANOVA。

您想添加更多变量吗,您可以尝试将测试设置为带有虚拟变量的分层线性回归问题。从具有单一均值的模型开始,并将该模型与具有两个用于实验条件的虚拟变量的模型进行比较,将为您提供所需的答案。可以比较较小和较大的模型,因为模型被认为是分层的;即较大的模型扩展了较小的模型。

对性别使用额外的假人,并为性别 x 治疗的交互效应使用潜在的假人,可以从数据中挤出大量信息。请注意,在这种情况下必须应用一些 Bonferroni 类型校正。人们想预先进行某种功效分析,以查看样本量是否能够承受多次测试而不会失去太多功效。

祝测试愉快!

在这种情况下,您没有理由不能仅将 ANOVA 与标准回归模型一起应用。采用三个单独的 T 检验并将它们组合成一个推论不如使用包含来自所有组的数据的模型进行单个 ANOVA。关于您对 ANOVA 的担忧,请务必注意,ANOVA 是一种分析方法,而不是模型(例如,请参见此处)。它可以应用于线性回归模型,而不管您在模型中包含或排除的特定术语和交互。

使用您的数据进行此类分析的最简单方法是为重量差异形成一个新变量(即,后期的体重减去早期的体重)。您可以轻松地形成一个线性回归模型,将药物作为唯一解释变量,将体重差异作为响应变量。模型公式(以R符号表示)将是:

weight.diff ~ factor(drug)

drug如果您形成这样的模型,那么您可以轻松地应用 ANOVA 来测试变量和变量之间是否存在统计关系weight.diff最好先对所有组进行整体 ANOVA,然后再进行个别测试,并适当考虑多重比较。另请注意,在此类工作中重要的一件事是让您的药物分配随机化,以便您进行随机对照试验 (RCT)。药物分配的随机化以及对照组使用安慰剂应确保您的药物变量在统计上不依赖于任何可能的混杂因素,这使您可以从统计推断中做出因果推断。

是的,您可以比较多个独立的 t 检验,但请注意,这样做会增加犯 I 型错误的可能性。假设一个α0.05,如果在三组之间进行比较,I 类错误的概率为 14.3%。

不要将开始权重和结束权重作为一对进行比较,而是比较两者之间的差异。即,对于每个参与者,从开始减去结束,并在该值上运行方差分析。