使用LSD.test(agricolae)计算不相等的组观察值的最小显着差异

时间:2019-08-07 06:42:15

标签: r anova tukey

我正在尝试对数据集执行LSD.test中的示例。不幸的是,我的数据集样本大小不相等,我读到可以用加权均值来处理。有人对此有经验吗?有没有一种方法可以在函数外部进行计算?

这是我的示例代码:

library(agricolae)

data <- as.data.frame(c(rep("A", 10), rep("B", 10), rep("C", 10), rep("D", 11)))
data$Value <- c(59.15,48.90,29.65,32.60,63.85,53.85,66.40,55.05,54.75,39.95,63.20,57.40,59.15,54.10,49.40,78.70,66.20,90.75,
                81.20,52.25,53.70,51.10,48.60,50.15,63.40,56.15,38.40,66.45,53.35,45.30,46.60,53.20,53.95,44.55,49.15,42.65,
                68.25,67.60,57.90,47.85,52.90)
colnames(data) <- c("Treatment", "Value")

cal <- lm(Value ~ Treatment, data = data)

model<-aov(cal)

out <- LSD.test(model,"Treatment", p.adj="bonferroni")
#stargraph
# Variation range: max and min
plot(out)
#endgraph
# Old version LSD.test()
df<-df.residual(model)
MSerror<-deviance(model)/df
out <- with(data,LSD.test(Value,Treatment,df,MSerror))
#stargraph
# Variation interquartil range: Q75 and Q25
plot(out,variation="IQR")
#endgraph
out<-LSD.test(model,"Treatment",p.adj="hommel",console=TRUE)
plot(out,variation="SD") # variation standard deviation

这仍然是“有效的”,但是没有像典型示例中那样列出“最小显着差异”:

library(agricolae)
data(sweetpotato)
model<-aov(yield~virus, data=sweetpotato)
out <- LSD.test(model,"virus", p.adj="bonferroni")
#stargraph
# Variation range: max and min
plot(out)
#endgraph
# Old version LSD.test()
df<-df.residual(model)
MSerror<-deviance(model)/df
out <- with(sweetpotato,LSD.test(yield,virus,df,MSerror))
#stargraph
# Variation interquartil range: Q75 and Q25
plot(out,variation="IQR")
#endgraph
out<-LSD.test(model,"virus",p.adj="hommel",console=TRUE)
plot(out,variation="SD") # variation standard deviation

编辑1:我也尝试过将不平等的组与具有农用食品的HSD一起使用,但这会返回错误:

data(sweetpotato)
A<-sweetpotato[-c(4,5,7),]
modelUnbalanced <- aov(yield ~ virus, data=A)
outUn <-HSD.test(modelUnbalanced, "virus",group=FALSE, unbalanced = TRUE)

HSD.test中的错误(modelUnbalanced,“病毒”,组= FALSE,unbalanced = TRUE):   未使用的参数(unbalanced = TRUE)

编辑2:我现在已经使用group = FALSE命令来查找各个交互:

      difference pvalue signif.        LCL        UCL
A - B -14.820000 0.0301       * -28.664094 -0.9759055
A - C  -2.245000 1.0000         -16.089094 11.5990945
A - D  -3.557727 1.0000         -17.083524  9.9680696
B - C  12.575000 0.0943       .  -1.269094 26.4190945
B - D  11.262273 0.1554          -2.263524 24.7880696
C - D  -1.312727 1.0000         -14.838524 12.2130696

现在我将如何找到差异= p = 0.05?我看了三个不等于1的p值与差的平方根之间的线性关系。这种关系并不完美,但R2 = 0.98很强,可能是样本量的影响。

enter image description here

我可以用它来预测@ p = 0.05的最小差异是多少?还是我完全被误导了?

非常感谢您的帮助!

干杯

0 个答案:

没有答案