首页 > 解决方案 > 在 R 中使用 Bonferroni 程序时,LSD 值为空

问题描述

使用 Bonferroni 程序时,我在查找 LSD 的值时遇到问题。它返回NULL,你能帮我吗?非常感谢。

library(agricolae)

# Input the treatments and responses
trt <- c(rep("P", 4), rep("T", 4), rep("S", 4), rep("E", 4), rep("C",4))
response <- c(29.6, 24.3, 28.5, 32, 27.3, 32.6, 30.8, 34.8, 5.8, 6.2, 11, 8.3, 
             21.6, 17.4, 18.3, 19, 29.2, 32.8, 25, 24.2)
trt <- as.factor(trt)

df <- data.frame(trt, response)
model <- aov(response ~ trt, data = df)
out <- LSD.test(model, "trt", p.adj = "bonferroni")
out

# Obtain the LSD value
out$statistics$LSD

在此处输入图像描述

标签: rstatistics

解决方案


不幸的是,它没有很好的记录。你可以检查LSD.test 的代码,你有:

   if (length(nr) == 1 & p.adj == "none") 
        statistics <- data.frame(statistics, t.value = Tprob, 
            LSD = LSD)
    if (length(nr) == 1 & p.adj != "none") 
        statistics <- data.frame(statistics, t.value = Tprob, 
            MSD = LSD)

因此,当您的 p.adjust 不是时"none",它会将列名更改为MSD意味着最小显着差异。您也可以切换到控制台(选项控制台 =TRUE)来查看。


推荐阅读