我在数据框沙丘(页面底部下方)中有三列,描述了三种不同沙丘生态系统记录的马拉姆草覆盖率:
(一)恢复;(2) 退化的;(3) 自然的;
我进行了两种不同的单向方差分析测试(如下)——测试 1 和测试 2——以确定生态系统之间的显着差异。测试 1 清楚地显示了生态系统之间的显着差异;但是,测试 2 显示没有显着差异。箱线图(下图)显示了生态系统之间差异的明显差异。
之后,我融合数据框以生成一个阶乘列(即,以 Ecosystem.Type 为标题),它也是响应变量。这个想法是应用 glm 模型(下面的测试 3)来使用 One Way Anova 进行测试;但是,此方法不成功(请在下面查找错误消息)。
问题
我很困惑我执行每个 One Way Anova 测试的代码是否正确,以及执行事后测试(土耳其 HSD、Scheffe 或其他)以区分显着不同的生态系统对的正确程序。如果有人可以提供帮助,我将非常感谢您的建议。非常感谢....
data(dune)
测试 1
dune.type.1<-aov(Natural~Restored+Degraded, data=dune)
summary.aov(dune.type.1, intercept=T)
Df Sum Sq Mean Sq F value Pr(>F)
(Intercept) 1 34694 34694 138.679 1.34e-09 ***
Restored 1 94 94 0.375 0.548
Degraded 1 486 486 1.942 0.181
Residuals 17 4253 250
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
事后测试
posthoc<-TukeyHSD(dune.type.1, conf.level=0.95)
Error in TukeyHSD.aov(dune.type.1, conf.level = 0.95) :
no factors in the fitted model
In addition: Warning messages:
1: In replications(paste("~", xx), data = mf) :
non-factors ignored: Restored
2: In replications(paste("~", xx), data = mf) :
non-factors ignored: Degraded
测试 2
dune1<-aov(Restored~Natural, data=dune)
dune2<-aov(Restored~Degraded, data=dune)
dune3<-aov(Degraded~Natural, data=dune)
summary(dune1)
Df Sum Sq Mean Sq F value Pr(>F)
Natural 1 86 85.58 0.356 0.558
Residuals 18 4325 240.26
summary(dune2)
Df Sum Sq Mean Sq F value Pr(>F)
Degraded 1 160 159.7 0.676 0.422
Residuals 18 4250 236.1
summary(dune3)
Df Sum Sq Mean Sq F value Pr(>F)
Natural 1 168.5 168.49 2.318 0.145
Residuals 18 1308.5 72.69
测试 3
melt.dune<-melt(dune, measure.vars=c("Degraded", "Restored", "Natural"))
colnames(melt.dune)=c("Ecosystem.Type", "Percentage.cover")
melt.dune$Percentage.cover<-as.numeric(melt.dune$Percentage.cover)
glm.dune<-glm(Ecosystem.Type~Percentage.cover, data=melt.dune)
summary(glm.dune)
Error
glm.dune<-glm(Ecosystem.Type~Percentage.cover, data=melt.dune)
Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, :
NA/NaN/Inf in 'y'
In addition: Warning messages:
1: In Ops.factor(y, mu) : ‘-’ not meaningful for factors
2: In Ops.factor(eta, offset) : ‘-’ not meaningful for factors
3: In Ops.factor(y, mu) : ‘-’ not meaningful for factors
融化的数据框
structure(list(Ecosystem.Type = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Degraded", "Restored",
"Natural"), class = "factor"), Percentage.cover = c(12, 17, 21,
11, 22, 16, 7, 9, 14, 2, 3, 15, 23, 4, 19, 36, 26, 4, 15, 23,
38, 46, 65, 35, 54, 29, 48, 13, 19, 33, 37, 55, 11, 53, 13, 24,
28, 44, 42, 39, 18, 61, 31, 46, 51, 51, 41, 44, 55, 47, 73, 43,
25, 42, 21, 13, 65, 30, 47, 29)), row.names = c(NA, -60L), .Names = c("Ecosystem.Type",
"Percentage.cover"), class = "data.frame")
数据
structure(list(Degraded = c(12L, 17L, 21L, 11L, 22L, 16L, 7L,
9L, 14L, 2L, 3L, 15L, 23L, 4L, 19L, 36L, 26L, 4L, 15L, 23L),
Restored = c(38L, 46L, 65L, 35L, 54L, 29L, 48L, 13L, 19L,
33L, 37L, 55L, 11L, 53L, 13L, 24L, 28L, 44L, 42L, 39L), Natural = c(18L,
61L, 31L, 46L, 51L, 51L, 41L, 44L, 55L, 47L, 73L, 43L, 25L,
42L, 21L, 13L, 65L, 30L, 47L, 29L)), .Names = c("Degraded",
"Restored", "Natural"), class = "data.frame", row.names = c(NA,
-20L))