本文介绍了如何使用不相等的样本量在R中进行单向方差分析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试学习R.一个来自旧统计数据的问题想知道不同施工现场的休息时间是否有所不同.麻烦的是,案文决定每个站点雇用不同数量的工人.因此,我陷入困境并寻求使用样本量不相等的ANOVA的帮助.
Trying to learn R. A question from an old stats text want's to know if there is a difference in break times at different construction sites. Trouble is, the text decided that each site employs a different number of workers. So, I am stuck and looking for help using ANOVA with unequal sample sizes.
site1 <- c(34,25,27,31,26,34,21)
site2 <- c(33,35,31,31,42,33)
site3 <- c(17,30,30,26,32,28,26,29)
site4 <- c(28,33,31,27,32,33,40)
推荐答案
尝试这个
site1 <- c(34,25,27,31,26,34,21)
site2 <- c(33,35,31,31,42,33)
site3 <- c(17,30,30,26,32,28,26,29)
site4 <- c(28,33,31,27,32,33,40)
Data <- data.frame(
Y=c(site1, site2, site3, site4),
Site =factor(rep(c("site1", "site2", "site3", "site4"), times=c(length(site1), length(site2), length(site3), length(site4))))
)
数据
Y Site
34 site1
25 site1
27 site1
31 site1
26 site1
34 site1
21 site1
33 site2
35 site2
31 site2
31 site2
42 site2
33 site2
17 site3
30 site3
30 site3
26 site3
32 site3
28 site3
26 site3
29 site3
28 site4
33 site4
31 site4
27 site4
32 site4
33 site4
40 site4
方差分析
fm1 <- aov(Y~Site, data=Data)
anova(fm1)
输出
Analysis of Variance Table
Response: Y
Df Sum Sq Mean Sq F value Pr(>F)
Site 3 212.35 70.782 3.4971 0.03098 *
Residuals 24 485.76 20.240
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
这篇关于如何使用不相等的样本量在R中进行单向方差分析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!