2016-11-21 60 views
0

我有7个组我想运行方差分析测试,以查看彼此之间是否存在基于特征的显着差异。我有大约600个特征。 我已经计算了每组和每个特征的均值,标准差和方差。七个小组有不同的样本量。如何安排我的数据,以便我能够在R中运行它们?在r中运行多个anova测试

回答

1
set.seed(2) 

sampledata <- expand.grid(group = paste0("group", 1:7), trait = paste0("trait", 1:600), value = 1:5) 
sampledata$value <- rnorm(nrow(sampledata)) 

sampledata.aov <- aov(value ~ group * trait, data = sampledata) 
anova(sampledata.aov) 

Analysis of Variance Table 

Response: value 
       Df Sum Sq Mean Sq F value Pr(>F) 
group   6  7.1 1.1784 1.1670 0.32072 
trait   599 658.0 1.0985 1.0878 0.07096 . 
group:trait 3594 3613.0 1.0053 0.9955 0.56604 
Residuals 16800 16964.3 1.0098     
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

即使有随机数,也会发出警告,当你一次拥有这么多特性时,你更有可能没有显着差异。