ggstatsplot (version 0.0.12)

subtitle_mann_nonparametric: Making text subtitle for the Mann-Whitney U-test (between-subjects designs).

Description

Making text subtitle for the Mann-Whitney U-test (between-subjects designs).

Usage

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

subtitle_t_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 design is repeated measures/within-subjects (in which case one-way Friedman Rank Sum Test will be carried out) or between-subjects (in which case one-way Kruskal<U+2013>Wallis H test will be carried out). 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.

Details

Two-sample Wilcoxon test, also known as Mann-Whitney test, is carried out.

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.

Examples

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

# -------------- between-subjects design ------------------------
# simple function call
ggstatsplot::subtitle_mann_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
ggstatsplot::subtitle_mann_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 alphabeical 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
ggstatsplot::subtitle_mann_nonparametric(
  data = msleep_short,
  x = vore,
  y = sleep_rem
)

# -------------- within-subjects design ------------------------
# using dataset included in the package
ggstatsplot::subtitle_mann_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 DataCamp Workspace