Function to run two-sample Wilcoxon tests on multiple variables across multiple grouping variables.

Running Wilcox test across multiple grouping variables.

grouped_wilcox(
  data,
  dep.vars,
  indep.vars,
  grouping.vars,
  paired = FALSE,
  correct = TRUE
)

Arguments

data

Dataframe from which variables are to be taken.

dep.vars

List dependent variables for a two-sample Wilcoxon tests (y in y ~ x).

indep.vars

List independent variables for a two-sample Wilcoxon tests (x in y ~ x).

grouping.vars

List of grouping variables (if NULL, the entire dataframe will be used).

paired

A logical indicating whether you want a paired two-sample Wilcoxon tests (Default: paired = FALSE).

correct

A logical indicating whether to apply continuity correction in the normal approximation for the p-value (Default: correct = TRUE).

Value

A tibble dataframe with tidy results from two-sample Wilcoxon tests analyses.

See also

Examples

# for reproducibility set.seed(123) # only with one grouping variable groupedstats::grouped_wilcox( data = dplyr::filter(.data = ggplot2::diamonds, color == "E" | color == "J"), dep.vars = depth:table, indep.vars = color, grouping.vars = clarity, paired = FALSE )
#> # A tibble: 16 x 9 #> clarity formula method #> <ord> <chr> <chr> #> 1 SI2 depth ~ color Wilcoxon rank sum test with continuity correction #> 2 SI1 depth ~ color Wilcoxon rank sum test with continuity correction #> 3 VS1 depth ~ color Wilcoxon rank sum test with continuity correction #> 4 VVS2 depth ~ color Wilcoxon rank sum test with continuity correction #> 5 VS2 depth ~ color Wilcoxon rank sum test with continuity correction #> 6 I1 depth ~ color Wilcoxon rank sum test with continuity correction #> 7 VVS1 depth ~ color Wilcoxon rank sum test with continuity correction #> 8 IF depth ~ color Wilcoxon rank sum test with continuity correction #> 9 SI2 table ~ color Wilcoxon rank sum test with continuity correction #> 10 SI1 table ~ color Wilcoxon rank sum test with continuity correction #> 11 VS1 table ~ color Wilcoxon rank sum test with continuity correction #> 12 VVS2 table ~ color Wilcoxon rank sum test with continuity correction #> 13 VS2 table ~ color Wilcoxon rank sum test with continuity correction #> 14 I1 table ~ color Wilcoxon rank sum test with continuity correction #> 15 VVS1 table ~ color Wilcoxon rank sum test with continuity correction #> 16 IF table ~ color Wilcoxon rank sum test with continuity correction #> statistic estimate conf.low conf.high p.value significance #> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> #> 1 380600 -0.200 -0.300 -0.0000364 1.54e- 2 * #> 2 918892 0.0000393 -0.100 0.100 6.77e- 1 ns #> 3 276743 -0.400 -0.500 -0.300 7.03e-12 *** #> 4 52618 -0.400 -0.600 -0.200 4.18e- 4 *** #> 5 816784. -0.200 -0.300 -0.100 8.86e- 5 *** #> 6 1570. -2.00 -3.00 -1.00 1.21e- 4 *** #> 7 19455 -0.300 -0.500 -0.100 5.07e- 3 ** #> 8 3286 -0.300 -0.700 -0.0000251 4.79e- 2 * #> 9 388138. -0.0000208 -0.0000391 0.00000498 6.85e- 2 ns #> 10 880016. 0 -0.0000130 0.0000362 1.71e- 1 ns #> 11 306400 -0.00000482 -1.00 -0.0000287 6.16e- 5 *** #> 12 54524 -1.00 -1.00 -0.0000587 2.60e- 3 ** #> 13 763942. -1.00 -1.00 -0.0000461 1.65e-10 *** #> 14 2900 1.00 -0.0000280 2.00 1.68e- 1 ns #> 15 22659 -0.00000772 -1.00 0.00000405 3.42e- 1 ns #> 16 3987 -0.0000335 -1.00 1.00 9.11e- 1 ns