R/helpers_t_test.R
expr_t_nonparametric.Rd
Making expression for MannWhitney Utest/Wilcoxon test results
expr_t_nonparametric( data, x, y, subject.id = NULL, paired = FALSE, k = 2L, conf.level = 0.95, conf.type = "norm", nboot = 100, output = "expression", ... )
data  A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted. 

x  The grouping variable from the dataframe 
y  The response (a.k.a. outcome or dependent) variable from the
dataframe 
subject.id  In case of repeated measures design ( 
paired  Logical that decides whether the experimental design is
repeated measures/withinsubjects or betweensubjects. The default is

k  Number of digits after decimal point (should be an integer)
(Default: 
conf.level  Scalar between 0 and 1. If unspecified, the defaults return

conf.type  A vector of character strings representing the type of
intervals required. The value should be any subset of the values 
nboot  Number of bootstrap samples for computing confidence interval
for the effect size (Default: 
output  If 
...  Additional arguments (currently ignored). 
For the two independent samples case, the MannWhitney Utest is calculated and W is reported from stats::wilcox.test. For the paired samples case the Wilcoxon signed rank test is run and V is reported.
Since there is no single commonly accepted method for reporting effect size for these tests we are computing and reporting r (computed as \(Z/\sqrt{N}\)) along with the confidence intervals associated with the estimate. Note that N here corresponds to total sample size for independent/betweensubjects designs, and to total number of pairs (and not observations) for repeated measures/withinsubjects designs.
Note: The stats::wilcox.test function does not follow the same convention as stats::t.test. The sign of the V test statistic will always be positive since it is the sum of the positive signed ranks. Therefore, V will vary in magnitude but not significance based solely on the order of the grouping variable. Consider manually reordering your factor levels if appropriate as shown in the second example below.
For more details, see https://indrajeetpatil.github.io/statsExpressions/articles/stats_details.html
# for reproducibility set.seed(123) library(statsExpressions) #  betweensubjects design  expr_t_nonparametric( data = sleep, x = group, y = extra )#> paste("log"["e"](italic("W")["MannWhitney"]), " = ", "3.24", #> ", ", italic("p"), " = ", "0.069", ", ", widehat(italic("r")), #> " = ", "0.41", ", CI"["95%"], " [", "0.84", ", ", "0.04", #> "]", ", ", italic("n")["obs"], " = ", 20L)#  withinsubjects design  expr_t_nonparametric( data = VR_dilemma, x = modality, y = score, paired = TRUE, subject.id = id )#> paste("log"["e"](italic("V")["Wilcoxon"]), " = ", "1.50", ", ", #> italic("p"), " = ", "0.001", ", ", widehat(italic("r")), #> " = ", "0.57", ", CI"["95%"], " [", "0.67", ", ", "0.44", #> "]", ", ", italic("n")["pairs"], " = ", 34L)