我正在使用Morley数据。我正在做随机块实验,以Run为处理因子,Expt为阻断因子。我需要确定Run之间是否有差异,阻断能获得什么效率。
我用来解决这个问题的代码是。
library(multcomp)
library(faraway)
data(morley)
treatment = morley$Run
blocking = morley$Expt
modelfit = lm(Speed~treatment+blocking, morley)
summary(modelfit)
anova(modelfit)
TukeyHSD(aov(Speed~treatment+factor(blocking), factory(morley))$treatment
我遇到的问题是TukeyHSD函数的问题。它给了我这个错误。
"Error: Incomplete expression: 不完整的表达式。 TukeyHSD(aov(Speed~treatment+factor(blocking), factory(morley))$treatment"
我不知道如何解决这个问题,因为我过去也用过类似的方法,而且很有效。任何帮助将是巨大的,谢谢
在你的代码中,变量速度没有被调用到数据集中。
Speed = morley$Speed
你是为了这个而努力吗?
> TukeyHSD(aov(Speed~treatment+factor(blocking)))
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = Speed ~ treatment + factor(blocking))
$`factor(blocking)`
diff lwr upr p adj
2-1 -53.0 -118.61406 12.614058 0.1719005
3-1 -64.0 -129.61406 1.614058 0.0595018
4-1 -88.5 -154.11406 -22.885942 0.0027517
5-1 -77.5 -143.11406 -11.885942 0.0121938
3-2 -11.0 -76.61406 54.614058 0.9901489
4-2 -35.5 -101.11406 30.114058 0.5619434
5-2 -24.5 -90.11406 41.114058 0.8367799
4-3 -24.5 -90.11406 41.114058 0.8367799
5-3 -13.5 -79.11406 52.114058 0.9787898
5-4 11.0 -54.61406 76.614058 0.9901489