在 R 中配对方差分析的两个因素
Pair two factors for ANOVA in R
我有一些来自两种不同病症(癌症和正常)的菌落计数数据,这些病症使用两种药物联合治疗:A(3 个水平)和 B(2 个水平)。对于菌落,我有不同的类型+总数,但我可以在不同的测试中查看不同的类型。
df <- data.frame( Patient = rep( 1:6, 6), Disease = rep( c( "cancer", "normal"), 18), DrugA = c( rep( 0, 12), rep( 30, 12), rep( 100, 12)), DrugB = rep( c( rep( 0, 6), rep( 2, 6)), 3), n.colonies = sample( 10:300, size = 36) )
head(df)
我的问题是我想比较两种情况(癌症和正常)之间每种治疗(药物 A 和药物 B 的组合)的差异。为此,我做了以下工作:
df$treatment.factor <- paste( df$DrugA, df$DrugB, sep = ".")
library(stats)
a <- aov( formula = n.colonies ~ Disease:treatment.factor, data = df)
summary(a)
TukeyHSD(a)
结果returns 所有可能的组合,包括同一条件下的不同治疗方案。我有什么办法可以将测试组限制为仅针对不同疾病的相同 treatment.factor?我正在考虑只做感兴趣的 t 检验并纠正多重比较,但它对我来说似乎并不完全正确。我也在考虑对每个条件(根据 DrugB 分开)进行回归,但只有 3 个点(DrugA 的三种浓度)也无济于事。
有什么建议吗?谢谢!
爱德华多
我不太清楚。也许你想要:
library(lsmeans)
lsmeans(a, pairwise ~ Disease:treatment.factor | treatment.factor)
$contrasts
treatment.factor = 0.0:
contrast estimate SE df t.ratio p.value
cancer - normal -101.333333 74.31826 24 -1.364 0.1854
treatment.factor = 0.2:
contrast estimate SE df t.ratio p.value
cancer - normal -92.333333 74.31826 24 -1.242 0.2261
treatment.factor = 100.0:
contrast estimate SE df t.ratio p.value
cancer - normal 50.666667 74.31826 24 0.682 0.5019
treatment.factor = 100.2:
contrast estimate SE df t.ratio p.value
cancer - normal 1.666667 74.31826 24 0.022 0.9823
treatment.factor = 30.0:
contrast estimate SE df t.ratio p.value
cancer - normal 9.000000 74.31826 24 0.121 0.9046
treatment.factor = 30.2:
contrast estimate SE df t.ratio p.value
cancer - normal 79.333333 74.31826 24 1.067 0.2964
我有一些来自两种不同病症(癌症和正常)的菌落计数数据,这些病症使用两种药物联合治疗:A(3 个水平)和 B(2 个水平)。对于菌落,我有不同的类型+总数,但我可以在不同的测试中查看不同的类型。
df <- data.frame( Patient = rep( 1:6, 6), Disease = rep( c( "cancer", "normal"), 18), DrugA = c( rep( 0, 12), rep( 30, 12), rep( 100, 12)), DrugB = rep( c( rep( 0, 6), rep( 2, 6)), 3), n.colonies = sample( 10:300, size = 36) )
head(df)
我的问题是我想比较两种情况(癌症和正常)之间每种治疗(药物 A 和药物 B 的组合)的差异。为此,我做了以下工作:
df$treatment.factor <- paste( df$DrugA, df$DrugB, sep = ".")
library(stats)
a <- aov( formula = n.colonies ~ Disease:treatment.factor, data = df)
summary(a)
TukeyHSD(a)
结果returns 所有可能的组合,包括同一条件下的不同治疗方案。我有什么办法可以将测试组限制为仅针对不同疾病的相同 treatment.factor?我正在考虑只做感兴趣的 t 检验并纠正多重比较,但它对我来说似乎并不完全正确。我也在考虑对每个条件(根据 DrugB 分开)进行回归,但只有 3 个点(DrugA 的三种浓度)也无济于事。
有什么建议吗?谢谢!
爱德华多
我不太清楚。也许你想要:
library(lsmeans)
lsmeans(a, pairwise ~ Disease:treatment.factor | treatment.factor)
$contrasts
treatment.factor = 0.0:
contrast estimate SE df t.ratio p.value
cancer - normal -101.333333 74.31826 24 -1.364 0.1854
treatment.factor = 0.2:
contrast estimate SE df t.ratio p.value
cancer - normal -92.333333 74.31826 24 -1.242 0.2261
treatment.factor = 100.0:
contrast estimate SE df t.ratio p.value
cancer - normal 50.666667 74.31826 24 0.682 0.5019
treatment.factor = 100.2:
contrast estimate SE df t.ratio p.value
cancer - normal 1.666667 74.31826 24 0.022 0.9823
treatment.factor = 30.0:
contrast estimate SE df t.ratio p.value
cancer - normal 9.000000 74.31826 24 0.121 0.9046
treatment.factor = 30.2:
contrast estimate SE df t.ratio p.value
cancer - normal 79.333333 74.31826 24 1.067 0.2964