0

我正在对拉丁方格实验进行 ANOVA 测试。出于某种原因,aov() 函数只能识别所使用的 3 个变量中的 2 个。

batch = c(1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5)
day = c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5)
ingredient = c('A','B','C','D','E','A','B','C','D','E','A','B','C','D','E','A','B','C','D','E','A','B','C','D','E')
rxn.time = c(8,11,4,6,4,7,2,9,8,2,1,7,10,6,3,7,3,1,6,8,3,8,5,10,8)
rxn.exp = data.frame(batch, day, ingredient, rxn.time)
test.10 = aov(rxn.exp$rxn.time~as.factor(rxn.exp$batch)+as.factor(rxn.exp$day)+as.factor(ingredient))
summary(test.10)

汇总仅针对前 2 个因子生成输出。我已经尝试仅使用 factor() 函数而不是 as.factor 以及其他几次尝试让 R 根据需要运行测试,其中包含 3 个不同的变化源以及任何噪声。有人可以解释为什么 R 不合作以及如何解决吗?

4

1 回答 1

0

只是因为“批次”和“成分”的组合是相同的(如果批次=1,成分=A,等等)。如果您使用随机成分,它会起作用。例如:

ingredient = LETTERS[sample(1:5, size= length(batch), replace=T)]
rxn.exp = data.frame(batch=as.factor(batch), day=as.factor(day), ingredient=as.factor(ingredient), rxn.time=rxn.time)
test.10 = lm(rxn.time~batch+day+ingredient, data=rxn.exp)
summary(test.10)

另请注意,我指的是 lm 函数中的数据框。

于 2017-02-28T01:45:36.377 回答