Giter Site home page Giter Site logo

indrajeetpatil / pairwisecomparisons Goto Github PK

View Code? Open in Web Editor NEW
44.0 3.0 6.0 6.27 MB

Pairwise comparison tests for one-way designs 🔬📝

Home Page: https://indrajeetpatil.github.io/pairwiseComparisons/

License: Other

R 100.00%
pairwise-comparison-tests parametric bayes-factor statistics robust

pairwisecomparisons's Introduction

{pairwiseComparisons}: Multiple Pairwise Comparison Tests

lifecycle R build status pkgdown

Introduction

{pairwiseComparisons} provides a tidy data friendly way to carry out pairwise comparison tests.

It currently supports post hoc multiple pairwise comparisons tests for both between-subjects and within-subjects one-way analysis of variance designs. For both of these designs, parametric, non-parametric, robust, and Bayesian statistical tests are available.

Installation

Type Source Command
Release CRAN install.packages("pairwiseComparisons")
Development GitHub remotes::install_github("IndrajeetPatil/pairwiseComparisons")

Linux users may encounter some installation problems. In particular, the {pairwiseComparisons} package depends on the PMCMRplus package.

ERROR: dependencies ‘gmp’, ‘Rmpfr’ are not available for package ‘PMCMRplus’
ERROR: dependency ‘pairwiseComparisons’ is not available for package ‘ggstatsplot’

This means that your operating system lacks gmp and Rmpfr libraries.

If you use Ubuntu, you can install these dependencies:

sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev

The following README file briefly describes the installation procedure: https://CRAN.R-project.org/package=PMCMRplus/readme/README.html

Summary of types of statistical analyses

Following table contains a brief summary of the currently supported pairwise comparison tests-

Between-subjects design

Type Equal variance? Test p-value adjustment? Function used
Parametric No Games-Howell test stats::pairwise.t.test
Parametric Yes Student’s t-test PMCMRplus::gamesHowellTest
Non-parametric No Dunn test PMCMRplus::kwAllPairsDunnTest
Robust No Yuen’s trimmed means test WRS2::lincon
Bayesian NA Student’s t-test NA BayesFactor::ttestBF

Within-subjects design

Type Test p-value adjustment? Function used
Parametric Student’s t-test stats::pairwise.t.test
Non-parametric Durbin-Conover test PMCMRplus::durbinAllPairsTest
Robust Yuen’s trimmed means test WRS2::rmmcp
Bayesian Student’s t-test NA BayesFactor::ttestBF

Examples

Here we will see specific examples of how to use this function for different types of

  • designs (between or within subjects)
  • statistics (parametric, non-parametric, robust, Bayesian)
  • p-value adjustment methods

Between-subjects design

# for reproducibility
set.seed(123)
library(pairwiseComparisons)
library(statsExpressions) # for data

# parametric
# if `var.equal = TRUE`, then Student's *t*-test will be run
pairwise_comparisons(
  data = ggplot2::msleep,
  x = vore,
  y = brainwt,
  type = "parametric",
  var.equal = TRUE,
  paired = FALSE,
  p.adjust.method = "bonferroni"
)
#> # A tibble: 6 x 6
#>   group1  group2  p.value test.details     p.value.adjustment
#>   <chr>   <chr>     <dbl> <chr>            <chr>             
#> 1 carni   herbi     1     Student's t-test Bonferroni        
#> 2 carni   insecti   1     Student's t-test Bonferroni        
#> 3 carni   omni      1     Student's t-test Bonferroni        
#> 4 herbi   insecti   1     Student's t-test Bonferroni        
#> 5 herbi   omni      0.979 Student's t-test Bonferroni        
#> 6 insecti omni      1     Student's t-test Bonferroni        
#>   label                                        
#>   <chr>                                        
#> 1 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 2 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 3 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 4 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 5 list(~italic(p)[Bonferroni-corrected]==0.979)
#> 6 list(~italic(p)[Bonferroni-corrected]==1.000)

# if `var.equal = FALSE`, then Games-Howell test will be run
pairwise_comparisons(
  data = ggplot2::msleep,
  x = vore,
  y = brainwt,
  type = "parametric",
  var.equal = FALSE,
  paired = FALSE,
  p.adjust.method = "bonferroni"
)
#> # A tibble: 6 x 11
#>   group1  group2  statistic p.value alternative method            distribution
#>   <chr>   <chr>       <dbl>   <dbl> <chr>       <chr>             <chr>       
#> 1 carni   herbi        2.17       1 two.sided   Games-Howell test q           
#> 2 carni   insecti     -2.17       1 two.sided   Games-Howell test q           
#> 3 carni   omni         1.10       1 two.sided   Games-Howell test q           
#> 4 herbi   insecti     -2.41       1 two.sided   Games-Howell test q           
#> 5 herbi   omni        -1.87       1 two.sided   Games-Howell test q           
#> 6 insecti omni         2.19       1 two.sided   Games-Howell test q           
#>   p.adjustment test.details      p.value.adjustment
#>   <chr>        <chr>             <chr>             
#> 1 none         Games-Howell test Bonferroni        
#> 2 none         Games-Howell test Bonferroni        
#> 3 none         Games-Howell test Bonferroni        
#> 4 none         Games-Howell test Bonferroni        
#> 5 none         Games-Howell test Bonferroni        
#> 6 none         Games-Howell test Bonferroni        
#>   label                                        
#>   <chr>                                        
#> 1 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 2 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 3 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 4 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 5 list(~italic(p)[Bonferroni-corrected]==1.000)
#> 6 list(~italic(p)[Bonferroni-corrected]==1.000)

# non-parametric
pairwise_comparisons(
  data = ggplot2::msleep,
  x = vore,
  y = brainwt,
  type = "nonparametric",
  paired = FALSE,
  p.adjust.method = "none"
)
#> # A tibble: 6 x 11
#>   group1  group2  statistic p.value alternative method               
#>   <chr>   <chr>       <dbl>   <dbl> <chr>       <chr>                
#> 1 carni   herbi       0.582  0.561  two.sided   Dunn's all-pairs test
#> 2 carni   insecti     1.88   0.0595 two.sided   Dunn's all-pairs test
#> 3 carni   omni        1.14   0.254  two.sided   Dunn's all-pairs test
#> 4 herbi   insecti     1.63   0.102  two.sided   Dunn's all-pairs test
#> 5 herbi   omni        0.717  0.474  two.sided   Dunn's all-pairs test
#> 6 insecti omni        1.14   0.254  two.sided   Dunn's all-pairs test
#>   distribution p.adjustment test.details p.value.adjustment
#>   <chr>        <chr>        <chr>        <chr>             
#> 1 z            none         Dunn test    None              
#> 2 z            none         Dunn test    None              
#> 3 z            none         Dunn test    None              
#> 4 z            none         Dunn test    None              
#> 5 z            none         Dunn test    None              
#> 6 z            none         Dunn test    None              
#>   label                               
#>   <chr>                               
#> 1 list(~italic(p)[uncorrected]==0.561)
#> 2 list(~italic(p)[uncorrected]==0.060)
#> 3 list(~italic(p)[uncorrected]==0.254)
#> 4 list(~italic(p)[uncorrected]==0.102)
#> 5 list(~italic(p)[uncorrected]==0.474)
#> 6 list(~italic(p)[uncorrected]==0.254)

# robust
pairwise_comparisons(
  data = ggplot2::msleep,
  x = vore,
  y = brainwt,
  type = "robust",
  paired = FALSE,
  p.adjust.method = "fdr"
)
#> # A tibble: 6 x 10
#>   group1  group2  estimate conf.level conf.low conf.high p.value
#>   <chr>   <chr>      <dbl>      <dbl>    <dbl>     <dbl>   <dbl>
#> 1 carni   herbi   -0.0323        0.95  -0.248     0.184    0.790
#> 2 carni   insecti  0.0451        0.95  -0.0484    0.139    0.552
#> 3 carni   omni     0.00520       0.95  -0.114     0.124    0.898
#> 4 herbi   insecti  0.0774        0.95  -0.133     0.288    0.552
#> 5 herbi   omni     0.0375        0.95  -0.182     0.257    0.790
#> 6 insecti omni    -0.0399        0.95  -0.142     0.0625   0.552
#>   test.details              p.value.adjustment
#>   <chr>                     <chr>             
#> 1 Yuen's trimmed means test FDR               
#> 2 Yuen's trimmed means test FDR               
#> 3 Yuen's trimmed means test FDR               
#> 4 Yuen's trimmed means test FDR               
#> 5 Yuen's trimmed means test FDR               
#> 6 Yuen's trimmed means test FDR               
#>   label                                 
#>   <chr>                                 
#> 1 list(~italic(p)[FDR-corrected]==0.790)
#> 2 list(~italic(p)[FDR-corrected]==0.552)
#> 3 list(~italic(p)[FDR-corrected]==0.898)
#> 4 list(~italic(p)[FDR-corrected]==0.552)
#> 5 list(~italic(p)[FDR-corrected]==0.790)
#> 6 list(~italic(p)[FDR-corrected]==0.552)

# Bayesian
pairwise_comparisons(
  data = ggplot2::msleep,
  x = vore,
  y = brainwt,
  type = "bayes",
  paired = FALSE
)
#> # A tibble: 6 x 18
#>   group1  group2  term       estimate conf.level conf.low conf.high    pd
#>   <chr>   <chr>   <chr>         <dbl>      <dbl>    <dbl>     <dbl> <dbl>
#> 1 carni   herbi   Difference   0.376        0.95   -0.525    1.33   0.800
#> 2 carni   insecti Difference  -0.0348       0.95   -0.127    0.0425 0.818
#> 3 carni   omni    Difference   0.0440       0.95   -0.139    0.239  0.693
#> 4 herbi   insecti Difference  -0.394        0.95   -1.61     0.775  0.758
#> 5 herbi   omni    Difference  -0.362        0.95   -1.06     0.345  0.859
#> 6 insecti omni    Difference   0.0762       0.95   -0.153    0.339  0.732
#>   rope.percentage prior.distribution prior.location prior.scale  bf10
#>             <dbl> <chr>                       <dbl>       <dbl> <dbl>
#> 1           0.171 cauchy                          0       0.707 0.540
#> 2           0.134 cauchy                          0       0.707 0.718
#> 3           0.236 cauchy                          0       0.707 0.427
#> 4           0.166 cauchy                          0       0.707 0.540
#> 5           0.162 cauchy                          0       0.707 0.571
#> 6           0.161 cauchy                          0       0.707 0.545
#>   method          log_e_bf10 expression label                        
#>   <chr>                <dbl> <list>     <chr>                        
#> 1 Bayesian t-test     -0.617 <language> list(~log[e](BF['01'])==0.62)
#> 2 Bayesian t-test     -0.332 <language> list(~log[e](BF['01'])==0.33)
#> 3 Bayesian t-test     -0.851 <language> list(~log[e](BF['01'])==0.85)
#> 4 Bayesian t-test     -0.616 <language> list(~log[e](BF['01'])==0.62)
#> 5 Bayesian t-test     -0.560 <language> list(~log[e](BF['01'])==0.56)
#> 6 Bayesian t-test     -0.606 <language> list(~log[e](BF['01'])==0.61)
#>   test.details    
#>   <chr>           
#> 1 Student's t-test
#> 2 Student's t-test
#> 3 Student's t-test
#> 4 Student's t-test
#> 5 Student's t-test
#> 6 Student's t-test

Within-subjects design

# for reproducibility
set.seed(123)

# parametric
pairwise_comparisons(
  data = bugs_long,
  x = condition,
  y = desire,
  subject.id = subject,
  type = "parametric",
  paired = TRUE,
  p.adjust.method = "BH"
)
#> # A tibble: 6 x 6
#>   group1 group2  p.value test.details     p.value.adjustment
#>   <chr>  <chr>     <dbl> <chr>            <chr>             
#> 1 HDHF   HDLF   1.06e- 3 Student's t-test FDR               
#> 2 HDHF   LDHF   7.02e- 2 Student's t-test FDR               
#> 3 HDHF   LDLF   3.95e-12 Student's t-test FDR               
#> 4 HDLF   LDHF   6.74e- 2 Student's t-test FDR               
#> 5 HDLF   LDLF   1.99e- 3 Student's t-test FDR               
#> 6 LDHF   LDLF   6.66e- 9 Student's t-test FDR               
#>   label                                    
#>   <chr>                                    
#> 1 list(~italic(p)[FDR-corrected]==0.001)   
#> 2 list(~italic(p)[FDR-corrected]==0.070)   
#> 3 list(~italic(p)[FDR-corrected]==3.95e-12)
#> 4 list(~italic(p)[FDR-corrected]==0.067)   
#> 5 list(~italic(p)[FDR-corrected]==0.002)   
#> 6 list(~italic(p)[FDR-corrected]==6.66e-09)

# non-parametric
pairwise_comparisons(
  data = bugs_long,
  x = condition,
  y = desire,
  subject.id = subject,
  type = "nonparametric",
  paired = TRUE,
  p.adjust.method = "BY"
)
#> # A tibble: 6 x 11
#>   group1 group2 statistic  p.value alternative
#>   <chr>  <chr>      <dbl>    <dbl> <chr>      
#> 1 HDHF   HDLF        4.78 1.44e- 5 two.sided  
#> 2 HDHF   LDHF        2.44 4.47e- 2 two.sided  
#> 3 HDHF   LDLF        8.01 5.45e-13 two.sided  
#> 4 HDLF   LDHF        2.34 4.96e- 2 two.sided  
#> 5 HDLF   LDLF        3.23 5.05e- 3 two.sided  
#> 6 LDHF   LDLF        5.57 4.64e- 7 two.sided  
#>   method                                                                
#>   <chr>                                                                 
#> 1 Durbin's all-pairs test for a two-way balanced incomplete block design
#> 2 Durbin's all-pairs test for a two-way balanced incomplete block design
#> 3 Durbin's all-pairs test for a two-way balanced incomplete block design
#> 4 Durbin's all-pairs test for a two-way balanced incomplete block design
#> 5 Durbin's all-pairs test for a two-way balanced incomplete block design
#> 6 Durbin's all-pairs test for a two-way balanced incomplete block design
#>   distribution p.adjustment test.details        p.value.adjustment
#>   <chr>        <chr>        <chr>               <chr>             
#> 1 t            none         Durbin-Conover test BY                
#> 2 t            none         Durbin-Conover test BY                
#> 3 t            none         Durbin-Conover test BY                
#> 4 t            none         Durbin-Conover test BY                
#> 5 t            none         Durbin-Conover test BY                
#> 6 t            none         Durbin-Conover test BY                
#>   label                                   
#>   <chr>                                   
#> 1 list(~italic(p)[BY-corrected]==1.44e-05)
#> 2 list(~italic(p)[BY-corrected]==0.045)   
#> 3 list(~italic(p)[BY-corrected]==5.45e-13)
#> 4 list(~italic(p)[BY-corrected]==0.050)   
#> 5 list(~italic(p)[BY-corrected]==0.005)   
#> 6 list(~italic(p)[BY-corrected]==4.64e-07)

# robust
pairwise_comparisons(
  data = bugs_long,
  x = condition,
  y = desire,
  subject.id = subject,
  type = "robust",
  paired = TRUE,
  p.adjust.method = "hommel"
)
#> # A tibble: 6 x 11
#>   group1 group2 estimate conf.level conf.low conf.high     p.value  p.crit
#>   <chr>  <chr>     <dbl>      <dbl>    <dbl>     <dbl>       <dbl>   <dbl>
#> 1 HDHF   HDLF      1.03        0.95   0.140      1.92  0.00999     0.0127 
#> 2 HDHF   LDHF      0.454       0.95  -0.104      1.01  0.0520      0.025  
#> 3 HDHF   LDLF      1.95        0.95   1.09       2.82  0.000000564 0.00851
#> 4 HDLF   LDHF     -0.676       0.95  -1.61       0.256 0.0520      0.05   
#> 5 HDLF   LDLF      0.889       0.95   0.0244     1.75  0.0203      0.0169 
#> 6 LDHF   LDLF      1.35        0.95   0.560      2.14  0.000102    0.0102 
#>   test.details              p.value.adjustment
#>   <chr>                     <chr>             
#> 1 Yuen's trimmed means test Hommel            
#> 2 Yuen's trimmed means test Hommel            
#> 3 Yuen's trimmed means test Hommel            
#> 4 Yuen's trimmed means test Hommel            
#> 5 Yuen's trimmed means test Hommel            
#> 6 Yuen's trimmed means test Hommel            
#>   label                                       
#>   <chr>                                       
#> 1 list(~italic(p)[Hommel-corrected]==0.010)   
#> 2 list(~italic(p)[Hommel-corrected]==0.052)   
#> 3 list(~italic(p)[Hommel-corrected]==5.64e-07)
#> 4 list(~italic(p)[Hommel-corrected]==0.052)   
#> 5 list(~italic(p)[Hommel-corrected]==0.020)   
#> 6 list(~italic(p)[Hommel-corrected]==1.02e-04)

# Bayesian
pairwise_comparisons(
  data = bugs_long,
  x = condition,
  y = desire,
  subject.id = subject,
  type = "bayes",
  paired = TRUE,
  bf.prior = 0.77
)
#> # A tibble: 6 x 18
#>   group1 group2 term       estimate conf.level conf.low conf.high    pd
#>   <chr>  <chr>  <chr>         <dbl>      <dbl>    <dbl>     <dbl> <dbl>
#> 1 HDHF   HDLF   Difference   -1.10        0.95  -1.73     -0.492  1    
#> 2 HDHF   LDHF   Difference   -0.465       0.95  -0.969     0.0406 0.962
#> 3 HDHF   LDLF   Difference   -2.13        0.95  -2.64     -1.63   1    
#> 4 HDLF   LDHF   Difference    0.652       0.95  -0.0362    1.32   0.971
#> 5 HDLF   LDLF   Difference   -0.983       0.95  -1.60     -0.423  0.999
#> 6 LDHF   LDLF   Difference   -1.67        0.95  -2.14     -1.14   1    
#>   rope.percentage prior.distribution prior.location prior.scale     bf10
#>             <dbl> <chr>                       <dbl>       <dbl>    <dbl>
#> 1           0     cauchy                          0        0.77 3.95e+ 1
#> 2           0.170 cauchy                          0        0.77 5.42e- 1
#> 3           0     cauchy                          0        0.77 1.22e+10
#> 4           0.162 cauchy                          0        0.77 6.50e- 1
#> 5           0     cauchy                          0        0.77 1.72e+ 1
#> 6           0     cauchy                          0        0.77 4.78e+ 6
#>   method          log_e_bf10 expression label                          
#>   <chr>                <dbl> <list>     <chr>                          
#> 1 Bayesian t-test      3.68  <language> list(~log[e](BF['01'])==-3.68) 
#> 2 Bayesian t-test     -0.612 <language> list(~log[e](BF['01'])==0.61)  
#> 3 Bayesian t-test     23.2   <language> list(~log[e](BF['01'])==-23.22)
#> 4 Bayesian t-test     -0.430 <language> list(~log[e](BF['01'])==0.43)  
#> 5 Bayesian t-test      2.84  <language> list(~log[e](BF['01'])==-2.84) 
#> 6 Bayesian t-test     15.4   <language> list(~log[e](BF['01'])==-15.38)
#>   test.details    
#>   <chr>           
#> 1 Student's t-test
#> 2 Student's t-test
#> 3 Student's t-test
#> 4 Student's t-test
#> 5 Student's t-test
#> 6 Student's t-test

Using {pairwiseComparisons} with ggsignif

Example-1: between-subjects

# needed libraries
set.seed(123)
library(ggplot2)
library(pairwiseComparisons)
library(ggsignif)

# converting to factor
mtcars$cyl <- as.factor(mtcars$cyl)

# creating a basic plot
p <- ggplot(mtcars, aes(cyl, wt)) +
  geom_boxplot()

# using `{pairwiseComparisons}` package to create a dataframe with results
set.seed(123)
(df <-
  pairwise_comparisons(mtcars, cyl, wt) %>%
  dplyr::mutate(groups = purrr::pmap(.l = list(group1, group2), .f = c)) %>%
  dplyr::arrange(group1))
#> # A tibble: 3 x 12
#>   group1 group2 statistic   p.value alternative method            distribution
#>   <chr>  <chr>      <dbl>     <dbl> <chr>       <chr>             <chr>       
#> 1 4      6           5.39 0.00831   two.sided   Games-Howell test q           
#> 2 4      8           9.11 0.0000124 two.sided   Games-Howell test q           
#> 3 6      8           5.12 0.00831   two.sided   Games-Howell test q           
#>   p.adjustment test.details      p.value.adjustment
#>   <chr>        <chr>             <chr>             
#> 1 none         Games-Howell test Holm              
#> 2 none         Games-Howell test Holm              
#> 3 none         Games-Howell test Holm              
#>   label                                      groups   
#>   <chr>                                      <list>   
#> 1 list(~italic(p)[Holm-corrected]==0.008)    <chr [2]>
#> 2 list(~italic(p)[Holm-corrected]==1.24e-05) <chr [2]>
#> 3 list(~italic(p)[Holm-corrected]==0.008)    <chr [2]>

# using `geom_signif` to display results
# (note that you can choose not to display all comparisons)
p +
  ggsignif::geom_signif(
    comparisons = list(df$groups[[1]]),
    annotations = df$label[[1]],
    test = NULL,
    na.rm = TRUE,
    parse = TRUE
  )

Example-2: within-subjects

# needed libraries
library(ggplot2)
library(pairwiseComparisons)
library(ggsignif)

# creating a basic plot
p <- ggplot(WRS2::WineTasting, aes(Wine, Taste)) +
  geom_boxplot()

# using `{pairwiseComparisons}` package to create a dataframe with results
set.seed(123)
(df <-
  pairwise_comparisons(
    WRS2::WineTasting,
    Wine,
    Taste,
    subject.id = Taster,
    type = "bayes",
    paired = TRUE
  ) %>%
  dplyr::mutate(groups = purrr::pmap(.l = list(group1, group2), .f = c)) %>%
  dplyr::arrange(group1))
#> # A tibble: 3 x 19
#>   group1 group2 term       estimate conf.level conf.low conf.high    pd
#>   <chr>  <chr>  <chr>         <dbl>      <dbl>    <dbl>     <dbl> <dbl>
#> 1 Wine A Wine B Difference -0.00721       0.95  -0.0569    0.0404 0.624
#> 2 Wine A Wine C Difference -0.0766        0.95  -0.140    -0.0144 0.989
#> 3 Wine B Wine C Difference -0.0696        0.95  -0.109    -0.0330 1.00 
#>   rope.percentage prior.distribution prior.location prior.scale   bf10
#>             <dbl> <chr>                       <dbl>       <dbl>  <dbl>
#> 1        0.404    cauchy                          0       0.707  0.235
#> 2        0.000526 cauchy                          0       0.707  3.71 
#> 3        0        cauchy                          0       0.707 50.5  
#>   method          log_e_bf10 expression label                         
#>   <chr>                <dbl> <list>     <chr>                         
#> 1 Bayesian t-test      -1.45 <language> list(~log[e](BF['01'])==1.45) 
#> 2 Bayesian t-test       1.31 <language> list(~log[e](BF['01'])==-1.31)
#> 3 Bayesian t-test       3.92 <language> list(~log[e](BF['01'])==-3.92)
#>   test.details     groups   
#>   <chr>            <list>   
#> 1 Student's t-test <chr [2]>
#> 2 Student's t-test <chr [2]>
#> 3 Student's t-test <chr [2]>

# using `geom_signif` to display results
p +
  ggsignif::geom_signif(
    comparisons = df$groups,
    map_signif_level = TRUE,
    tip_length = 0.01,
    y_position = c(6.5, 6.65, 6.8),
    annotations = df$label,
    test = NULL,
    na.rm = TRUE,
    parse = TRUE
  )

Acknowledgments

The hexsticker was generously designed by Sarah Otterstetter (Max Planck Institute for Human Development, Berlin).

pairwisecomparisons's People

Contributors

indrajeetpatil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pairwisecomparisons's Issues

move `pairwise_caption` here from `ggstatsplot`

#' @name pairwise_caption
#' @noRd

pairwise_caption <- function(caption, test.description, p.adjust.method) {
  substitute(
    atop(
      displaystyle(top.text),
      expr = paste(
        "Pairwise comparisons: ",
        bold(test.description),
        "; Adjustment (p-value): ",
        bold(p.adjust.method.text)
      )
    ),
    env = list(
      top.text = caption,
      test.description = test.description,
      p.adjust.method.text = p_adjust_text(p.adjust.method)
    )
  )
}

Error: package or namespace load failed for ‘pairwiseComparisons’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘rstan’

Hi,

I'm trying to instal the library pairwiseComparisons but I keep getting the same error. I'm running RStudio 1.3.1056 for R 4.02 on a macOS Catalina 10.15.6. Haven't had any problem with other libraries, so I wonder if you have a quickfix.

library(pairwiseComparisons)
Registered S3 method overwritten by 'broom.mixed':
method from
tidy.gamlss broom
Error: package or namespace load failed for ‘pairwiseComparisons’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘rstan’

Tried to install lib.loc or .libPaths but I get the following mistake.

install.packages("lib.loc")
Warning in install.packages :
package ‘lib.loc’ is not available (for R version 4.0.2)

This (https://indrajeetpatil.github.io/pairwiseComparisons/) did not help either.

WRS2 feature request: retaining group level names in the `comp` object itself

Pairwise comparison objects from WRS2 contain the comparisons in comp object but the group level names are removed and replaced with numeric values, while the names are contained in fnames. The correspondence between numeric values and group levels is unclear and in edge cases (dropped factor levels, reordered factor levels) can be tricky.

setup

    library(WRS2)
    library(magrittr)
    require(reshape)
    #> Loading required package: reshape

    bushLong <- 
      melt(bush, id.var = "participant", variable_name = "food") %>%
      dplyr::arrange(participant)

within-subjects

    x_w <- rmmcp(bushLong$value, bushLong$food, bushLong$participant)

    x_w$comp
    #>      Group Group    psihat    ci.lower  ci.upper    p.value  p.crit
    #> [1,]     1     2  3.666667  -0.4830017  7.816335 0.01359625 0.01020
    #> [2,]     1     3  4.000000  -0.3572784  8.357278 0.01172054 0.00851
    #> [3,]     1     4  2.000000  -8.0992023 12.099202 0.44148206 0.01690
    #> [4,]     2     3  0.000000  -5.3880170  5.388017 1.00000000 0.05000
    #> [5,]     2     4 -1.833333  -9.2326553  5.565989 0.34371248 0.01270
    #> [6,]     3     4 -2.000000 -12.5482728  8.548273 0.46001407 0.02500
    
    x_w$fnames
    #> [1] "stick_insect"      "kangaroo_testicle" "fish_eye"         
    #> [4] "witchetty_grub"

between-subjects

    x_b <- lincon(libido ~ dose, data = viagra)

    x_b$comp
    #>      Group Group psihat ci.lower ci.upper   p.value
    #> [1,]     1     2     -1 -5.31858  3.31858 0.4353309
    #> [2,]     1     3     -3 -7.31858  1.31858 0.1805095
    #> [3,]     2     3     -2 -6.31858  2.31858 0.3166048

    x_b$fnames
    #> [1] "placebo" "low"     "high"

Created on 2020-09-28 by the reprex package (v0.3.0.9001)

feature request for `PMCMRplus`

# setup
set.seed(123)
library(tidyverse)
library(PMCMRplus)

# custom function
PMCMR_to_tidy <- function(mod, ...) {
  # custom function to convert from a matrix to a tidy dataframe
  matrix_to_tidy <- function(m, col_name = "value") {
    result <-
      data.frame(
        group1 = rep(rownames(m), each = ncol(m)),
        group2 = rep(colnames(m), times = nrow(m)),
        col3 = as.numeric(base::t(m)),
        stringsAsFactors = FALSE
      )

    names(result)[3] <- col_name
    stats::na.omit(result)
  }

  # combine all components of the object in a single dataframe
  tibble::as_tibble(dplyr::bind_cols(
    dplyr::full_join(
      matrix_to_tidy(mod$statistic, col_name = "statistic"),
      matrix_to_tidy(mod$p.value, col_name = "p.value"),
      by = c("group1", "group2")
    ),
    purrr::flatten_dfr(list(mod$parameter)),
    tibble::tibble(method = mod$method),
    tibble::tibble(distribution = mod$dist),
    tibble::tibble(p.adjust.method = mod$p.adjust.method)
  ))
}

# example PMCMRplus object
ans <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays, p.adjust.method = "single-step")
#> Warning in kwAllPairsConoverTest.default(c(10, 7, 20, 14, 14, 12, 10, 23, : Ties
#> are present. Quantiles were corrected for ties.

# using the function
PMCMR_to_tidy(ans)
#> # A tibble: 15 x 9
#>    group1 group2 statistic  p.value nmeans    df method distribution
#>    <chr>  <chr>      <dbl>    <dbl>  <int> <int> <chr>  <chr>       
#>  1 B      A          0.890 9.88e- 1      6    66 Conov~ q           
#>  2 C      A        -13.6   0.            6    66 Conov~ q           
#>  3 C      B        -14.5   0.            6    66 Conov~ q           
#>  4 D      A         -8.87  4.61e- 7      6    66 Conov~ q           
#>  5 D      B         -9.76  3.61e- 8      6    66 Conov~ q           
#>  6 D      C          4.71  1.70e- 2      6    66 Conov~ q           
#>  7 E      A        -11.0   1.12e- 9      6    66 Conov~ q           
#>  8 E      B        -11.8   7.57e-11      6    66 Conov~ q           
#>  9 E      C          2.63  4.37e- 1      6    66 Conov~ q           
#> 10 E      D         -2.09  6.81e- 1      6    66 Conov~ q           
#> 11 F      A          1.15  9.64e- 1      6    66 Conov~ q           
#> 12 F      B          0.264 1.00e+ 0      6    66 Conov~ q           
#> 13 F      C         14.7   0.            6    66 Conov~ q           
#> 14 F      D         10.0   1.68e- 8      6    66 Conov~ q           
#> 15 F      E         12.1   3.05e-11      6    66 Conov~ q           
#> # ... with 1 more variable: p.adjust.method <chr>

Created on 2020-10-14 by the reprex package (v0.3.0.9001)

Package stuck solving

Having many issues trying to install. Tried with a fresh conda environment and it's been stuck on "solving" overnight.

image

Do you have a list of packages to install, in a specific order, to get this following code to work?

# for reproducibility
set.seed(123)
library(ggstatsplot)

# plot
ggbetweenstats(
  data = iris,
  x = Species,
  y = Sepal.Length,
  title = "Distribution of sepal length across Iris species"
)

Feature suggestion for Bayesian muliple comparisons

Hi Indrajeet,

Was working on multiple comparisons for bayes analysis see https://ibecav.netlify.com/post/pairwise-bayesian-comparisons-even-faster/ when it struck me that a nice future feature for ggstatsplot::ggbetweenstats might be to display BF10 similar to the way you do p values for parametric.

I hacked at your code a little bit signif_column and pairwise_p and the reprex kind of shows what's possible...

library(tidyverse)
library(ggstatsplot)
#> Registered S3 methods overwritten by 'broom.mixed':
#>   method         from 
#>   augment.lme    broom
#>   augment.merMod broom
#>   glance.lme     broom
#>   glance.merMod  broom
#>   glance.stanreg broom
#>   tidy.brmsfit   broom
#>   tidy.gamlss    broom
#>   tidy.lme       broom
#>   tidy.merMod    broom
#>   tidy.rjags     broom
#>   tidy.stanfit   broom
#>   tidy.stanreg   broom
#> Registered S3 methods overwritten by 'lme4':
#>   method                          from
#>   cooks.distance.influence.merMod car 
#>   influence.merMod                car 
#>   dfbeta.influence.merMod         car 
#>   dfbetas.influence.merMod        car
library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> 
#> Attaching package: 'Matrix'
#> The following object is masked from 'package:tidyr':
#> 
#>     expand
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey ([email protected]).
#> 
#> Type BFManual() to open the manual.
#> ************
# function body
xpairwise_p <- function(data,
                       x,
                       y,
                       type = "parametric",
                       tr = 0.1,
                       paired = FALSE,
                       var.equal = FALSE,
                       p.adjust.method = "holm",
                       k = 2,
                       messages = TRUE,
                       ...) {
  ellipsis::check_dots_used()

  # ---------------------------- data cleanup -------------------------------
  # creating a dataframe
  data <-
    dplyr::select(
      .data = data,
      x = !!rlang::enquo(x),
      y = !!rlang::enquo(y)
    ) %>%
    dplyr::mutate(.data = ., x = droplevels(as.factor(x))) %>%
    tibble::as_tibble(x = .)
# return(data)
  # ---------------------------- parametric ---------------------------------
  
  if (type %in% c("parametric", "p")) {
    if (isTRUE(var.equal) || isTRUE(paired)) {
      # anova model
      aovmodel <- stats::aov(formula = y ~ x, data = data)
      
      # safeguarding against edge cases
      aovmodel$model %<>%
        dplyr::mutate(
          .data = .,
          x = forcats::fct_relabel(
            .f = x,
            .fun = ~ stringr::str_replace(
              string = .x,
              pattern = "-",
              replacement = "_"
            )
          )
        )
      
      # extracting and cleaning up Tukey's HSD output
      df_tukey <- stats::TukeyHSD(x = aovmodel, conf.level = 0.95) %>%
        broomExtra::tidy(x = .) %>%
        dplyr::select(.data = ., comparison, estimate) %>%
        tidyr::separate(
          data = .,
          col = comparison,
          into = c("group1", "group2"),
          sep = "-"
        ) %>%
        dplyr::rename(.data = ., mean.difference = estimate) %>%
        dplyr::mutate_at(
          .tbl = .,
          .vars = dplyr::vars(dplyr::matches("^group[0-9]$")),
          .funs = ~ stringr::str_replace(
            string = .,
            pattern = "_",
            replacement = "-"
          )
        )
      
      # tidy dataframe with results from pairwise tests
      df_tidy <- broomExtra::tidy(
        stats::pairwise.t.test(
          x = data$y,
          g = data$x,
          p.adjust.method = p.adjust.method,
          paired = paired,
          alternative = "two.sided",
          na.action = na.omit
        )
      ) %>%
        signif_column(data = ., p = p.value)
      
      # combining mean difference and results from pairwise t-test
      df <-
        dplyr::full_join(
          x = df_tukey,
          y = df_tidy,
          by = c("group1", "group2")
        ) %>% # the group columns need to be swapped to be consistent
        dplyr::rename(.data = ., group2 = group1, group1 = group2) %>%
        dplyr::select(.data = ., group1, group2, dplyr::everything())
      
      # display message about the post hoc tests run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The parametric pairwise multiple comparisons test used-\n",
            "Student's t-test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    } else {
      
      # dataframe with Games-Howell test results
      df <-
        games_howell(data = data, x = x, y = y) %>%
        p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method) %>%
        dplyr::select(.data = ., -conf.low, -conf.high)
      
      # display message about the post hoc tests run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The parametric pairwise multiple comparisons test used-\n",
            "Games-Howell test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    }
  }
  
  # ---------------------------- nonparametric ----------------------------

  if (type %in% c("nonparametric", "np")) {
    if (!isTRUE(paired)) {
      # running Dwass-Steel-Crichtlow-Fligner test using `jmv` package
      jmv_pairs <-
        jmv::anovaNP(
          data = data,
          deps = "y",
          group = "x",
          pairs = TRUE
        )

      # extracting the pairwise tests and formatting the output
      df <-
        as.data.frame(x = jmv_pairs$comparisons[[1]]) %>%
        tibble::as_tibble(x = .) %>%
        dplyr::rename(
          .data = .,
          group1 = p1,
          group2 = p2,
          p.value = p
        ) %>%
        ggstatsplot:::p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method)

      # letting the user know which test was run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The nonparametric pairwise multiple comparisons test used-\n",
            "Dwass-Steel-Crichtlow-Fligner test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    } else {
      # converting the entered long format data to wide format
      data_wide <- long_to_wide_converter(
        data = data,
        x = x,
        y = y
      )

      # running Durbin-Conover test using `jmv` package
      jmv_pairs <-
        jmv::anovaRMNP(
          data = data_wide,
          measures = names(data_wide[, -1]),
          pairs = TRUE
        )

      # extracting the pairwise tests and formatting the output
      df <-
        as.data.frame(x = jmv_pairs$comp) %>%
        tibble::as_tibble(x = .) %>%
        dplyr::select(.data = ., -sep) %>%
        dplyr::rename(
          .data = .,
          group1 = i1,
          group2 = i2,
          statistic = stat,
          p.value = p
        ) %>%
        ggstatsplot:::p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method)

      # letting the user know which test was run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The nonparametric pairwise multiple comparisons test used-\n",
            "Durbin-Conover test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    }
  }

  # ---------------------------- robust ----------------------------------

  if (type %in% c("robust", "r")) {
    if (!isTRUE(paired)) {
      # object with all details about pairwise comparisons
      rob_pairwise_df <-
        WRS2::lincon(
          formula = y ~ x,
          data = data,
          tr = tr
        )
    } else {
      # converting to long format and then getting it back in wide so that the
      # rowid variable can be used as the block variable for WRS2 functions
      data_within <-
        long_to_wide_converter(
          data = data,
          x = x,
          y = y
        ) %>%
        tidyr::gather(data = ., key, value, -rowid) %>%
        dplyr::arrange(.data = ., rowid)

      # running pairwise multiple comparison tests
      rob_pairwise_df <-
        with(
          data = data_within,
          expr = WRS2::rmmcp(
            y = value,
            groups = key,
            blocks = rowid,
            tr = tr
          )
        )
    }

    # extracting the robust pairwise comparisons and tidying up names
    rob_df_tidy <-
      suppressMessages(tibble::as_tibble(
        x = rob_pairwise_df$comp,
        .name_repair = "unique"
      )) %>%
      dplyr::rename(
        .data = .,
        group1 = Group...1,
        group2 = Group...2
      )

    # cleaning the raw object and getting it in the right format
    df <-
      dplyr::full_join(
        # dataframe comparing comparison details
        x = rob_df_tidy %>%
          ggstatsplot:::p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method) %>%
          tidyr::gather(
            data = .,
            key = "key",
            value = "rowid",
            group1:group2
          ),
        # dataframe with factor level codings
        y = rob_pairwise_df$fnames %>%
          tibble::enframe(x = ., name = "rowid"),
        by = "rowid"
      ) %>%
      dplyr::select(.data = ., -rowid) %>%
      tidyr::spread(data = ., key = "key", value = "value") %>%
      dplyr::select(.data = ., group1, group2, dplyr::everything())

    # for paired designs, there will be an unnecessary column to remove
    if (("p.crit") %in% names(df)) {
      df %<>% dplyr::select(.data = ., -p.crit)
    }

    # renaming confidence interval names
    df %<>% dplyr::rename(.data = ., conf.low = ci.lower, conf.high = ci.upper)

    # message about which test was run
    if (isTRUE(messages)) {
      message(cat(
        crayon::green("Note: "),
        crayon::blue(
          "The robust pairwise multiple comparisons test used-\n",
          "Yuen's trimmed means comparisons test.\n",
          "Adjustment method for p-values: "
        ),
        crayon::yellow(p.adjust.method),
        sep = ""
      ))
    }
  }

  # ---------------------------- bayes factor --------------------------------

  # print a message telling the user that this is currently not supported
  if (type %in% c("bf", "bayes")) {
    # anova model
    aovmodel <- stats::aov(formula = y ~ x, data = data)
    
    # safeguarding against edge cases
    aovmodel$model %<>%
      dplyr::mutate(
        .data = .,
        x = forcats::fct_relabel(
          .f = x,
          .fun = ~ stringr::str_replace(
            string = .x,
            pattern = "-",
            replacement = "_"
          )
        )
      )
    
    # extracting and cleaning up Tukey's HSD output
    df_tukey <- stats::TukeyHSD(x = aovmodel, conf.level = 0.95) %>%
      broomExtra::tidy(x = .) %>%
      dplyr::select(.data = ., comparison, estimate) %>%
      tidyr::separate(
        data = .,
        col = comparison,
        into = c("group1", "group2"),
        sep = "-"
      ) %>%
      dplyr::rename(.data = ., mean.difference = estimate) %>%
      dplyr::mutate_at(
        .tbl = .,
        .vars = dplyr::vars(dplyr::matches("^group[0-9]$")),
        .funs = ~ stringr::str_replace(
          string = .,
          pattern = "_",
          replacement = "-"
        )
      )
    # return(df_tukey)
    
    # combining mean difference and results from pairwise t-test
    df <- df_tukey %>% # the group columns need to be swapped to be consistent
      dplyr::rename(.data = ., group2 = group1, group1 = group2) %>%
      dplyr::select(.data = ., group1, group2, dplyr::everything())
    
    g1_list <- df_tukey %>% pull(group2) %>% as.character()
    g2_list <- df_tukey %>% pull(group1) %>% as.character()
    
    # return(g1_list)
    
    bfresults <- map2(
      g1_list,
      g2_list,
      function(a, b)
        data %>%
        filter(!is.na(x)) %>%
        filter(!is.na(y)) %>%
        filter(x %in% c(a, b)) %>%
        droplevels() %>%
        as.data.frame()
    ) %>%
      map(.x = ., ~ ttestBF(
        formula = y ~ x,
        data = .
      )) %>%
      map(.x = ., ~ extractBF(x = .)) %>%
      map_dbl(.x = ., ~ .[, "bf"]) 
    # return(bfresults)
    
    df$bfactor <- bfresults
    
    # display message about the post hoc tests run
    if (isTRUE(messages)) {
      message(cat(
        crayon::green("Note: "),
        crayon::blue(
          "The pairwise multiple comparisons test used - \n",
          "BayesFactor::ttestBF.\n"
        ),
        sep = ""
      ))
    }
  } # bayes


  # ---------------------------- cleanup ----------------------------------

  # if there are factors, covert them to character to make life easy
  df %<>%
    dplyr::mutate_if(
      .tbl = .,
      .predicate = is.factor,
      .funs = ~ as.character(.)
    ) 
#  return(df)
  if (type %in% c("parametric", "nonparametric", "robust", "p", "np", "r")) {
  df %<>%
    purrrlyr::by_row(
      .d = .,
      ..f = ~ specify_decimal_p(
        x = .$p.value,
        k = k,
        p.value = TRUE
      ),
      .collate = "rows",
      .to = "label",
      .labels = TRUE
    ) %>%
    dplyr::mutate(
      .data = .,
      p.value.label = dplyr::case_when(
        label == "< 0.001" ~ "p <= 0.001",
        TRUE ~ paste("p = ", label, sep = "")
      )
    ) %>%
    dplyr::select(.data = ., -label)
  }
  # return
  return(tibble::as_tibble(df))
}


bf_column <- function(data = NULL, bf) {
  
  # if dataframe is provided
  if (!is.null(data)) {
    
    # storing variable name to be assigned later
    p_lab <- colnames(dplyr::select(
      .data = data,
      !!rlang::enquo(bf)
    ))
    
    # preparing dataframe
    df <-
      dplyr::select(
        .data = data,
        # column corresponding to bf-values
        bf = !!rlang::enquo(bf),
        dplyr::everything()
      )
  } else {
    
    # if only vector is provided
    df <-
      base::cbind.data.frame(bf = bf)
  }
  
  # make sure the bf-value column is numeric; if not, convert it to numeric
  if (!is.numeric(df$bf)) {
    
    # display message about conversion
    base::message(cat(
      crayon::green("Note:"),
      crayon::blue(
        "The entered vector is of class",
        crayon::yellow(class(df$bf)[[1]]),
        "; attempting to convert it to numeric."
      )
    ))
    
    # conversion
    df$bf <- as.numeric(as.character(df$bf))
  }
  
  # add new support column based on 
  # Wagenmakers, Wetzels, Borsboom, & Van Der Maas, 2011 
  df %<>%
    dplyr::mutate(
      .data = .,
      support = dplyr::case_when(
        # first condition
        bf < .01 ~ "extreme BF01",
        bf < .03 & bf >= .01 ~ "very strong BF01",
        bf < .1 & bf >= .03 ~ "strong BF01",
        bf < 1/3 & bf >= .1 ~ "moderate BF01",
        bf < 1 & bf >= 1/3 ~ "anectdotal BF01",
        bf >= 1 & bf < 3 ~ "anectdotal BF10",
        bf >= 3 & bf < 10 ~ "moderate BF10",
        bf >= 10 & bf < 30 ~ "strong BF10",
        bf >= 30 & bf < 100 ~ "very strong BF10",
        bf >= 100  ~ "extreme BF10",
        # fourth condition
        bf < 0.001 ~ "***"
      )
    ) %>%
    tibble::as_data_frame(x = .) # convert to tibble dataframe
  
  # change back from the generic bf-value to the original name that was provided by the user for the bf-value
  if (!is.null(data)) {
    
    # reordering the dataframe
    df %<>%
      dplyr::select(.data = ., -bf, -support, dplyr::everything())
    
    # renaming the bf-value variable with the name provided by the user
    colnames(df)[which(names(df) == "bf")] <- p_lab
  }
  
  # return the final tibble dataframe
  return(df)
}

testme <- xpairwise_p(data = ggplot2::msleep,
x = vore,
y = brainwt, 
type = "bf")
#> Note: The pairwise multiple comparisons test used - 
#>  BayesFactor::ttestBF.
#> 

bf_column(testme, bfactor)
#> Warning: `as_data_frame()` is deprecated, use `as_tibble()` (but mind the new semantics).
#> This warning is displayed once per session.
#> # A tibble: 6 x 5
#>   group1  group2  mean.difference bfactor support        
#>   <chr>   <chr>             <dbl>   <dbl> <chr>          
#> 1 carni   herbi            0.542    0.540 anectdotal BF01
#> 2 carni   insecti         -0.0577   0.718 anectdotal BF01
#> 3 carni   omni             0.0665   0.427 anectdotal BF01
#> 4 herbi   insecti         -0.600    0.540 anectdotal BF01
#> 5 herbi   omni            -0.476    0.571 anectdotal BF01
#> 6 insecti omni             0.124    0.545 anectdotal BF01

Created on 2019-07-11 by the reprex package (v0.3.0)

brain dump

  • add support for PMCMR objects in parameters
  • check which tests work with NAs and which not (why is long_to_wide needed here?)
  • use rlang::exec when non-parametric
  • have separate if statements for parametric and bayes; don't put them together
  • see if PMCMRplus might be willing to support pairwise t tests as well
  • don't support quoted arguments any more
  • once easystats API is stabilized, have strict tests for the entire dataframes
  • change default trimming to 0.2
  • move PMCMRplus from Imports to Suggests
  • simplify installation instructions

feature request for `WRS2`: allow to adjust confidence intervals plus consistent output

  • allow users to change the confidence intervals for estimate of group difference
  • have a consistent output for both designs
    (e.g., columns p.crit and sig are only present in within-subjects output)

between-subjects design

WRS2::lincon(libido ~ dose, data = viagra)
#> Call:
#> lincon(formula = libido ~ dose, data = viagra)
#> 
#>                  psihat ci.lower ci.upper p.value
#> placebo vs. low      -1 -5.31858  3.31858 0.43533
#> placebo vs. high     -3 -7.31858  1.31858 0.18051
#> low vs. high         -2 -6.31858  2.31858 0.31660

within-subjects design

WRS2::rmmcp(WineTasting$Taste, WineTasting$Wine, WineTasting$Taster)
#> Call:
#> rmmcp(y = WineTasting$Taste, groups = WineTasting$Wine, blocks = WineTasting$Taster)
#> 
#>                    psihat ci.lower ci.upper p.value p.crit   sig
#> Wine A vs. Wine B 0.02143 -0.02164  0.06449 0.19500 0.0500 FALSE
#> Wine A vs. Wine C 0.11429  0.02148  0.20710 0.00492 0.0169  TRUE
#> Wine B vs. Wine C 0.08214  0.00891  0.15538 0.00878 0.0250  TRUE

use `statsExpressions` for Bayesian test?

Doesn't really add that many new dependencies, since ipmisc anyways relies on tidyr.

setdiff(
  tools::package_dependencies("statsExpressions")$statsExpressions,
  tools::package_dependencies("pairwiseComparisons")$pairwiseComparisons
)
#> [1] "correlation" "effectsize"  "performance" "tidyr"

Created on 2021-06-08 by the reprex package (v2.0.0)

TO DO for 3.0.0

  • remove internal Games-Howell test (use PMCMRplus)
  • remove reliance on Dunn test (use PMCMRplus)
  • uniform output for everything but Bayes
  • remove dependence from tidyBF to make the package lighter
  • remove dependence from broomExtra to make the package lighter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.