Trouble running LSD post hoc test in R

Hello,

Can someone please help me run LSD test on my data?
Here is my data:

squads <-tibble::tribble(
           ~score, ~treatment,
                6,     "st 1",
                7,     "st 1",
                4,     "st 1",
                5,     "st 1",
                6,     "st 1",
                5,     "st 1",
                5,     "st 1",
                2,      "st2",
                2,      "st2",
                1,      "st2",
              1.5,      "st2",
              2.5,      "st2",
                2,      "st2",
                4,      "st2",
                5,      "st3",
                4,      "st3",
                5,      "st3",
                6,      "st3",
                7,      "st3",
                5,      "st3",
                5,      "st3"
           )
head(squads)
#> # A tibble: 6 x 2
#>   score treatment
#>   <dbl> <chr>    
#> 1     6 st 1     
#> 2     7 st 1     
#> 3     4 st 1     
#> 4     5 st 1     
#> 5     6 st 1     
#> 6     5 st 1

Created on 2020-12-03 by the reprex package (v0.3.0)

Here is my code:

df <- read.csv("F:/Complete_Projects/LSD_test.csv", stringsAsFactors = F)
colnames(df)[1] = "score"
colnames(df)[2] = "treatment"
res.aov <- aov(score ~ treatment, data = df)
summary(res.aov)
#>             Df Sum Sq Mean Sq F value   Pr(>F)    
#> treatment    2  48.29  24.143   26.34 4.51e-06 ***
#> Residuals   18  16.50   0.917                     
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(DescTools)
#> Warning: package 'DescTools' was built under R version 4.0.3
#> Error: package or namespace load failed for 'DescTools' in library.dynam(lib, package, package.lib):
#>  DLL 'rootSolve' not found: maybe not installed for this architecture?
library(multcomp)
#> Warning: package 'multcomp' was built under R version 4.0.3
#> Loading required package: mvtnorm
#> Loading required package: survival
#> Loading required package: TH.data
#> Warning: package 'TH.data' was built under R version 4.0.2
#> Loading required package: MASS
#> 
#> Attaching package: 'TH.data'
#> The following object is masked from 'package:MASS':
#> 
#>     geyser
#> Warning in get(Info[i, 1], envir = env): internal error -3 in R_decompress1
#> Error: package or namespace load failed for 'multcomp' in get(Info[i, 1], envir = env):
#>  lazy-load database 'C:/Users/chetan/Documents/R/win-library/4.0/sandwich/R/sandwich.rdb' is corrupt
PostHocTest(aov(score ~ treatment, data = df), method = "lsd")
#> Error in PostHocTest(aov(score ~ treatment, data = df), method = "lsd"): could not find function "PostHocTest"

Created on 2020-12-03 by the reprex package (v0.3.0)

Hi @sharmachetan,
Those errors you are seeing suggest that you are running an old version of R that is not behaving well with the add-on packages. Can you upgrade to R-4.0.3? Also, you may need to re-install the add-on packages to fix the "lazy load database corrupt" error.

Your code works fine for me (and thanks for posting a good reprex):

library(tidyverse)
squads <-tibble::tribble(
           ~score, ~treatment,
                6,      "st1",
                7,      "st1",
                4,      "st1",
                5,      "st1",
                6,      "st1",
                5,      "st1",
                5,      "st1",
                2,      "st2",
                2,      "st2",
                1,      "st2",
              1.5,      "st2",
              2.5,      "st2",
                2,      "st2",
                4,      "st2",
                5,      "st3",
                4,      "st3",
                5,      "st3",
                6,      "st3",
                7,      "st3",
                5,      "st3",
                5,      "st3"
           )
head(squads)
#> # A tibble: 6 x 2
#>   score treatment
#>   <dbl> <chr>    
#> 1     6 st1      
#> 2     7 st1      
#> 3     4 st1      
#> 4     5 st1      
#> 5     6 st1      
#> 6     5 st1

res.aov <- aov(score ~ treatment, data = squads)
summary(res.aov)
#>             Df Sum Sq Mean Sq F value   Pr(>F)    
#> treatment    2  48.29  24.143   26.34 4.51e-06 ***
#> Residuals   18  16.50   0.917                     
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

library(DescTools)
PostHocTest(res.aov, method = "lsd")
#> 
#>   Posthoc multiple comparisons of means : Fisher LSD 
#>     95% family-wise confidence level
#> 
#> $treatment
#>               diff    lwr.ci    upr.ci    pval    
#> st2-st1 -3.2857143 -4.360895 -2.210533 4.8e-06 ***
#> st3-st1 -0.1428571 -1.218038  0.932324  0.7833    
#> st3-st2  3.1428571  2.067676  4.218038 8.5e-06 ***
#> 
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Created on 2020-12-03 by the reprex package (v0.3.0)

HTH

1 Like

@DavoWW thanks for the suggestion. I updated my RStudio but you can see it is still causing some problems:

df <- read.csv("F:/Complete_Projects/LSD_test.csv", stringsAsFactors = F)
colnames(df)[1] = "score"
colnames(df)[2] = "treatment"
res.aov <- aov(score ~ treatment, data = df)
summary(res.aov)
#>             Df Sum Sq Mean Sq F value   Pr(>F)    
#> treatment    2  48.29  24.143   26.34 4.51e-06 ***
#> Residuals   18  16.50   0.917                     
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(DescTools)
#> Error: package or namespace load failed for 'DescTools' in library.dynam(lib, package, package.lib):
#>  DLL 'rootSolve' not found: maybe not installed for this architecture?
library(multcomp)
#> Loading required package: mvtnorm
#> Loading required package: survival
#> Loading required package: TH.data
#> Loading required package: MASS
#> 
#> Attaching package: 'TH.data'
#> The following object is masked from 'package:MASS':
#> 
#>     geyser
#> Warning in get(Info[i, 1], envir = env): internal error -3 in R_decompress1
#> Error: package or namespace load failed for 'multcomp' in get(Info[i, 1], envir = env):
#>  lazy-load database 'C:/Users/chetan/Documents/R/win-library/4.0/sandwich/R/sandwich.rdb' is corrupt
PostHocTest(aov(score ~ treatment, data = df), method = "lsd")
#> Error in PostHocTest(aov(score ~ treatment, data = df), method = "lsd"): could not find function "PostHocTest"

Created on 2020-12-04 by the reprex package (v0.3.0)

Hi @sharmachetan,
Sorry for delay in replying, been off-line for a few days.
I suggest you try uninstalling the three packages DescTools, multcomp, and sandwich using the RStudio packages menu and the "Remove package" buttons on the right hand side of the list. Then, close RStudio and restart. Then re-install those three packages.
HTH

1 Like

Thanks @DavoWW. I did as you mentioned in the recent post, but still it is showing same kind of problem. Here you go:

df <- read.csv("F:/Complete_Projects/LSD_test.csv", stringsAsFactors = F)
colnames(df)[1] = "score"
colnames(df)[2] = "treatment"
res.aov <- aov(score ~ treatment, data = df)
summary(res.aov)
#>             Df Sum Sq Mean Sq F value   Pr(>F)    
#> treatment    2  48.29  24.143   26.34 4.51e-06 ***
#> Residuals   18  16.50   0.917                     
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(DescTools)
#> Error: package or namespace load failed for 'DescTools' in library.dynam(lib, package, package.lib):
#>  DLL 'rootSolve' not found: maybe not installed for this architecture?
library(multcomp)
#> Loading required package: mvtnorm
#> Loading required package: survival
#> Loading required package: TH.data
#> Loading required package: MASS
#> 
#> Attaching package: 'TH.data'
#> The following object is masked from 'package:MASS':
#> 
#>     geyser
PostHocTest(aov(score ~ treatment, data = df), method = "lsd")
#> Error in PostHocTest(aov(score ~ treatment, data = df), method = "lsd"): could not find function "PostHocTest"

Created on 2020-12-11 by the reprex package (v0.3.0)

I got some help from one of my friends, it solved a part of it. But still not fully, I think there is some problem with package DescTools:

df <- read.csv("F:/Complete_Projects/LSD_test.csv", stringsAsFactors = F)
colnames(df)[1] = "score"
colnames(df)[2] = "treatment"
res.aov <- aov(score ~ treatment, data = df)
summary(res.aov)
#>             Df Sum Sq Mean Sq F value   Pr(>F)    
#> treatment    2  48.29  24.143   26.34 4.51e-06 ***
#> Residuals   18  16.50   0.917                     
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(DescTools)
#> Error: package or namespace load failed for 'DescTools' in library.dynam(lib, package, package.lib):
#>  DLL 'rootSolve' not found: maybe not installed for this architecture?
library(multcomp)
#> Loading required package: mvtnorm
#> Loading required package: survival
#> Loading required package: TH.data
#> Loading required package: MASS
#> 
#> Attaching package: 'TH.data'
#> The following object is masked from 'package:MASS':
#> 
#>     geyser
library(jtools)
library(broom.mixed)
#> Registered S3 methods overwritten by 'broom':
#>   method            from  
#>   tidy.glht         jtools
#>   tidy.summary.glht jtools
#> Registered S3 method overwritten by 'broom.mixed':
#>   method      from 
#>   tidy.gamlss broom
library(ggstance)
PostHocTest(aov(score ~ treatment, data = df), method = "lsd")
#> Error in PostHocTest(aov(score ~ treatment, data = df), method = "lsd"): could not find function "PostHocTest"

Created on 2020-12-11 by the reprex package (v0.3.0)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.