【问题标题】:N - way ANOVA in RR中的N-way ANOVA
【发布时间】:2017-07-18 18:51:32
【问题描述】:

我正在对拉丁方格实验进行 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 不合作以及如何解决吗?

【问题讨论】:

    标签: r statistics anova experimental-design


    【解决方案1】:

    这只是因为“批次”和“成分”的组合相同(如果批次=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 函数中引用了数据框。

    【讨论】:

    • 非常感谢!我没有意识到我以那种模式输入了成分信息。这解决了我的问题
    猜你喜欢
    • 1970-01-01
    • 2021-06-28
    • 2012-09-22
    • 2021-07-04
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多