2

I have a problem in finding the value of LSD when using the Bonferroni's procedure. It returns NULL and could you please help me with it? Thanks so much.

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

enter image description here

JayPeerachai
  • 3,499
  • 3
  • 14
  • 29
Fox_Summer
  • 149
  • 6
  • Fun fact: `rep(c("P", "T", "S", "E", "C"), each=4)` is a simpler way to make `trt` – DanY Sep 23 '20 at 22:53
  • Run `str(out)` and you'll see that you get a `NULL` because `out$statistics$LSD` is not an element of `out`. It appears that `LSD` is not a statistic provided by `agricolae::LSD.test()`. – DanY Sep 23 '20 at 22:58

1 Answers1

2

Unfortunately it's not very well-documented. You can check the code for LSD.test, and there you have:

   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)

So when your p.adjust is not "none", it changes the column name to MSD which means minimum significant difference. You can also switch to console (option console =TRUE) to see this.

StupidWolf
  • 45,075
  • 17
  • 40
  • 72