简体   繁体   English

用于R中重塑数据的3向ANOVA

[英]3-way ANOVA for reshaped data in R

I have just discovered reshaping in R and am unsure of how to proceed with an ANOVA once the data is reshaped. 我刚刚发现在R中进行了重塑,并且不确定一旦数据重塑后如何进行ANOVA。 I found this site which has the data organized in a way very similar to my own data. 我发现这个站点的数据组织方式与我自己的数据非常相似。 If I were using this hypothetical data, how would I conduct a 3-way ANOVA say between race, program and subject? 如果我使用这些假设数据,我该如何在种族,程序和主题之间进行三向方差分析? Now that the subjects have been reshaped into a single column I'm having trouble seeing how to include this variable using the typical ANOVA code. 现在,这些主题已重塑为一列,我很难确定如何使用典型的ANOVA代码来包含此变量。 Any help would be much appreciated! 任何帮助将非常感激!

Assuming the data are in 'long format' and 'score' is your dependent variable you could do something like: 假设数据为“长格式”,并且“分数”是您的因变量,则可以执行以下操作:

mymodel = aov(score ~ prog + race + subj, data=l)
summary(my model)

Which in this case yields: 在这种情况下产生:

Df Sum Sq Mean Sq F value   Pr(>F)    
prog          1   2864    2864   31.32 2.82e-08 ***
race          1   5064    5064   55.39 2.14e-13 ***
subj          4    106      27    0.29    0.885    
Residuals   993  90780      91                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

nb this model contains only the main effects 注意此模型仅包含主要效果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM