本文介绍了如何从R中的重复测量方差分析模型中获得残差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常从aov()
开始使用summary()
函数可以得到残差.
Normally from aov()
you can get residuals after using summary()
function on it.
但是当我使用重复测量方差分析和公式不同时如何获得残差?
But how can I get residuals when I use Repeated measures ANOVA and formula is different?
## as a test, not particularly sensible statistically
npk.aovE <- aov(yield ~ N*P*K + Error(block), npk)
npk.aovE
summary(npk.aovE)
Error: block
Df Sum Sq Mean Sq F value Pr(>F)
N:P:K 1 37.0 37.00 0.483 0.525
Residuals 4 306.3 76.57
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
N 1 189.28 189.28 12.259 0.00437 **
P 1 8.40 8.40 0.544 0.47490
K 1 95.20 95.20 6.166 0.02880 *
N:P 1 21.28 21.28 1.378 0.26317
N:K 1 33.14 33.14 2.146 0.16865
P:K 1 0.48 0.48 0.031 0.86275
Residuals 12 185.29 15.44
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
直观summary(npk.aovE)$residuals
返回NULL
.有人可以帮我吗?
Intuitial summary(npk.aovE)$residuals
return NULL
..Can anyone can help me with this?
推荐答案
很抱歉,我以太快的速度阅读了您的示例.我建议的内容对于带有aov()的多层模型是不可能的.请尝试以下操作:
I apologize I read your example way too quickly. What I suggested is not possible with multilevel models with aov(). Try the following:
> npk.pr <- proj(npk.aovE)
> npk.pr[[3]][, "Residuals"]
这是一个更简单的可复制性,如果遇到相同的问题,任何人都可以弄乱:
Here's a simpler reproducible anyone can mess around with if they run into the same issue:
x1 <- gl(8, 4)
block <- gl(2, 16)
y <- as.numeric(x1) + rnorm(length(x1))
d <- data.frame(block, x1, y)
m <- aov(y ~ x1 + Error(block), d)
m.pr <- proj(m)
m.pr[[3]][, "Residuals"]
这篇关于如何从R中的重复测量方差分析模型中获得残差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!