R IN ACTION SELF-TUTORIAL-71 R 进

2021-10-10  本文已影响0人  RashidinAbdu

  1. 方差分析(ANOVA)用于确定三个或更多独立组的平均值之间是否存在统计显著性差异。例如,假设我们想知道学习技术是否对一个班级的学生的考试成绩有影响。我们随机把全班分成三组。每组使用一个月的不同学习方法来准备考试。在月底,所有的学生都参加同样的考试。为了找出学习技巧是否会影响考试成绩,我们可以进行单向方差分析,这将告诉我们三组的平均成绩之间是否存在统计上的显著差异。


    image.png

  1. 在方差分析中,我们有一个响应变量。然而,在MANOVA(多元方差分析)中,我们有多个响应变量。


1) 数据:

Isobutyric acid Pentanoic acid  Isovaleric acid Name
0.3 2.829378839 0.3 Agathobacter
0.3 6.004179503 0   Ruminococcus
8.331295827 11.88198431 33.20889143 Ruminococcus
0.951198899 11.73258091 28.63164961 Ruminococcus
0.3 0   0   Ruminococcus
2.050382466 10.07822753 0   Mediterraneibacter
0   0   0   Mediterraneibacter
3.513720564 11.19639518 0   Mediterraneibacter
0.214560437 8.206513644 0   Mediterraneibacter


  1. 运行:
# 参考:https://www.statology.org/manova-in-r/
# 读取数据 ,第一行没有放列名
SCFA1<-read.delim("clipboard",
                  header = FALSE, 
                  check.names = FALSE)
head(SCFA1)

#fit the MANOVA model选择模型
model <- manova(cbind(Isobutyric acid,Pentanoic acid, Isovaleric acid) ~ Name, data = SCFA1)
#view the results
summary(model, test='Wilks')
#we can perform univariate ANOVAs using summary.aov() 
summary.aov(model)
#load gplots library
#install.packages('gplots')
library(gplots)
#visualize mean sepal length by species
#绘图
p1<-plotmeans((SCFA1$`Propanoic acid`) ~ SCFA1$`Name`)
p1<-

p2<-plotmeans((SCFA1$`Isobutyric acid`) ~ SCFA1$`Name`)
p2

p3<-plotmeans((SCFA1$`Isovaleric acid`) ~ SCFA1$`Name`)
p3

得到:


image.png image.png image.png
上一篇下一篇

猜你喜欢

热点阅读