statsExpressions (version 0.3.1)

expr_t_nonparametric: Making expression for Mann-Whitney U-test/Wilcoxon test results

Description

Making expression for Mann-Whitney U-test/Wilcoxon test results

Usage

expr_t_nonparametric(
  data,
  x,
  y,
  paired = FALSE,
  k = 2,
  conf.level = 0.95,
  conf.type = "norm",
  nboot = 100,
  stat.title = NULL,
  messages = TRUE,
  ...
)

expr_mann_nonparametric( data, x, y, paired = FALSE, k = 2, conf.level = 0.95, conf.type = "norm", nboot = 100, stat.title = NULL, messages = TRUE, ... )

Arguments

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 data.

y

The response (a.k.a. outcome or dependent) variable from the dataframe data.

paired

Logical that decides whether the experimental design is repeated measures/within-subjects or between-subjects. The default is FALSE.

k

Number of digits after decimal point (should be an integer) (Default: k = 2).

conf.level

Scalar between 0 and 1. If unspecified, the defaults return 95% lower and upper confidence intervals (0.95).

conf.type

A vector of character strings representing the type of intervals required. The value should be any subset of the values "norm", "basic", "perc", "bca". For more, see ?boot::boot.ci.

nboot

Number of bootstrap samples for computing confidence interval for the effect size (Default: 100).

stat.title

A character describing the test being run, which will be added as a prefix in the subtitle. The default is NULL. An example of a stat.title argument will be something like "Student's t-test: ".

messages

Decides whether messages references, notes, and warnings are to be displayed (Default: TRUE).

...

Additional arguments (currently ignored).

Details

For the two independent samples case, the Mann-Whitney U-test 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/between-subjects designs, and to total number of pairs (and not observations) for repeated measures/within-subjects 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.

References

For more details, see- https://indrajeetpatil.github.io/statsExpressions/articles/stats_details.html

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# for reproducibility
set.seed(123)

# -------------- between-subjects design ------------------------
# simple function call
statsExpressions::expr_t_nonparametric(
  data = sleep,
  x = group,
  y = extra
)

# creating a smaller dataset
msleep_short <- dplyr::filter(
  .data = ggplot2::msleep,
  vore %in% c("carni", "herbi")
)

# modifying few things
statsExpressions::expr_t_nonparametric(
  data = msleep_short,
  x = vore,
  y = sleep_rem,
  nboot = 200,
  conf.level = 0.99,
  conf.type = "bca"
)

# The order of the grouping factor matters when computing *V*
# Changing default alphabetical order manually
msleep_short$vore <- factor(msleep_short$vore,
  levels = c("herbi", "carni")
)

# note the change in the reported *V* value but the identical
# value for *p* and the reversed effect size
statsExpressions::expr_t_nonparametric(
  data = msleep_short,
  x = vore,
  y = sleep_rem
)

# -------------- within-subjects design ------------------------
# using dataset included in the package
statsExpressions::expr_t_nonparametric(
  data = VR_dilemma,
  x = modality,
  y = score,
  paired = TRUE,
  conf.level = 0.90,
  conf.type = "perc",
  nboot = 200,
  k = 5
)
# }

Run the code above in your browser using DataLab