对 R 进行 Tukey 测试
conducting a Tukey test on R
我正在尝试对数据 (bmt)、(KMsurv) 进行 Tukey 测试,并仅关注变量 t2 和 d3。
t2:无病生存时间(至复发、死亡或研究结束的时间)
d3:无病指标变量。 d3 = 1 如果死亡或复发,或 d3 = 0 如果活着或无病。
可以使用 KMsurv 包获取数据。患者已分为风险类别或组,由数据集中的变量 g 表示。
g = 1; ALL (acute lymphoblastic leukemia) 38 patients
g = 2; AML low risk (acute myeloctic leukemia) 54 patients
g = 3; AML high risk (acute myeloctic leukemia) 45 patients
library(KMsurv)
data(bmt)
bmt
library(survival)
# run the ANOVA and print out the ANOVA table:
anova1 <- aov( group ~ t2+d3, data = bmt )
summary(anova1)
TukeyHSD(anova1)
但是出现错误信息
Error in TukeyHSD.aov(anova1) :no factors in the fitted model In addition: Warning messages: 1: In replications(paste("~", xx), data = mf) : non-factors ignored: t2 2: In replications(paste("~", xx), data = mf) : non-factors ignored: d3
我已经安装了包 multcomp
但我不确定是否需要这个包。
我该如何修复该错误?
我认为没有必要在这里进行方差分析,因为您的结果是无复发生存。如果你真的想,然后做一个 Tukey 测试,那么命令将是:
anova1 <- aov(t2 ~ factor(group), data = bmt)
summary(anova1)
Df Sum Sq Mean Sq F value Pr(>F)
factor(group) 2 7186442 3593221 7.115 0.00116 **
Residuals 134 67675770 505043
TukeyHSD(anova1)
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = t2 ~ factor(group), data = bmt)
$`factor(group)`
diff lwr upr p adj
2-1 456.35673 99.72036 812.9931 0.0081370
3-1 -22.13216 -393.20690 348.9426 0.9890452
3-2 -478.48889 -818.45440 -138.5234 0.0031404
但这忽略了事件(变量 d3),所以我不会太在意结果。
我正在尝试对数据 (bmt)、(KMsurv) 进行 Tukey 测试,并仅关注变量 t2 和 d3。 t2:无病生存时间(至复发、死亡或研究结束的时间) d3:无病指标变量。 d3 = 1 如果死亡或复发,或 d3 = 0 如果活着或无病。 可以使用 KMsurv 包获取数据。患者已分为风险类别或组,由数据集中的变量 g 表示。
g = 1; ALL (acute lymphoblastic leukemia) 38 patients
g = 2; AML low risk (acute myeloctic leukemia) 54 patients
g = 3; AML high risk (acute myeloctic leukemia) 45 patients
library(KMsurv)
data(bmt)
bmt
library(survival)
# run the ANOVA and print out the ANOVA table:
anova1 <- aov( group ~ t2+d3, data = bmt )
summary(anova1)
TukeyHSD(anova1)
但是出现错误信息
Error in TukeyHSD.aov(anova1) :no factors in the fitted model In addition: Warning messages: 1: In replications(paste("~", xx), data = mf) : non-factors ignored: t2 2: In replications(paste("~", xx), data = mf) : non-factors ignored: d3
我已经安装了包 multcomp
但我不确定是否需要这个包。
我该如何修复该错误?
我认为没有必要在这里进行方差分析,因为您的结果是无复发生存。如果你真的想,然后做一个 Tukey 测试,那么命令将是:
anova1 <- aov(t2 ~ factor(group), data = bmt)
summary(anova1)
Df Sum Sq Mean Sq F value Pr(>F)
factor(group) 2 7186442 3593221 7.115 0.00116 **
Residuals 134 67675770 505043
TukeyHSD(anova1)
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = t2 ~ factor(group), data = bmt)
$`factor(group)`
diff lwr upr p adj
2-1 456.35673 99.72036 812.9931 0.0081370
3-1 -22.13216 -393.20690 348.9426 0.9890452
3-2 -478.48889 -818.45440 -138.5234 0.0031404
但这忽略了事件(变量 d3),所以我不会太在意结果。