【问题标题】:How to test AOV assumptions - error in plot如何测试 AOV 假设 - 图中的错误
【发布时间】:2014-02-26 12:33:14
【问题描述】:

我正在尝试通过使用函数plot 绘制残差来测试 AOV 假设。我想测试细菌密度是否受温度和我的治疗影响。我使用了aov 函数并考虑了处理和温度之间的相互作用。此外,我的实验设计是分块进行的。当我使用plot 时出现错误:

Error in xy.coords(x, y, xlabel, ylabel, log) :
 'x' is a list, but does not have components 'x' and 'y'

## I've run the example in ?aov
npk.aov <- aov(yield ~ block + N*P*K, npk)
plot(npl.aov)

这个例子有效。这两个数据都在data.frame 中。唯一的区别是我的自变量是因素。但据我所知,aov 不是问题。

你能帮我解决这个错误吗?

这是一个玩具示例:

block <- rep(1:7, 6)
temp <- rep(c("a", "b"), c(21, 21))
treat <- rep(rep(c("T1", "T2", "T3"), c(7, 7, 7)), 2)
density <- rnorm(42)
dat <- data.frame(block, temp, treat, density)
mod <- aov(density ~ temp*treat+Error(block/treat), data=dat)# modelo certo
plot(mod)

会话详情:

platform
"x86_64-w64-mingw32"
"R version 3.0.2 (2013-09-25)"
$nickname
"Frisbee Sailing"`

【问题讨论】:

  • 我没有看到你在aov中提到的例子。
  • ## 我已经在 ?aov npk.aov PK, npk) plot(npl.aov)
  • 温度是一个连续变量。我认为你应该适合混合效果模型(例如,看看包 lme4)。
  • 谢谢@Roland。但在我的实验中,温度被控制为“自然条件”(~25°)或“温暖条件”(~29°)。这就是我在玩具示例中创建临时“a”和“b”的原因。

标签: r


【解决方案1】:

我认为您对模型“内部”部分的残差感兴趣:

plot(residuals(mod[["Within"]])~fitted(mod[["Within"]]))

qqnorm(residuals(mod[["Within"]]))
qqline(residuals(mod[["Within"]]))

【讨论】:

  • 非常感谢@Roland
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-10-17
  • 2021-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-03
  • 2019-11-22
相关资源
最近更新 更多