Skip to contents

pairwise.augmentedRCBD performs pairwise t tests of adjusted means from an object of class augmentedRCBD.

Usage

pairwise.augmentedRCBD(aug, cl = NULL, p.adjust = c("none", "tukey", "sidak"))

Arguments

aug

An object of class augmentedRCBD.

cl

A cluster object created by makeCluster for parallel evaluations.

p.adjust

The p value adjustment method. Either "none", "tukey" or "sidak".

Value

A data frame of pairwise comparisons of treatments.

Details

The default pairwise comparison in augmentedRCBD employs pairs.emmGrid function from emmeans which is very slow for large number of comparisons. This function attempts to do the same faster with parallel computing with the package parallel-package.

See also

Examples

library(augmentedRCBD)
#> 
#> --------------------------------------------------------------------------------
#> Welcome to augmentedRCBD version 0.1.7
#> 
#> 
#> # To know how to use this package type:
#>   browseVignettes(package = 'augmentedRCBD')
#>   for the package vignette.
#> 
#> # To know whats new in this version type:
#>   news(package='augmentedRCBD')
#>   for the NEWS file.
#> 
#> # To cite the methods in the package type:
#>   citation(package='augmentedRCBD')
#> 
#> # To suppress this message use:
#>   suppressPackageStartupMessages(library(augmentedRCBD))
#> --------------------------------------------------------------------------------

blk <- c(rep(1,7),rep(2,6),rep(3,7))
trt <- c(1, 2, 3, 4, 7, 11, 12, 1, 2, 3, 4, 5, 9, 1, 2, 3, 4, 8, 6, 10)
y1 <- c(92, 79, 87, 81, 96, 89, 82, 79, 81, 81, 91, 79, 78, 83, 77, 78, 78,
        70, 75, 74)
y2 <- c(258, 224, 238, 278, 347, 300, 289, 260, 220, 237, 227, 281, 311, 250,
        240, 268, 287, 226, 395, 450)
data <- data.frame(blk, trt, y1, y2)
# Convert block and treatment to factors
data$blk <- as.factor(data$blk)
data$trt <- as.factor(data$trt)
# Results for variable y1
out1 <- augmentedRCBD(data$blk, data$trt, data$y1, method.comp = "lsd",
                      alpha = 0.05, group = TRUE, console = TRUE)
#> 
#> Augmented Design Details
#> ========================
#>                                        
#> Number of blocks           "3"         
#> Number of treatments       "12"        
#> Number of check treatments "4"         
#> Number of test treatments  "8"         
#> Check treatments           "1, 2, 3, 4"
#> 
#> 
#> ANOVA, Treatment Adjusted
#> =========================
#>                                      Df Sum Sq Mean Sq F value Pr(>F)  
#> Block (ignoring Treatments)           2  360.1  180.04   6.675 0.0298 *
#> Treatment (eliminating Blocks)       11  285.1   25.92   0.961 0.5499  
#>   Treatment: Check                    3   52.9   17.64   0.654 0.6092  
#>   Treatment: Test and Test vs. Check  8  232.2   29.02   1.076 0.4779  
#> Residuals                             6  161.8   26.97                 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> ANOVA, Block Adjusted
#> =====================
#>                                Df Sum Sq Mean Sq F value Pr(>F)
#> Treatment (ignoring Blocks)    11  575.7   52.33   1.940  0.215
#>   Treatment: Check              3   52.9   17.64   0.654  0.609
#>   Treatment: Test               7  505.9   72.27   2.679  0.125
#>   Treatment: Test vs. Check     1   16.9   16.87   0.626  0.459
#> Block (eliminating Treatments)  2   69.5   34.75   1.288  0.342
#> Residuals                       6  161.8   26.97               
#> 
#> Coefficient of Variation
#> ========================
#> 6.372367
#> 
#> Overall Adjusted Mean
#> =====================
#> 81.0625
#> 
#> Standard Errors
#> ===============
#>                                          Std. Error of Diff.  CD (5%)
#> Control Treatment Means                             4.240458 10.37603
#> Two Test Treatments (Same Block)                    7.344688 17.97180
#> Two Test Treatments (Different Blocks)              8.211611 20.09309
#> A Test Treatment and a Control Treatment            6.704752 16.40594
#> 
#> Treatment Means
#> ===============
#>  Treatment Block Means   SE r   Min   Max Adjusted Means
#>          1       84.67 3.84 3 79.00 92.00          84.67
#>         10     3 74.00 <NA> 1 74.00 74.00          77.25
#>         11     1 89.00 <NA> 1 89.00 89.00          86.50
#>         12     1 82.00 <NA> 1 82.00 82.00          79.50
#>          2       79.00 1.15 3 77.00 81.00          79.00
#>          3       82.00 2.65 3 78.00 87.00          82.00
#>          4       83.33 3.93 3 78.00 91.00          83.33
#>          5     2 79.00 <NA> 1 79.00 79.00          78.25
#>          6     3 75.00 <NA> 1 75.00 75.00          78.25
#>          7     1 96.00 <NA> 1 96.00 96.00          93.50
#>          8     3 70.00 <NA> 1 70.00 70.00          73.25
#>          9     2 78.00 <NA> 1 78.00 78.00          77.25
#> 
#> 
#> Comparisons
#> ===========
#> 
#> Method : lsd
#> 
#>                   contrast estimate   SE df t.ratio p.value sig
#>    treatment1 - treatment2     5.67 4.24  6   1.336   0.230    
#>    treatment1 - treatment3     2.67 4.24  6   0.629   0.553    
#>    treatment1 - treatment4     1.33 4.24  6   0.314   0.764    
#>    treatment1 - treatment5     6.42 6.36  6   1.009   0.352    
#>    treatment1 - treatment6     6.42 6.36  6   1.009   0.352    
#>    treatment1 - treatment7    -8.83 6.36  6  -1.389   0.214    
#>    treatment1 - treatment8    11.42 6.36  6   1.795   0.123    
#>    treatment1 - treatment9     7.42 6.36  6   1.166   0.288    
#>   treatment1 - treatment10     7.42 6.36  6   1.166   0.288    
#>   treatment1 - treatment11    -1.83 6.36  6  -0.288   0.783    
#>   treatment1 - treatment12     5.17 6.36  6   0.812   0.448    
#>    treatment2 - treatment3    -3.00 4.24  6  -0.707   0.506    
#>    treatment2 - treatment4    -4.33 4.24  6  -1.022   0.346    
#>    treatment2 - treatment5     0.75 6.36  6   0.118   0.910    
#>    treatment2 - treatment6     0.75 6.36  6   0.118   0.910    
#>    treatment2 - treatment7   -14.50 6.36  6  -2.280   0.063    
#>    treatment2 - treatment8     5.75 6.36  6   0.904   0.401    
#>    treatment2 - treatment9     1.75 6.36  6   0.275   0.792    
#>   treatment2 - treatment10     1.75 6.36  6   0.275   0.792    
#>   treatment2 - treatment11    -7.50 6.36  6  -1.179   0.283    
#>   treatment2 - treatment12    -0.50 6.36  6  -0.079   0.940    
#>    treatment3 - treatment4    -1.33 4.24  6  -0.314   0.764    
#>    treatment3 - treatment5     3.75 6.36  6   0.590   0.577    
#>    treatment3 - treatment6     3.75 6.36  6   0.590   0.577    
#>    treatment3 - treatment7   -11.50 6.36  6  -1.808   0.121    
#>    treatment3 - treatment8     8.75 6.36  6   1.376   0.218    
#>    treatment3 - treatment9     4.75 6.36  6   0.747   0.483    
#>   treatment3 - treatment10     4.75 6.36  6   0.747   0.483    
#>   treatment3 - treatment11    -4.50 6.36  6  -0.707   0.506    
#>   treatment3 - treatment12     2.50 6.36  6   0.393   0.708    
#>    treatment4 - treatment5     5.08 6.36  6   0.799   0.455    
#>    treatment4 - treatment6     5.08 6.36  6   0.799   0.455    
#>    treatment4 - treatment7   -10.17 6.36  6  -1.598   0.161    
#>    treatment4 - treatment8    10.08 6.36  6   1.585   0.164    
#>    treatment4 - treatment9     6.08 6.36  6   0.956   0.376    
#>   treatment4 - treatment10     6.08 6.36  6   0.956   0.376    
#>   treatment4 - treatment11    -3.17 6.36  6  -0.498   0.636    
#>   treatment4 - treatment12     3.83 6.36  6   0.603   0.569    
#>    treatment5 - treatment6     0.00 8.21  6   0.000   1.000    
#>    treatment5 - treatment7   -15.25 8.21  6  -1.857   0.113    
#>    treatment5 - treatment8     5.00 8.21  6   0.609   0.565    
#>    treatment5 - treatment9     1.00 7.34  6   0.136   0.896    
#>   treatment5 - treatment10     1.00 8.21  6   0.122   0.907    
#>   treatment5 - treatment11    -8.25 8.21  6  -1.005   0.354    
#>   treatment5 - treatment12    -1.25 8.21  6  -0.152   0.884    
#>    treatment6 - treatment7   -15.25 8.21  6  -1.857   0.113    
#>    treatment6 - treatment8     5.00 7.34  6   0.681   0.521    
#>    treatment6 - treatment9     1.00 8.21  6   0.122   0.907    
#>   treatment6 - treatment10     1.00 7.34  6   0.136   0.896    
#>   treatment6 - treatment11    -8.25 8.21  6  -1.005   0.354    
#>   treatment6 - treatment12    -1.25 8.21  6  -0.152   0.884    
#>    treatment7 - treatment8    20.25 8.21  6   2.466   0.049   *
#>    treatment7 - treatment9    16.25 8.21  6   1.979   0.095    
#>   treatment7 - treatment10    16.25 8.21  6   1.979   0.095    
#>   treatment7 - treatment11     7.00 7.34  6   0.953   0.377    
#>   treatment7 - treatment12    14.00 7.34  6   1.906   0.105    
#>    treatment8 - treatment9    -4.00 8.21  6  -0.487   0.643    
#>   treatment8 - treatment10    -4.00 7.34  6  -0.545   0.606    
#>   treatment8 - treatment11   -13.25 8.21  6  -1.614   0.158    
#>   treatment8 - treatment12    -6.25 8.21  6  -0.761   0.475    
#>   treatment9 - treatment10    -0.00 8.21  6  -0.000   1.000    
#>   treatment9 - treatment11    -9.25 8.21  6  -1.126   0.303    
#>   treatment9 - treatment12    -2.25 8.21  6  -0.274   0.793    
#>  treatment10 - treatment11    -9.25 8.21  6  -1.126   0.303    
#>  treatment10 - treatment12    -2.25 8.21  6  -0.274   0.793    
#>  treatment11 - treatment12     7.00 7.34  6   0.953   0.377    
#> 
#> Treatment Groups
#> ================
#> 
#> Method : lsd
#> 
#>  Treatment Adjusted Means   SE df lower.CL upper.CL Group
#>          8          73.25 5.61  6    59.52    86.98    1 
#>          9          77.25 5.61  6    63.52    90.98    12
#>         10          77.25 5.61  6    63.52    90.98    12
#>          5          78.25 5.61  6    64.52    91.98    12
#>          6          78.25 5.61  6    64.52    91.98    12
#>          2          79.00 3.00  6    71.66    86.34    12
#>         12          79.50 5.61  6    65.77    93.23    12
#>          3          82.00 3.00  6    74.66    89.34    12
#>          4          83.33 3.00  6    76.00    90.67    12
#>          1          84.67 3.00  6    77.33    92.00    12
#>         11          86.50 5.61  6    72.77   100.23    12
#>          7          93.50 5.61  6    79.77   107.23     2
# Results for variable y2
out2 <- augmentedRCBD(data$blk, data$trt, data$y1, method.comp = "lsd",
                      alpha = 0.05, group = TRUE, console = TRUE)
#> 
#> Augmented Design Details
#> ========================
#>                                        
#> Number of blocks           "3"         
#> Number of treatments       "12"        
#> Number of check treatments "4"         
#> Number of test treatments  "8"         
#> Check treatments           "1, 2, 3, 4"
#> 
#> 
#> ANOVA, Treatment Adjusted
#> =========================
#>                                      Df Sum Sq Mean Sq F value Pr(>F)  
#> Block (ignoring Treatments)           2  360.1  180.04   6.675 0.0298 *
#> Treatment (eliminating Blocks)       11  285.1   25.92   0.961 0.5499  
#>   Treatment: Check                    3   52.9   17.64   0.654 0.6092  
#>   Treatment: Test and Test vs. Check  8  232.2   29.02   1.076 0.4779  
#> Residuals                             6  161.8   26.97                 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> ANOVA, Block Adjusted
#> =====================
#>                                Df Sum Sq Mean Sq F value Pr(>F)
#> Treatment (ignoring Blocks)    11  575.7   52.33   1.940  0.215
#>   Treatment: Check              3   52.9   17.64   0.654  0.609
#>   Treatment: Test               7  505.9   72.27   2.679  0.125
#>   Treatment: Test vs. Check     1   16.9   16.87   0.626  0.459
#> Block (eliminating Treatments)  2   69.5   34.75   1.288  0.342
#> Residuals                       6  161.8   26.97               
#> 
#> Coefficient of Variation
#> ========================
#> 6.372367
#> 
#> Overall Adjusted Mean
#> =====================
#> 81.0625
#> 
#> Standard Errors
#> ===============
#>                                          Std. Error of Diff.  CD (5%)
#> Control Treatment Means                             4.240458 10.37603
#> Two Test Treatments (Same Block)                    7.344688 17.97180
#> Two Test Treatments (Different Blocks)              8.211611 20.09309
#> A Test Treatment and a Control Treatment            6.704752 16.40594
#> 
#> Treatment Means
#> ===============
#>  Treatment Block Means   SE r   Min   Max Adjusted Means
#>          1       84.67 3.84 3 79.00 92.00          84.67
#>         10     3 74.00 <NA> 1 74.00 74.00          77.25
#>         11     1 89.00 <NA> 1 89.00 89.00          86.50
#>         12     1 82.00 <NA> 1 82.00 82.00          79.50
#>          2       79.00 1.15 3 77.00 81.00          79.00
#>          3       82.00 2.65 3 78.00 87.00          82.00
#>          4       83.33 3.93 3 78.00 91.00          83.33
#>          5     2 79.00 <NA> 1 79.00 79.00          78.25
#>          6     3 75.00 <NA> 1 75.00 75.00          78.25
#>          7     1 96.00 <NA> 1 96.00 96.00          93.50
#>          8     3 70.00 <NA> 1 70.00 70.00          73.25
#>          9     2 78.00 <NA> 1 78.00 78.00          77.25
#> 
#> 
#> Comparisons
#> ===========
#> 
#> Method : lsd
#> 
#>                   contrast estimate   SE df t.ratio p.value sig
#>    treatment1 - treatment2     5.67 4.24  6   1.336   0.230    
#>    treatment1 - treatment3     2.67 4.24  6   0.629   0.553    
#>    treatment1 - treatment4     1.33 4.24  6   0.314   0.764    
#>    treatment1 - treatment5     6.42 6.36  6   1.009   0.352    
#>    treatment1 - treatment6     6.42 6.36  6   1.009   0.352    
#>    treatment1 - treatment7    -8.83 6.36  6  -1.389   0.214    
#>    treatment1 - treatment8    11.42 6.36  6   1.795   0.123    
#>    treatment1 - treatment9     7.42 6.36  6   1.166   0.288    
#>   treatment1 - treatment10     7.42 6.36  6   1.166   0.288    
#>   treatment1 - treatment11    -1.83 6.36  6  -0.288   0.783    
#>   treatment1 - treatment12     5.17 6.36  6   0.812   0.448    
#>    treatment2 - treatment3    -3.00 4.24  6  -0.707   0.506    
#>    treatment2 - treatment4    -4.33 4.24  6  -1.022   0.346    
#>    treatment2 - treatment5     0.75 6.36  6   0.118   0.910    
#>    treatment2 - treatment6     0.75 6.36  6   0.118   0.910    
#>    treatment2 - treatment7   -14.50 6.36  6  -2.280   0.063    
#>    treatment2 - treatment8     5.75 6.36  6   0.904   0.401    
#>    treatment2 - treatment9     1.75 6.36  6   0.275   0.792    
#>   treatment2 - treatment10     1.75 6.36  6   0.275   0.792    
#>   treatment2 - treatment11    -7.50 6.36  6  -1.179   0.283    
#>   treatment2 - treatment12    -0.50 6.36  6  -0.079   0.940    
#>    treatment3 - treatment4    -1.33 4.24  6  -0.314   0.764    
#>    treatment3 - treatment5     3.75 6.36  6   0.590   0.577    
#>    treatment3 - treatment6     3.75 6.36  6   0.590   0.577    
#>    treatment3 - treatment7   -11.50 6.36  6  -1.808   0.121    
#>    treatment3 - treatment8     8.75 6.36  6   1.376   0.218    
#>    treatment3 - treatment9     4.75 6.36  6   0.747   0.483    
#>   treatment3 - treatment10     4.75 6.36  6   0.747   0.483    
#>   treatment3 - treatment11    -4.50 6.36  6  -0.707   0.506    
#>   treatment3 - treatment12     2.50 6.36  6   0.393   0.708    
#>    treatment4 - treatment5     5.08 6.36  6   0.799   0.455    
#>    treatment4 - treatment6     5.08 6.36  6   0.799   0.455    
#>    treatment4 - treatment7   -10.17 6.36  6  -1.598   0.161    
#>    treatment4 - treatment8    10.08 6.36  6   1.585   0.164    
#>    treatment4 - treatment9     6.08 6.36  6   0.956   0.376    
#>   treatment4 - treatment10     6.08 6.36  6   0.956   0.376    
#>   treatment4 - treatment11    -3.17 6.36  6  -0.498   0.636    
#>   treatment4 - treatment12     3.83 6.36  6   0.603   0.569    
#>    treatment5 - treatment6     0.00 8.21  6   0.000   1.000    
#>    treatment5 - treatment7   -15.25 8.21  6  -1.857   0.113    
#>    treatment5 - treatment8     5.00 8.21  6   0.609   0.565    
#>    treatment5 - treatment9     1.00 7.34  6   0.136   0.896    
#>   treatment5 - treatment10     1.00 8.21  6   0.122   0.907    
#>   treatment5 - treatment11    -8.25 8.21  6  -1.005   0.354    
#>   treatment5 - treatment12    -1.25 8.21  6  -0.152   0.884    
#>    treatment6 - treatment7   -15.25 8.21  6  -1.857   0.113    
#>    treatment6 - treatment8     5.00 7.34  6   0.681   0.521    
#>    treatment6 - treatment9     1.00 8.21  6   0.122   0.907    
#>   treatment6 - treatment10     1.00 7.34  6   0.136   0.896    
#>   treatment6 - treatment11    -8.25 8.21  6  -1.005   0.354    
#>   treatment6 - treatment12    -1.25 8.21  6  -0.152   0.884    
#>    treatment7 - treatment8    20.25 8.21  6   2.466   0.049   *
#>    treatment7 - treatment9    16.25 8.21  6   1.979   0.095    
#>   treatment7 - treatment10    16.25 8.21  6   1.979   0.095    
#>   treatment7 - treatment11     7.00 7.34  6   0.953   0.377    
#>   treatment7 - treatment12    14.00 7.34  6   1.906   0.105    
#>    treatment8 - treatment9    -4.00 8.21  6  -0.487   0.643    
#>   treatment8 - treatment10    -4.00 7.34  6  -0.545   0.606    
#>   treatment8 - treatment11   -13.25 8.21  6  -1.614   0.158    
#>   treatment8 - treatment12    -6.25 8.21  6  -0.761   0.475    
#>   treatment9 - treatment10    -0.00 8.21  6  -0.000   1.000    
#>   treatment9 - treatment11    -9.25 8.21  6  -1.126   0.303    
#>   treatment9 - treatment12    -2.25 8.21  6  -0.274   0.793    
#>  treatment10 - treatment11    -9.25 8.21  6  -1.126   0.303    
#>  treatment10 - treatment12    -2.25 8.21  6  -0.274   0.793    
#>  treatment11 - treatment12     7.00 7.34  6   0.953   0.377    
#> 
#> Treatment Groups
#> ================
#> 
#> Method : lsd
#> 
#>  Treatment Adjusted Means   SE df lower.CL upper.CL Group
#>          8          73.25 5.61  6    59.52    86.98    1 
#>          9          77.25 5.61  6    63.52    90.98    12
#>         10          77.25 5.61  6    63.52    90.98    12
#>          5          78.25 5.61  6    64.52    91.98    12
#>          6          78.25 5.61  6    64.52    91.98    12
#>          2          79.00 3.00  6    71.66    86.34    12
#>         12          79.50 5.61  6    65.77    93.23    12
#>          3          82.00 3.00  6    74.66    89.34    12
#>          4          83.33 3.00  6    76.00    90.67    12
#>          1          84.67 3.00  6    77.33    92.00    12
#>         11          86.50 5.61  6    72.77   100.23    12
#>          7          93.50 5.61  6    79.77   107.23     2

# Make cluster
library(parallel)
ncores <- max(2, parallel::detectCores() - 2)

# Pairwise t test without p value adjustment
cl <- makeCluster(getOption("cl.cores", ncores))
pout1 <- pairwise.augmentedRCBD(out1, cl = cl,
                                p.adjust = "none")
stopCluster(cl)

cl <- makeCluster(getOption("cl.cores", ncores))
pout2 <- pairwise.augmentedRCBD(out1, cl = cl,
                                p.adjust = "none")
stopCluster(cl)

# Pairwise t test with tukey adjustment
cl <- makeCluster(getOption("cl.cores", ncores))
pout1_tukey <- pairwise.augmentedRCBD(out1, cl = cl,
                                      p.adjust = "tukey")
stopCluster(cl)

cl <- makeCluster(getOption("cl.cores", ncores))
pout2_tukey <- pairwise.augmentedRCBD(out1, cl = cl,
                                      p.adjust = "tukey")
stopCluster(cl)

# Pairwise t test with sidak p value adjustment
cl <- makeCluster(getOption("cl.cores", ncores))
pout1_sidak <- pairwise.augmentedRCBD(out1, cl = cl,
                                      p.adjust = "sidak")
stopCluster(cl)

cl <- makeCluster(getOption("cl.cores", ncores))
pout2_sidak <- pairwise.augmentedRCBD(out1, cl = cl,
                                      p.adjust = "sidak")
stopCluster(cl)