R/MRtest.R
MRtest.Rd
MRtest
applies the Means grouping based on midrange, Means Grouping
based on Range, Student-Newman-Keuls based on midrange and
Tukey based on midrange tests.
These are new tests for multiple comparisons proposed by the
authors (BATISTA, 2016), that are being published.
MRtest( y, trt = NULL, dferror = NULL, mserror = NULL, replication = NULL, alpha = 0.05, main = NULL, MCP = "all", ismean = FALSE )
y | Model (aov or lm), numeric vector containing the response variable or the mean of the treatments. |
---|---|
trt | Constant (y = model) or a vector containing the treatments. |
dferror | Degrees of freedom of the Mean Square Error. |
mserror | Mean Square Error. |
replication | Number de repetitions of the treatments in the experiment.
For unbalanced data should be informed the harmonic mean of repetitions.
This argument should be informed only if |
alpha | Significant level. The default is |
main | Title of the analysis. |
MCP | Allows choosing the multiple comparison test; the defaut is "all". This option will go perform all tests. However, the options are: the Means grouping based on midrange test ("MGM"), Means Grouping based on Range test ("MGR"), the Student-Newman-Keuls based on midrange test ("SNKM") and the Tukey based on midrange test ("TM"). |
ismean | Logic. If |
MRtest
returns the print of a list of results. First,
the summary of y
. Second, the statistics
of the test chosen. And finally, the mean group results for each test.
If MRtest
function is stored
in an object, the results will be printed and
also stored in the object.
The MCP
argument allows you to choose various tests
of multiple comparisons at once. For example,
MCP = c("MGM", "MGR")
, and so on.
# Simulated data (completely randomized design) # Response variable rv <- c(100.08, 105.66, 97.64, 100.11, 102.60, 121.29, 100.80, 99.11, 104.43, 122.18, 119.49, 124.37, 123.19, 134.16, 125.67, 128.88, 148.07, 134.27, 151.53, 127.31) # Treatments treat <- factor(rep(LETTERS[1:5], each = 4)) # Anova res <- anova(aov(rv~treat)) DFerror <- res$Df[2] MSerror <- res$`Mean Sq`[2] # Loading the midrangeMCP package library(midrangeMCP) # applying the tests results <- MRtest(y = rv, trt = treat, dferror = DFerror, mserror = MSerror, alpha = 0.05, main = "Multiple Comparison Procedure: MGM test", MCP = c("MGM"))#> MCP's based on distributions of the studentized midrange and range #> #> Study: Multiple Comparison Procedure: MGM test #> #> Summary: #> Means std r Min Max #> A 100.87 3.40 4 97.64 105.66 #> B 105.95 10.33 4 99.11 121.29 #> C 117.62 9.02 4 104.43 124.37 #> D 127.97 4.74 4 123.19 134.16 #> E 140.30 11.42 4 127.31 151.53 #> #> Mean Grouping Midrange Test #> #> Statistics: #> Exp.Mean CV MSerror Df n Stud.Midrange Ext.DMS Int.DMS #> 118.542 7.08182 70.47488 15 5 1.089968 5.90246 4.575105 #> #> Groups: #> Means Groups #> E 140.30 g1 #> D 127.97 g2 #> C 117.62 g3 #> B 105.95 g4 #> A 100.87 g4# Other option for the MCP argument is "all". All tests are used. results$Groups # Results of the tests#> $group.MGM #> Means Groups #> E 140.30 g1 #> D 127.97 g2 #> C 117.62 g3 #> B 105.95 g4 #> A 100.87 g4 #>results$Statistics # Main arguments of the tests#> $Statistics.MGM #> Exp.Mean CV MSerror Df n Stud.Midrange Ext.DMS Int.DMS #> 118.542 7.08182 70.47488 15 5 1.089968 5.90246 4.575105 #>results$Summary # Summary of the response variable#> Means std r Min Max #> A 100.87 3.40 4 97.64 105.66 #> B 105.95 10.33 4 99.11 121.29 #> C 117.62 9.02 4 104.43 124.37 #> D 127.97 4.74 4 123.19 134.16 #> E 140.30 11.42 4 127.31 151.53# Using the y argument as aov or lm model res <- aov(rv~treat) MRtest(y = res, trt = "treat", alpha = 0.05, main = "Multiple Comparison Procedure: MGM test", MCP = c("MGM"))#> MCP's based on distributions of the studentized midrange and range #> #> Study: Multiple Comparison Procedure: MGM test #> #> Summary: #> Means std r Min Max #> A 100.87 3.40 4 97.64 105.66 #> B 105.95 10.33 4 99.11 121.29 #> C 117.62 9.02 4 104.43 124.37 #> D 127.97 4.74 4 123.19 134.16 #> E 140.30 11.42 4 127.31 151.53 #> #> Mean Grouping Midrange Test #> #> Statistics: #> Exp.Mean CV MSerror Df n Stud.Midrange Ext.DMS Int.DMS #> 118.542 7.08182 70.47488 15 5 1.089968 5.90246 4.575105 #> #> Groups: #> Means Groups #> E 140.30 g1 #> D 127.97 g2 #> C 117.62 g3 #> B 105.95 g4 #> A 100.87 g4# For unbalanced data: It will be used the harmonic mean of # the number of experiment replicates # Using the previous example rv <- rv[-1] treat <- treat[-1] res <- lm(rv~treat) # Linear model # Multiple comparison procedure: MGR test MRtest(y = res, trt = "treat", alpha = 0.05, main = "Multiple Comparison Procedure: MGR test", MCP = c("MGR"))#> MCP's based on distributions of the studentized midrange and range #> #> Study: Multiple Comparison Procedure: MGR test #> #> Unbalanced data: It will be used the harmonic mean of #> #> the number of experiment replicates #> Summary: #> Means std r Min Max #> A 101.14 4.11 3.75 97.64 105.66 #> B 105.95 10.33 3.75 99.11 121.29 #> C 117.62 9.02 3.75 104.43 124.37 #> D 127.97 4.74 3.75 123.19 134.16 #> E 140.30 11.42 3.75 127.31 151.53 #> #> Harmonic mean of the number of experiment replicates 3.75 #> #> Mean Grouping Range Test #> #> Statistics: #> Exp.Mean CV MSerror Df n Stud.Range DMS #> 119.5137 7.267902 75.44898 14 5 4.40661 19.76586 #> #> Groups: #> Means Groups #> E 140.30 g1 #> D 127.97 g2 #> C 117.62 g2 #> B 105.95 g3 #> A 101.14 g3# Assuming that the available data are the averages # of the treatments and the analysis of variance # Analysis of Variance Table # Response: rv # Df Sum Sq Mean Sq F value Pr(>F) # treat 4 4135.2 1033.80 14.669 4.562e-05 *** # Residuals 15 1057.1 70.47 mean.treat <- c(100.87, 105.95, 117.62, 127.97, 140.30) treat <- factor(LETTERS[1:5]) DFerror <- 15 MSerror <- 70.47488 replic <- 4 MRtest(y = mean.treat, trt = treat, dferror = DFerror, mserror = MSerror, replication = replic, alpha = 0.05, main = "Multiple Comparison Procedure: MGM test", MCP = c("MGM"), ismean = TRUE)#> MCP's based on distributions of the studentized midrange and range #> #> Study: Multiple Comparison Procedure: MGM test #> #> Summary: #> Means r #> 1 100.87 4 #> 2 105.95 4 #> 3 117.62 4 #> 4 127.97 4 #> 5 140.30 4 #> #> Mean Grouping Midrange Test #> #> Statistics: #> Exp.Mean CV MSerror Df n Stud.Midrange Ext.DMS Int.DMS #> 118.542 7.081821 70.47488 15 5 1.089968 5.90246 4.575105 #> #> Groups: #> Means Groups #> E 140.30 g1 #> D 127.97 g2 #> C 117.62 g3 #> B 105.95 g4 #> A 100.87 g4