ggplot2与ezANOVA的残差 [英] ggplot2 residuals with ezANOVA
问题描述
anova_1< -ezANOVA(data = main_data,dv =。(rt),wid。(id),
(A,B,C),type = 3,detailed = TRUE)
'I'我试图通过qqplot来查看残差是怎么回事,但我不知道如何去找他们,或者他们是否在那里。使用我的lme模型,我只需将它们从模型中提取出来
main_data $ model_residuals< - as.numeric(residuals(model_1))
并绘制它们
residuals_qq <-ggplot(main_data,aes(sample = main_data $ model_residuals))+
stat_qq(color =black,alpha = 1,size = 2)+
geom_abline( intercept = mean(main_data $ model_residuals),slope = sd(main_data $ model_residuals))
我会喜欢使用ggplot,因为我想保持图形的一致性。
编辑
也许我不清楚我在做什么。使用lme模型,我可以简单地从 main_data data.frame
中的残差对象创建变量 model_residuals
,然后包含我在ggplot中绘制的残差。我想知道,如果ezAnova中的残差可能类似,或者我可以获得方差分析的残差。
我和ezanova有同样的问题。我选择的解决方案是切换到 ez.glm
(从 afex
包)。 ezANOVA
和 ez.glm
从一个不同的包装中包装一个函数,所以你应该得到相同的结果。
这看起来就像你的例子:
anova_1< -ez.glm(id,rt ,main_data,within = c(A,B,C),return =full)
nice.anova(anova_1 $ Anova)#显示类似于ezANOVA的ANOVA表。
然后,您可以按照常规方式拉出lm对象并获取残差:
残差(anova_1 $ lm)
希望有所帮助。
编辑:与上一版本一起工作
anova_1< -aov_ez(id,rt,main_data,within = c(A (m1)
print(m1 $ anova)
summary(m1 $ Anova)
summary(m1)
然后,您可以用常规方式拉出lm对象并获取残差:
残差(anova_1 $ lm)
I ran a three way repeated measures ANOVA with ezANOVA.
anova_1<-ezANOVA(data = main_data, dv = .(rt), wid.(id),
within = .(A,B,C), type = 3, detailed = TRUE)
I'm trying to see what's going on with the residuals via a qqplot but I don't know how to get to them or if they'r even there. With my lme models I simply extract them from the model
main_data$model_residuals <- as.numeric(residuals(model_1))
and plot them
residuals_qq<-ggplot(main_data, aes(sample = main_data$model_residuals)) +
stat_qq(color="black", alpha=1, size =2) +
geom_abline(intercept = mean(main_data$model_residuals), slope = sd(main_data$model_residuals))
I'd like to use ggplot since I'd like to keep a sense of consistency in my graphing.
EDIT
Maybe I wasn't clear in what I'm trying to do. With lme models I can simply create the variable model_residuals
from the residuals object in the main_data data.frame
that then contains the residuals I plot in ggplot. I want to know if something similar is possible for the residuals in ezAnova or if there is a way I can get hold of the residuals for my ANOVA.
I had the same trouble with ezANOVA. The solution I went for was to switch to ez.glm
(from the afex
package). Both ezANOVA
and ez.glm
wrap a function from a different package, so you should get the same results.
This would look like this for your example:
anova_1<-ez.glm("id", "rt", main_data, within=c("A","B","C"), return="full")
nice.anova(anova_1$Anova) # show the ANOVA table like ezANOVA does.
Then you can pull out the lm object and get your residuals in the usual way:
residuals(anova_1$lm)
Hope that helps.
Edit: A few changes to make it work with the last version
anova_1<-aov_ez("id", "rt", main_data, within=c("A","B","C"))
print(m1)
print(m1$Anova)
summary(m1$Anova)
summary(m1)
Then you can pull out the lm object and get your residuals in the usual way:
residuals(anova_1$lm)
这篇关于ggplot2与ezANOVA的残差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!