Sample.
Optionaly: Sample | WilcoxTestOptions
Second sample for a two-sample or paired test. May be omitted, and the options
passed in its place: wilcoxTest(x, { mu: 1 }).
Optionaloptions: WilcoxTestOptions
See WilcoxTestOptions.
The test result; see WilcoxTestResult.
const x = [1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30];
const y = [0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29];
const r = wilcoxTest(x, y, { paired: true, alternative: "greater" });
r.statistic; // 40 (V)
r.pValue; // 0.01953125
There is also a formula form, wilcoxTest("y ~ g", data, options) (next overload).
Wilcoxon tests from a formula and a data frame. As R's wilcox.test(formula, data): "y ~ g" is the
rank sum test of the two levels of g (the first level is x), "y ~ 1" the signed rank test and
"Pair(a, b) ~ 1" the paired test of a and b (the option paired is not allowed). Only the variables of the
formula count: the rows where one of them is missing are dropped.
"y ~ g", "y ~ 1" or "Pair(a, b) ~ 1".
The data frame: an object of columns (null or NaN for a missing value).
Optionaloptions: WilcoxTestOptions
See WilcoxTestOptions.
Wilcoxon signed rank and rank sum (Mann-Whitney) tests. Equivalent to R's
wilcox.test().With one sample (or
paired: true) performs the signed rank test; with two samples the rank sum test. The choice between exact and normal-approximation p-values, the Hodges-Lehmann estimates and the confidence intervals follow R 4.6: with ties or zeros the exact test is the conditional test given the mid-ranks, and an exact interval reports the confidence level it achieves. OnlyNaNis dropped; infinite values are kept and ranked (as R actually does). Where R 4.6.2 is wrong, the one-sample conditional interval and small two-sided normal p-values, see docs/differences-from-r.md.