@numero-uno-jpn/rstats 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.ja.md +13 -9
- package/README.md +13 -8
- package/dist/chunks/{chunk-QJJWGNJP.js → chunk-2X7JYQBI.js} +2 -2
- package/dist/chunks/{chunk-O6PT7IVU.js → chunk-36GVER3O.js} +2 -2
- package/dist/chunks/{chunk-EWC6I75B.js → chunk-3WUXRSM6.js} +1 -1
- package/dist/chunks/{chunk-4NM37MGA.js → chunk-6I6QKTFK.js} +2 -2
- package/dist/chunks/{chunk-2XKG3DX4.js → chunk-ETOEZTGL.js} +1 -1
- package/dist/chunks/{chunk-IT354SHV.js → chunk-FVPDVRJQ.js} +2 -2
- package/dist/chunks/{chunk-QULPY6YM.js → chunk-GG4BJMJW.js} +1 -1
- package/dist/chunks/{chunk-7HPVUVZB.js → chunk-HITD7CX6.js} +1 -1
- package/dist/chunks/{chunk-LIMZKONM.js → chunk-KK4GE65D.js} +2 -2
- package/dist/chunks/chunk-LAUYSGV4.js +3 -0
- package/dist/chunks/chunk-M6GDXKKS.js +2 -0
- package/dist/chunks/{chunk-QFULZNHL.js → chunk-PHHUHR7T.js} +1 -1
- package/dist/chunks/{chunk-ENL43FNO.js → chunk-WQPFDDIY.js} +2 -2
- package/dist/chunks/chunk-X2AWQSVS.js +2 -0
- package/dist/chunks/{chunk-ZRIM4R4A.js → chunk-ZRJQD7VS.js} +2 -2
- package/dist/data/grouping.d.ts +100 -0
- package/dist/data/grouping.js +264 -0
- package/dist/descriptive/basic.d.ts +130 -17
- package/dist/descriptive/basic.js +115 -14
- package/dist/descriptive/cov.d.ts +22 -12
- package/dist/descriptive/dataFrames.d.ts +138 -0
- package/dist/descriptive/dataFrames.js +400 -0
- package/dist/descriptive/factanal.d.ts +26 -6
- package/dist/descriptive/factanal.js +7 -3
- package/dist/descriptive/hist.d.ts +27 -6
- package/dist/descriptive/hist.js +9 -3
- package/dist/descriptive/missing.d.ts +42 -0
- package/dist/descriptive/missing.js +52 -0
- package/dist/descriptive/moments.d.ts +91 -13
- package/dist/descriptive/moments.js +66 -9
- package/dist/descriptive/omega.d.ts +28 -6
- package/dist/descriptive/omega.js +16 -4
- package/dist/descriptive/pivot.d.ts +105 -0
- package/dist/descriptive/pivot.js +347 -0
- package/dist/descriptive/quantile.d.ts +33 -5
- package/dist/descriptive/quantile.js +20 -2
- package/dist/descriptive/rank.d.ts +12 -2
- package/dist/descriptive/rank.js +2 -0
- package/dist/descriptive/table.d.ts +55 -7
- package/dist/descriptive/table.js +38 -4
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.d.ts +40 -5
- package/dist/distributions/arcsine.js +35 -4
- package/dist/distributions/beta.d.ts +12 -0
- package/dist/distributions/beta.js +12 -0
- package/dist/distributions/binomial.d.ts +18 -0
- package/dist/distributions/binomial.js +18 -0
- package/dist/distributions/bvnorm.d.ts +4 -1
- package/dist/distributions/bvnorm.js +4 -1
- package/dist/distributions/cauchy.d.ts +24 -0
- package/dist/distributions/cauchy.js +24 -0
- package/dist/distributions/chisq.d.ts +18 -0
- package/dist/distributions/chisq.js +18 -0
- package/dist/distributions/exponential.d.ts +29 -1
- package/dist/distributions/exponential.js +24 -0
- package/dist/distributions/f.d.ts +18 -0
- package/dist/distributions/f.js +18 -0
- package/dist/distributions/gamma.d.ts +20 -0
- package/dist/distributions/gamma.js +18 -0
- package/dist/distributions/geometric.d.ts +24 -0
- package/dist/distributions/geometric.js +24 -0
- package/dist/distributions/hypergeometric.d.ts +24 -0
- package/dist/distributions/hypergeometric.js +24 -0
- package/dist/distributions/invgamma.d.ts +32 -4
- package/dist/distributions/invgamma.js +27 -3
- package/dist/distributions/kumaraswamy.d.ts +31 -3
- package/dist/distributions/kumaraswamy.js +31 -3
- package/dist/distributions/laplace.d.ts +36 -4
- package/dist/distributions/laplace.js +31 -3
- package/dist/distributions/logistic.d.ts +29 -1
- package/dist/distributions/logistic.js +24 -0
- package/dist/distributions/lognormal.d.ts +29 -1
- package/dist/distributions/lognormal.js +24 -0
- package/dist/distributions/multinomial.d.ts +7 -1
- package/dist/distributions/multinomial.js +2 -0
- package/dist/distributions/negbinomial.d.ts +29 -1
- package/dist/distributions/negbinomial.js +24 -0
- package/dist/distributions/normal.d.ts +11 -1
- package/dist/distributions/normal.js +6 -0
- package/dist/distributions/pareto.d.ts +36 -4
- package/dist/distributions/pareto.js +31 -3
- package/dist/distributions/poisson.d.ts +18 -0
- package/dist/distributions/poisson.js +18 -0
- package/dist/distributions/signrank.d.ts +24 -0
- package/dist/distributions/signrank.js +24 -0
- package/dist/distributions/summary.d.ts +20 -2
- package/dist/distributions/summary.js +4 -0
- package/dist/distributions/t.d.ts +18 -0
- package/dist/distributions/t.js +18 -0
- package/dist/distributions/triangular.d.ts +36 -4
- package/dist/distributions/triangular.js +31 -3
- package/dist/distributions/tukey.d.ts +15 -1
- package/dist/distributions/tukey.js +10 -0
- package/dist/distributions/uniform.d.ts +29 -1
- package/dist/distributions/uniform.js +24 -0
- package/dist/distributions/weibull.d.ts +29 -1
- package/dist/distributions/weibull.js +24 -0
- package/dist/distributions/wilcox.d.ts +24 -0
- package/dist/distributions/wilcox.js +24 -0
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +5 -1
- package/dist/entries/descriptive.js +4 -0
- package/dist/entries/numerics.d.ts +1 -1
- package/dist/entries/tests.js +1 -1
- package/dist/htest/agreement.d.ts +61 -23
- package/dist/htest/agreement.js +19 -9
- package/dist/htest/ansariTest.d.ts +19 -1
- package/dist/htest/ansariTest.js +5 -17
- package/dist/htest/aov.d.ts +43 -10
- package/dist/htest/aov.js +17 -3
- package/dist/htest/binomTest.d.ts +12 -2
- package/dist/htest/binomTest.js +2 -0
- package/dist/htest/brunnerMunzelTest.d.ts +9 -3
- package/dist/htest/brunnerMunzelTest.js +4 -2
- package/dist/htest/chisqTest.d.ts +19 -3
- package/dist/htest/cor.d.ts +31 -3
- package/dist/htest/cor.js +9 -27
- package/dist/htest/effectSize.d.ts +70 -12
- package/dist/htest/effectSize.js +40 -7
- package/dist/htest/fisherTest.d.ts +9 -1
- package/dist/htest/fisherTest.js +2 -0
- package/dist/htest/groups.d.ts +5 -1
- package/dist/htest/ksTest.d.ts +32 -2
- package/dist/htest/ksTest.js +5 -8
- package/dist/htest/leveneTest.d.ts +15 -4
- package/dist/htest/leveneTest.js +5 -2
- package/dist/htest/mantelhaenTest.d.ts +25 -3
- package/dist/htest/mantelhaenTest.js +15 -1
- package/dist/htest/mcnemarTest.d.ts +14 -4
- package/dist/htest/mcnemarTest.js +4 -2
- package/dist/htest/multipleComparisons.d.ts +173 -29
- package/dist/htest/multipleComparisons.js +123 -19
- package/dist/htest/normalityTests.d.ts +56 -9
- package/dist/htest/normalityTests.js +40 -6
- package/dist/htest/onewayTest.d.ts +45 -2
- package/dist/htest/onewayTest.js +15 -7
- package/dist/htest/pAdjust.d.ts +9 -1
- package/dist/htest/pAdjust.js +2 -0
- package/dist/htest/pairwise.d.ts +50 -5
- package/dist/htest/pairwise.js +25 -0
- package/dist/htest/poissonTest.d.ts +12 -2
- package/dist/htest/poissonTest.js +2 -0
- package/dist/htest/polycor.d.ts +29 -10
- package/dist/htest/power.d.ts +60 -6
- package/dist/htest/power.js +6 -0
- package/dist/htest/propTest.d.ts +13 -2
- package/dist/htest/propTest.js +2 -0
- package/dist/htest/pwr.d.ts +286 -36
- package/dist/htest/pwr.js +116 -15
- package/dist/htest/rankTests.d.ts +132 -7
- package/dist/htest/rankTests.js +30 -33
- package/dist/htest/tTest.d.ts +32 -2
- package/dist/htest/tTest.js +19 -24
- package/dist/htest/testFormula.d.ts +57 -0
- package/dist/htest/testFormula.js +171 -0
- package/dist/htest/trendTests.d.ts +29 -8
- package/dist/htest/trendTests.js +8 -4
- package/dist/htest/types.d.ts +14 -2
- package/dist/htest/varTest.d.ts +46 -6
- package/dist/htest/varTest.js +11 -21
- package/dist/htest/wilcoxTest.d.ts +23 -1
- package/dist/htest/wilcoxTest.js +9 -24
- package/dist/internal/dpq.d.ts +4 -0
- package/dist/internal/noncentral.d.ts +2 -0
- package/dist/internal/vectorize.d.ts +4 -0
- package/dist/linalg/basic.d.ts +39 -5
- package/dist/linalg/basic.js +15 -0
- package/dist/linalg/chol.d.ts +26 -5
- package/dist/linalg/chol.js +7 -0
- package/dist/linalg/eigen.d.ts +16 -7
- package/dist/linalg/eigen.js +6 -5
- package/dist/linalg/expm.d.ts +15 -5
- package/dist/linalg/expm.js +5 -3
- package/dist/linalg/kappa.d.ts +21 -1
- package/dist/linalg/kappa.js +16 -0
- package/dist/linalg/lu.d.ts +30 -6
- package/dist/linalg/lu.js +15 -3
- package/dist/linalg/matrix.d.ts +4 -0
- package/dist/linalg/norm.d.ts +16 -1
- package/dist/linalg/norm.js +9 -0
- package/dist/linalg/ops.d.ts +168 -36
- package/dist/linalg/ops.js +116 -20
- package/dist/linalg/qr.d.ts +87 -12
- package/dist/linalg/qr.js +31 -0
- package/dist/linalg/schur.d.ts +8 -2
- package/dist/linalg/schur.js +3 -1
- package/dist/linalg/solve.d.ts +42 -6
- package/dist/linalg/solve.js +22 -0
- package/dist/linalg/svd.d.ts +12 -2
- package/dist/linalg/svd.js +2 -0
- package/dist/linalg.js +2 -2
- package/dist/models/anovaSequential.d.ts +26 -4
- package/dist/models/anovaSequential.js +3 -1
- package/dist/models/aovEz.d.ts +29 -6
- package/dist/models/aovEz.js +5 -2
- package/dist/models/aovStrata.d.ts +12 -2
- package/dist/models/carAnova.d.ts +9 -3
- package/dist/models/carAnova.js +4 -2
- package/dist/models/coxph.d.ts +33 -7
- package/dist/models/coxph.js +8 -3
- package/dist/models/glm.d.ts +128 -21
- package/dist/models/glm.js +71 -14
- package/dist/models/glmAnova.d.ts +30 -5
- package/dist/models/glmAnova.js +15 -2
- package/dist/models/glmConfint.d.ts +16 -2
- package/dist/models/glmConfint.js +9 -1
- package/dist/models/glmFamily.d.ts +27 -5
- package/dist/models/lm.d.ts +75 -17
- package/dist/models/lm.js +22 -4
- package/dist/models/mauchly.d.ts +20 -5
- package/dist/models/mauchly.js +7 -3
- package/dist/models/modelFrame.d.ts +5 -1
- package/dist/models/modelMatrix.d.ts +18 -4
- package/dist/models/modelMatrix.js +3 -1
- package/dist/models/survival.d.ts +41 -9
- package/dist/models/survival.js +10 -4
- package/dist/numerics/deriv.d.ts +21 -6
- package/dist/numerics/deriv.js +16 -5
- package/dist/numerics/integrate.d.ts +37 -7
- package/dist/numerics/integrate.js +8 -2
- package/dist/numerics/interp.d.ts +63 -12
- package/dist/numerics/interp.js +30 -6
- package/dist/numerics/ode.d.ts +15 -5
- package/dist/numerics/ode.js +5 -3
- package/dist/numerics.js +2 -2
- package/dist/optim/optim.d.ts +32 -8
- package/dist/optim/optim.js +8 -4
- package/dist/random/beta.d.ts +8 -0
- package/dist/random/beta.js +8 -0
- package/dist/random/binomial.d.ts +16 -0
- package/dist/random/binomial.js +16 -0
- package/dist/random/continuous.d.ts +51 -0
- package/dist/random/continuous.js +51 -0
- package/dist/random/extra.d.ts +66 -6
- package/dist/random/extra.js +66 -6
- package/dist/random/gamma.d.ts +33 -0
- package/dist/random/gamma.js +33 -0
- package/dist/random/hyper.d.ts +8 -0
- package/dist/random/hyper.js +8 -0
- package/dist/random/poisson.d.ts +25 -0
- package/dist/random/poisson.js +25 -0
- package/dist/random/r2dtable.d.ts +2 -0
- package/dist/random/r2dtable.js +2 -0
- package/dist/random/rank.d.ts +16 -0
- package/dist/random/rank.js +16 -0
- package/dist/random/rng.d.ts +49 -6
- package/dist/random/rng.js +29 -2
- package/dist/random/sample.d.ts +10 -2
- package/dist/random/sample.js +5 -1
- package/dist/random/streams.d.ts +13 -0
- package/dist/random/streams.js +13 -0
- package/dist/rstats.js +14 -14
- package/dist/special/besselIK.d.ts +11 -3
- package/dist/special/besselIK.js +6 -2
- package/dist/special/besselJY.d.ts +6 -2
- package/dist/special/besselJY.js +6 -2
- package/dist/special/beta.d.ts +16 -2
- package/dist/special/beta.js +16 -2
- package/dist/special/choose.d.ts +13 -5
- package/dist/special/choose.js +13 -5
- package/dist/special/erf.d.ts +8 -3
- package/dist/special/erf.js +8 -3
- package/dist/special/extra.d.ts +30 -10
- package/dist/special/extra.js +25 -9
- package/dist/special/gamma.d.ts +18 -2
- package/dist/special/gamma.js +18 -2
- package/dist/special/log1p.d.ts +16 -7
- package/dist/special/log1p.js +16 -7
- package/dist/special/psigamma.d.ts +9 -3
- package/dist/special/psigamma.js +9 -3
- package/dist/special/rCompatible.d.ts +5 -1
- package/dist/special.js +2 -2
- package/dist/tests.js +12 -13
- package/llms.txt +14 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-AECGWZHD.js +0 -2
- package/dist/chunks/chunk-XWTZ4RTR.js +0 -2
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Alternative, type HTest, type Counts } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link fisherTest}.
|
|
4
|
+
*
|
|
5
|
+
* @category Hypothesis tests
|
|
6
|
+
*/
|
|
3
7
|
export interface FisherTestOptions {
|
|
4
8
|
/**
|
|
5
9
|
* Alternative hypothesis: `"two.sided"`, `"less"` or `"greater"`. Default `"two.sided"`.
|
|
@@ -26,6 +30,8 @@ export interface FisherTestOptions {
|
|
|
26
30
|
* `fisher.test()` does not return a statistic. For 2 x 2 tables, `estimate` is the
|
|
27
31
|
* conditional maximum likelihood estimate of the odds ratio and `confInt` its interval;
|
|
28
32
|
* for larger tables only `method`, `alternative` and `pValue` are set.
|
|
33
|
+
*
|
|
34
|
+
* @category Hypothesis tests
|
|
29
35
|
*/
|
|
30
36
|
export interface FisherTestResult extends Omit<HTest, "statistic" | "statisticName"> {
|
|
31
37
|
}
|
|
@@ -55,5 +61,7 @@ export interface FisherTestResult extends Omit<HTest, "statistic" | "statisticNa
|
|
|
55
61
|
* r.estimate; // 6.408308867005792 (conditional MLE of the odds ratio)
|
|
56
62
|
* r.confInt; // [0.2117329153055031, 621.9337505454175]
|
|
57
63
|
* ```
|
|
64
|
+
*
|
|
65
|
+
* @category Hypothesis tests
|
|
58
66
|
*/
|
|
59
67
|
export declare function fisherTest(x: readonly Counts[], options?: FisherTestOptions): FisherTestResult;
|
package/dist/htest/fisherTest.js
CHANGED
|
@@ -65,6 +65,8 @@ import { matchAlternative } from "./types.js";
|
|
|
65
65
|
* r.estimate; // 6.408308867005792 (conditional MLE of the odds ratio)
|
|
66
66
|
* r.confInt; // [0.2117329153055031, 621.9337505454175]
|
|
67
67
|
* ```
|
|
68
|
+
*
|
|
69
|
+
* @category Hypothesis tests
|
|
68
70
|
*/
|
|
69
71
|
export function fisherTest(x, options = {}) {
|
|
70
72
|
const nr = x.length;
|
package/dist/htest/groups.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { Sample } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Group label: a number or a string.
|
|
4
|
+
*
|
|
5
|
+
* @category Hypothesis tests
|
|
6
|
+
*/
|
|
3
7
|
export type GroupLabel = number | string;
|
|
4
8
|
/** Groups with their labels: the sorted labels (x, g form) or the 1-based positions in the list (list form) */
|
|
5
9
|
export interface LabelledGroups {
|
package/dist/htest/ksTest.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { DataFrame } from "../models/modelFrame.js";
|
|
1
2
|
import { type Alternative, type HTest, type Sample } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link ksTest}.
|
|
5
|
+
*
|
|
6
|
+
* @category Hypothesis tests
|
|
7
|
+
*/
|
|
3
8
|
export interface KsTestOptions {
|
|
4
9
|
/**
|
|
5
10
|
* Alternative hypothesis (unambiguous abbreviations accepted). `"greater"`: the distribution function of `x` lies
|
|
@@ -15,17 +20,42 @@ export interface KsTestOptions {
|
|
|
15
20
|
/**
|
|
16
21
|
* Result of {@link ksTest}. As in R, `alternative` describes the hypothesis in words ("two-sided", "the CDF of x lies
|
|
17
22
|
* above the null hypothesis", ...), and `exact` tells whether the p-value is exact.
|
|
23
|
+
*
|
|
24
|
+
* @category Hypothesis tests
|
|
18
25
|
*/
|
|
19
26
|
export interface KsTestResult extends Omit<HTest, "alternative"> {
|
|
27
|
+
/** Description of the alternative hypothesis, as R prints it (e.g. `"two-sided"`). */
|
|
20
28
|
alternative: string;
|
|
29
|
+
/** Whether the p-value is exact. */
|
|
21
30
|
exact: boolean;
|
|
22
31
|
}
|
|
23
32
|
/**
|
|
24
|
-
* Kolmogorov-Smirnov test. Equivalent to R's `ks.test()
|
|
33
|
+
* Kolmogorov-Smirnov test. Equivalent to R's `ks.test()`. Takes a distribution function given as a function (for
|
|
25
34
|
* example `(q) => pnorm(q)`) or a second sample. `NaN` values are dropped.
|
|
26
35
|
*
|
|
27
36
|
* @param x Sample.
|
|
28
37
|
* @param y A continuous distribution function, or a second sample.
|
|
29
38
|
* @param options See {@link KsTestOptions}.
|
|
39
|
+
*
|
|
40
|
+
* There is also a formula form for two samples, `ksTest("y ~ g", data, options)` (next overload).
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const x = [0.61, -1.2, 0.33, 1.57, -0.42, 0.08, -0.85, 1.1];
|
|
45
|
+
* ksTest(x, (q) => pnorm(q)).pValue; // 0.9716870044206776
|
|
46
|
+
* ksTest(x, [0.9, 2.1, 1.4, 2.8, 1.7, 0.4]).statistic; // 0.625
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @category Hypothesis tests
|
|
30
50
|
*/
|
|
31
51
|
export declare function ksTest(x: Sample, y: Sample | ((q: number) => number), options?: KsTestOptions): KsTestResult;
|
|
52
|
+
/**
|
|
53
|
+
* Two-sample Kolmogorov-Smirnov test from a formula and a data frame. As R's `ks.test(formula, data)`:
|
|
54
|
+
* `"y ~ g"` compares the two levels of `g` (the first level is `x`). Only the variables of the formula count: the
|
|
55
|
+
* rows where one of them is missing are dropped.
|
|
56
|
+
*
|
|
57
|
+
* @param formula `"y ~ g"`.
|
|
58
|
+
* @param data The data frame: an object of columns (`null` or `NaN` for a missing value).
|
|
59
|
+
* @param options See {@link KsTestOptions}.
|
|
60
|
+
*/
|
|
61
|
+
export declare function ksTest(formula: string, data: DataFrame, options?: KsTestOptions): KsTestResult;
|
package/dist/htest/ksTest.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// by counting lattice paths, asymptotic ones as for one sample with n replaced by m n / (m + n).
|
|
9
9
|
import { pkolmogorovExact, pkolmogorovLimit, pkolmogorovOneSidedUpper } from "./core/kolmogorov.js";
|
|
10
10
|
import { psmirnovUpper } from "./core/smirnov.js";
|
|
11
|
+
import { twoGroupData } from "./testFormula.js";
|
|
11
12
|
import { matchAlternative } from "./types.js";
|
|
12
13
|
function describe(alternative, oneSample) {
|
|
13
14
|
if (alternative === "two.sided")
|
|
@@ -15,15 +16,11 @@ function describe(alternative, oneSample) {
|
|
|
15
16
|
const where = alternative === "less" ? "below" : "above";
|
|
16
17
|
return `the CDF of x lies ${where} ${oneSample ? "the null hypothesis" : "that of y"}`;
|
|
17
18
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Kolmogorov-Smirnov test. Equivalent to R's `ks.test()`, with a distribution function given as a function (for
|
|
20
|
-
* example `(q) => pnorm(q)`) or a second sample. `NaN` values are dropped.
|
|
21
|
-
*
|
|
22
|
-
* @param x Sample.
|
|
23
|
-
* @param y A continuous distribution function, or a second sample.
|
|
24
|
-
* @param options See {@link KsTestOptions}.
|
|
25
|
-
*/
|
|
26
19
|
export function ksTest(x, y, options = {}) {
|
|
20
|
+
if (typeof x === "string") {
|
|
21
|
+
const d = twoGroupData(x, y);
|
|
22
|
+
return ksTest(d.x, d.y, options);
|
|
23
|
+
}
|
|
27
24
|
const xs = Array.from(x)
|
|
28
25
|
.filter((v) => !Number.isNaN(v))
|
|
29
26
|
.sort((a, b) => a - b);
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { type GroupLabel } from "./groups.js";
|
|
2
2
|
import type { Sample } from "./types.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link leveneTest}.
|
|
5
|
+
*
|
|
6
|
+
* @category Hypothesis tests
|
|
7
|
+
*/
|
|
4
8
|
export interface LeveneTestOptions {
|
|
5
9
|
/** The centre of each group: `"median"` (default) or `"mean"`. */
|
|
6
10
|
center?: "median" | "mean" | (string & {});
|
|
7
11
|
}
|
|
8
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Result of {@link leveneTest}: car's table.
|
|
14
|
+
*
|
|
15
|
+
* @category Hypothesis tests
|
|
16
|
+
*/
|
|
9
17
|
export interface LeveneTestResult {
|
|
10
18
|
/** `["Df", "F value", "Pr(>F)"]`. */
|
|
11
19
|
colNames: string[];
|
|
@@ -15,8 +23,9 @@ export interface LeveneTestResult {
|
|
|
15
23
|
table: number[][];
|
|
16
24
|
}
|
|
17
25
|
/**
|
|
18
|
-
* Levene's test for homogeneity of variance across groups. Equivalent to car
|
|
19
|
-
* median)` (or `mean`). Pairs with a missing value are dropped; groups are ordered by
|
|
26
|
+
* Levene's test for homogeneity of variance across groups. Equivalent to `car::leveneTest()` in R. Computes
|
|
27
|
+
* `leveneTest(y ~ g, center = median)` (or `mean`). Pairs with a missing value are dropped; groups are ordered by
|
|
28
|
+
* their sorted labels.
|
|
20
29
|
*
|
|
21
30
|
* @param y The values.
|
|
22
31
|
* @param g Group labels, parallel to `y`.
|
|
@@ -26,5 +35,7 @@ export interface LeveneTestResult {
|
|
|
26
35
|
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
27
36
|
* leveneTest([4.2, 5.1, 6.3, 5.8, 7.9, 8.4, 6.6, 7.0, 5.5], g).table[0]; // [2, 0.15936952714535912, 0.8561748951935417]
|
|
28
37
|
* ```
|
|
38
|
+
*
|
|
39
|
+
* @category Hypothesis tests
|
|
29
40
|
*/
|
|
30
41
|
export declare function leveneTest(y: Sample, g: readonly GroupLabel[], options?: LeveneTestOptions): LeveneTestResult;
|
package/dist/htest/leveneTest.js
CHANGED
|
@@ -8,8 +8,9 @@ import { aov } from "./aov.js";
|
|
|
8
8
|
import { labelledGroups, median } from "./groups.js";
|
|
9
9
|
import { matchChoice } from "./power.js";
|
|
10
10
|
/**
|
|
11
|
-
* Levene's test for homogeneity of variance across groups. Equivalent to car
|
|
12
|
-
* median)` (or `mean`). Pairs with a missing value are dropped; groups are ordered by
|
|
11
|
+
* Levene's test for homogeneity of variance across groups. Equivalent to `car::leveneTest()` in R. Computes
|
|
12
|
+
* `leveneTest(y ~ g, center = median)` (or `mean`). Pairs with a missing value are dropped; groups are ordered by
|
|
13
|
+
* their sorted labels.
|
|
13
14
|
*
|
|
14
15
|
* @param y The values.
|
|
15
16
|
* @param g Group labels, parallel to `y`.
|
|
@@ -19,6 +20,8 @@ import { matchChoice } from "./power.js";
|
|
|
19
20
|
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
20
21
|
* leveneTest([4.2, 5.1, 6.3, 5.8, 7.9, 8.4, 6.6, 7.0, 5.5], g).table[0]; // [2, 0.15936952714535912, 0.8561748951935417]
|
|
21
22
|
* ```
|
|
23
|
+
*
|
|
24
|
+
* @category Hypothesis tests
|
|
22
25
|
*/
|
|
23
26
|
export function leveneTest(y, g, options = {}) {
|
|
24
27
|
const center = matchChoice(options.center ?? "median", ["median", "mean"]);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Alternative, type HTest } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link mantelhaenTest}.
|
|
4
|
+
*
|
|
5
|
+
* @category Hypothesis tests
|
|
6
|
+
*/
|
|
3
7
|
export interface MantelhaenTestOptions {
|
|
4
8
|
/** Alternative hypothesis (2 x 2 x K only). Default `"two.sided"`. */
|
|
5
9
|
alternative?: Alternative | "two" | "l" | "g";
|
|
@@ -10,17 +14,35 @@ export interface MantelhaenTestOptions {
|
|
|
10
14
|
/** Confidence level of the interval for the common odds ratio. Default `0.95`. */
|
|
11
15
|
confLevel?: number;
|
|
12
16
|
}
|
|
13
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Result of {@link mantelhaenTest}. 2 x 2 x K tables add the common odds ratio and its interval.
|
|
19
|
+
*
|
|
20
|
+
* @category Hypothesis tests
|
|
21
|
+
*/
|
|
14
22
|
export interface MantelhaenTestResult extends Omit<HTest, "alternative"> {
|
|
15
23
|
/** Present for 2 x 2 x K tables. */
|
|
16
24
|
alternative?: Alternative;
|
|
17
25
|
}
|
|
18
26
|
/**
|
|
19
27
|
* Cochran-Mantel-Haenszel chi-squared test of conditional independence in a set of contingency tables, one per
|
|
20
|
-
* stratum. Equivalent to R's `mantelhaen.test()
|
|
28
|
+
* stratum. Equivalent to R's `mantelhaen.test()`. Takes the strata as R takes a three-dimensional array.
|
|
21
29
|
*
|
|
22
30
|
* @param strata The K strata, each an I x J table of counts as an array of rows (all of the same shape; I, J >= 2,
|
|
23
31
|
* K >= 2 for the asymptotic test).
|
|
24
32
|
* @param options See {@link MantelhaenTestOptions}.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const r = mantelhaenTest([
|
|
37
|
+
* [[10, 5], [4, 12]],
|
|
38
|
+
* [[8, 6], [5, 9]],
|
|
39
|
+
* [[12, 4], [6, 10]],
|
|
40
|
+
* ]);
|
|
41
|
+
* r.statistic; // 8.972595458903124
|
|
42
|
+
* r.pValue; // 0.002740590103473906
|
|
43
|
+
* r.estimate; // 4.13218122372723 (common odds ratio)
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @category Hypothesis tests
|
|
25
47
|
*/
|
|
26
48
|
export declare function mantelhaenTest(strata: readonly (readonly (readonly number[])[])[], options?: MantelhaenTestOptions): MantelhaenTestResult;
|
|
@@ -21,11 +21,25 @@ import { ConvolvedNoncentralHyper, conditionalMLE, lowerLimit, upperLimit } from
|
|
|
21
21
|
import { checkConfLevelOpen, matchAlternative } from "./types.js";
|
|
22
22
|
/**
|
|
23
23
|
* Cochran-Mantel-Haenszel chi-squared test of conditional independence in a set of contingency tables, one per
|
|
24
|
-
* stratum. Equivalent to R's `mantelhaen.test()
|
|
24
|
+
* stratum. Equivalent to R's `mantelhaen.test()`. Takes the strata as R takes a three-dimensional array.
|
|
25
25
|
*
|
|
26
26
|
* @param strata The K strata, each an I x J table of counts as an array of rows (all of the same shape; I, J >= 2,
|
|
27
27
|
* K >= 2 for the asymptotic test).
|
|
28
28
|
* @param options See {@link MantelhaenTestOptions}.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const r = mantelhaenTest([
|
|
33
|
+
* [[10, 5], [4, 12]],
|
|
34
|
+
* [[8, 6], [5, 9]],
|
|
35
|
+
* [[12, 4], [6, 10]],
|
|
36
|
+
* ]);
|
|
37
|
+
* r.statistic; // 8.972595458903124
|
|
38
|
+
* r.pValue; // 0.002740590103473906
|
|
39
|
+
* r.estimate; // 4.13218122372723 (common odds ratio)
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @category Hypothesis tests
|
|
29
43
|
*/
|
|
30
44
|
export function mantelhaenTest(strata, options = {}) {
|
|
31
45
|
const K = strata.length;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import type { HTest } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link mcnemarTest}.
|
|
4
|
+
*
|
|
5
|
+
* @category Hypothesis tests
|
|
6
|
+
*/
|
|
3
7
|
export interface McnemarTestOptions {
|
|
4
8
|
/** Apply the continuity correction (2 x 2 tables only). Default `true`. */
|
|
5
9
|
correct?: boolean;
|
|
6
10
|
}
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Result of {@link mcnemarTest}. Has no `alternative`, as R's `mcnemar.test()` returns none.
|
|
13
|
+
*
|
|
14
|
+
* @category Hypothesis tests
|
|
15
|
+
*/
|
|
8
16
|
export interface McnemarTestResult extends Omit<HTest, "alternative"> {
|
|
9
17
|
/** Degrees of freedom (`parameterName` is `"df"`). */
|
|
10
18
|
parameter: number;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
21
|
* McNemar's chi-squared test for symmetry of rows and columns in a square table of counts. Equivalent to R's
|
|
14
|
-
* `mcnemar.test()
|
|
22
|
+
* `mcnemar.test()`. Takes a matrix, or two factors given as paired category codes.
|
|
15
23
|
*
|
|
16
24
|
* @param x Square table of counts as an array of rows, or the first of two paired samples of category codes.
|
|
17
25
|
* @param y Second paired sample of category codes, when `x` is a sample. May be omitted (and the options passed in
|
|
@@ -20,7 +28,9 @@ export interface McnemarTestResult extends Omit<HTest, "alternative"> {
|
|
|
20
28
|
*
|
|
21
29
|
* @example
|
|
22
30
|
* ```ts
|
|
23
|
-
* mcnemarTest([[794, 86], [150, 570]]).statistic; //
|
|
31
|
+
* mcnemarTest([[794, 86], [150, 570]]).statistic; // 16.81779661016949
|
|
24
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* @category Hypothesis tests
|
|
25
35
|
*/
|
|
26
36
|
export declare function mcnemarTest(x: readonly (readonly number[])[] | readonly (number | string)[], y?: readonly (number | string)[] | McnemarTestOptions, options?: McnemarTestOptions): McnemarTestResult;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { pgamma1 } from "../distributions/gamma.js";
|
|
7
7
|
/**
|
|
8
8
|
* McNemar's chi-squared test for symmetry of rows and columns in a square table of counts. Equivalent to R's
|
|
9
|
-
* `mcnemar.test()
|
|
9
|
+
* `mcnemar.test()`. Takes a matrix, or two factors given as paired category codes.
|
|
10
10
|
*
|
|
11
11
|
* @param x Square table of counts as an array of rows, or the first of two paired samples of category codes.
|
|
12
12
|
* @param y Second paired sample of category codes, when `x` is a sample. May be omitted (and the options passed in
|
|
@@ -15,8 +15,10 @@ import { pgamma1 } from "../distributions/gamma.js";
|
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
18
|
-
* mcnemarTest([[794, 86], [150, 570]]).statistic; //
|
|
18
|
+
* mcnemarTest([[794, 86], [150, 570]]).statistic; // 16.81779661016949
|
|
19
19
|
* ```
|
|
20
|
+
*
|
|
21
|
+
* @category Hypothesis tests
|
|
20
22
|
*/
|
|
21
23
|
export function mcnemarTest(x, y, options = {}) {
|
|
22
24
|
let table;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type GroupLabel } from "./groups.js";
|
|
2
2
|
import { type PAdjustMethod } from "./pAdjust.js";
|
|
3
3
|
import { type Alternative, type Sample } from "./types.js";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Result of the PMCMRplus tests (R's `PMCMR` objects).
|
|
6
|
+
*
|
|
7
|
+
* @category Multiple comparisons
|
|
8
|
+
*/
|
|
5
9
|
export interface PMCMRResult {
|
|
6
10
|
/** Description of the test (R's `method`). */
|
|
7
11
|
method: string;
|
|
@@ -22,84 +26,194 @@ export interface PMCMRResult {
|
|
|
22
26
|
/** R's warnings. */
|
|
23
27
|
warnings: string[];
|
|
24
28
|
}
|
|
25
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Options of the all-pairs Dunn test.
|
|
31
|
+
*
|
|
32
|
+
* @category Multiple comparisons
|
|
33
|
+
*/
|
|
26
34
|
export interface KwAllPairsDunnTestOptions {
|
|
27
35
|
/** p-value adjustment (see `pAdjust`). Default `"holm"`. */
|
|
28
36
|
pAdjustMethod?: PAdjustMethod | (string & {});
|
|
29
37
|
}
|
|
30
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Options of the many-to-one tests.
|
|
40
|
+
*
|
|
41
|
+
* @category Multiple comparisons
|
|
42
|
+
*/
|
|
31
43
|
export interface ManyOneTestOptions {
|
|
32
44
|
/** Alternative hypothesis for each group against the control. Default `"two.sided"`. */
|
|
33
45
|
alternative?: Alternative | "two" | "l" | "g";
|
|
34
46
|
}
|
|
35
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Options of the many-to-one Dunn test.
|
|
49
|
+
*
|
|
50
|
+
* @category Multiple comparisons
|
|
51
|
+
*/
|
|
36
52
|
export interface KwManyOneDunnTestOptions extends ManyOneTestOptions {
|
|
37
53
|
/** `"single-step"` (simultaneous normal probabilities, the default) or a `pAdjust` method. */
|
|
38
54
|
pAdjustMethod?: "single-step" | PAdjustMethod | (string & {});
|
|
39
55
|
}
|
|
40
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Options of Steel's many-to-one rank test (`manyOneUTest`).
|
|
58
|
+
*
|
|
59
|
+
* @category Multiple comparisons
|
|
60
|
+
*/
|
|
41
61
|
export type ManyOneUTestOptions = KwManyOneDunnTestOptions;
|
|
42
62
|
/**
|
|
43
|
-
* Dunn's all-pairs test of mean ranks with adjusted p-values. Equivalent to PMCMRplus
|
|
63
|
+
* Dunn's all-pairs test of mean ranks with adjusted p-values. Equivalent to `PMCMRplus::kwAllPairsDunnTest()` in R.
|
|
44
64
|
*
|
|
45
65
|
* @param x Response values.
|
|
46
66
|
* @param g Group labels, parallel to `x` (groups in the order of the sorted labels).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
71
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
72
|
+
* kwAllPairsDunnTest(x, g).pValue; // [[0.3594249897579995, NaN], [0.02187107427460692, 0.3594249897579995]]
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @category Multiple comparisons
|
|
47
76
|
*/
|
|
48
77
|
export declare function kwAllPairsDunnTest(x: Sample, g: readonly GroupLabel[], options?: KwAllPairsDunnTestOptions): PMCMRResult;
|
|
49
78
|
/**
|
|
50
|
-
* Dunn's many-to-one test of mean ranks against the control (the first group). Equivalent to
|
|
51
|
-
* `kwManyOneDunnTest()
|
|
52
|
-
* normal probabilities (R approximates them by randomised integration).
|
|
79
|
+
* Dunn's many-to-one test of mean ranks against the control (the first group). Equivalent to
|
|
80
|
+
* `PMCMRplus::kwManyOneDunnTest()` in R. With `pAdjustMethod` `"single-step"` (the default) the p-values are the
|
|
81
|
+
* exact simultaneous normal probabilities (R approximates them by randomised integration).
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
86
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
87
|
+
* kwManyOneDunnTest(x, g).pValue; // [[0.30272579742071715], [0.013938744281312318]]
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @category Multiple comparisons
|
|
53
91
|
*/
|
|
54
92
|
export declare function kwManyOneDunnTest(x: Sample, g: readonly GroupLabel[], options?: KwManyOneDunnTestOptions): PMCMRResult;
|
|
55
93
|
/**
|
|
56
94
|
* Dunnett's many-to-one test of means against the control (the first group), with the pooled variance. Equivalent to
|
|
57
|
-
* PMCMRplus
|
|
95
|
+
* `PMCMRplus::dunnettTest()` in R. The p-values are the exact multivariate t probabilities (R approximates them by
|
|
58
96
|
* randomised integration); two-sided, as in PMCMRplus, `min(1, 2 P(max T_i >= |t|))`.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
101
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
102
|
+
* dunnettTest(x, g).pValue; // [[0.026103399464872296], [0.0011111316275120736]]
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @category Multiple comparisons
|
|
59
106
|
*/
|
|
60
107
|
export declare function dunnettTest(x: Sample, g: readonly GroupLabel[], options?: ManyOneTestOptions): PMCMRResult;
|
|
61
108
|
/**
|
|
62
109
|
* Steel's many-to-one rank test in its normal approximation: the Mann-Whitney statistic of each group against the
|
|
63
110
|
* control (the first group), each pair ranked on its own (midranks), standardised with the tie-corrected variance.
|
|
64
|
-
* Equivalent to PMCMRplus
|
|
111
|
+
* Equivalent to `PMCMRplus::manyOneUTest()` in R. The statistic is positive when the group ranks higher than the
|
|
65
112
|
* control. With `pAdjustMethod` `"single-step"` (the default; at least three groups) the p-values are the exact
|
|
66
113
|
* simultaneous normal probabilities (R approximates them by randomised integration).
|
|
67
114
|
*
|
|
68
115
|
* @param x Response values.
|
|
69
116
|
* @param g Group labels, parallel to `x` (groups in the order of the sorted labels).
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
121
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
122
|
+
* manyOneUTest(x, g).pValue; // [[0.08993551204759488], [0.08993551204759488]]
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @category Multiple comparisons
|
|
70
126
|
*/
|
|
71
127
|
export declare function manyOneUTest(x: Sample, g: readonly GroupLabel[], options?: ManyOneUTestOptions): PMCMRResult;
|
|
72
128
|
/**
|
|
73
|
-
* Dwass-Steel-Critchlow-Fligner all-pairs test of pairwise Mann-Whitney statistics. Equivalent to
|
|
74
|
-
* `dscfAllPairsTest()
|
|
129
|
+
* Dwass-Steel-Critchlow-Fligner all-pairs test of pairwise Mann-Whitney statistics. Equivalent to
|
|
130
|
+
* `PMCMRplus::dscfAllPairsTest()` in R. The statistic, sqrt(2) (U - n_i n_j / 2) / sqrt(Var U) with the smaller U,
|
|
131
|
+
* is never positive.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
136
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
137
|
+
* dscfAllPairsTest(x, g).pValue; // [[0.12122941216677251, NaN], [0.12122941216677251, 0.12122941216677251]]
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @category Multiple comparisons
|
|
75
141
|
*/
|
|
76
142
|
export declare function dscfAllPairsTest(x: Sample, g: readonly GroupLabel[]): PMCMRResult;
|
|
77
143
|
/**
|
|
78
144
|
* Games-Howell all-pairs test of means with Welch's standard errors and degrees of freedom. Equivalent to
|
|
79
|
-
* PMCMRplus
|
|
145
|
+
* `PMCMRplus::gamesHowellTest()` in R.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
150
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
151
|
+
* gamesHowellTest(x, g).pValue; // [[0.05271565998164183, NaN], [0.009781818487986175, 0.08494498877912128]]
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @category Multiple comparisons
|
|
80
155
|
*/
|
|
81
156
|
export declare function gamesHowellTest(x: Sample, g: readonly GroupLabel[]): PMCMRResult;
|
|
82
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* Tukey's all-pairs test of means (Tukey-Kramer for unequal sizes). Equivalent to `PMCMRplus::tukeyTest()` in R.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
163
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
164
|
+
* tukeyTest(x, g).pValue; // [[0.03403130149294014, NaN], [0.001492661804896774, 0.04527523376597547]]
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @category Multiple comparisons
|
|
168
|
+
*/
|
|
83
169
|
export declare function tukeyTest(x: Sample, g: readonly GroupLabel[]): PMCMRResult;
|
|
84
170
|
/**
|
|
85
|
-
* Steel's many-to-one rank test
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* internally.
|
|
171
|
+
* Steel's many-to-one rank test. Equivalent to `PMCMRplus::steelTest()` in R. It behaves as `steelTest()` of
|
|
172
|
+
* PMCMRplus 1.9.12 does: that fails on every input, so this reproduces its errors. A two-sided
|
|
173
|
+
* alternative is rejected (`'arg' should be one of “greater”, “less”`), unequal group sizes give `Steel's test is
|
|
174
|
+
* only valid for balanced designs.`, and balanced data the error PMCMRplus raises internally.
|
|
89
175
|
*
|
|
90
176
|
* @throws Always.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
181
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
182
|
+
* const message = (() => {
|
|
183
|
+
* try {
|
|
184
|
+
* steelTest(x, g, { alternative: "greater" });
|
|
185
|
+
* } catch (e) {
|
|
186
|
+
* return (e as Error).message;
|
|
187
|
+
* }
|
|
188
|
+
* })();
|
|
189
|
+
* message; // "'data' must be of a vector type, was 'NULL'"
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @category Multiple comparisons
|
|
91
193
|
*/
|
|
92
194
|
export declare function steelTest(x: Sample, g: readonly GroupLabel[], options?: ManyOneTestOptions): never;
|
|
93
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* Adjustment method of {@link dunnTest} (dunn.test's `method`).
|
|
197
|
+
*
|
|
198
|
+
* @category Multiple comparisons
|
|
199
|
+
*/
|
|
94
200
|
export type DunnTestMethod = "none" | "bonferroni" | "sidak" | "holm" | "hs" | "hochberg" | "bh" | "by";
|
|
95
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* Options of {@link dunnTest}.
|
|
203
|
+
*
|
|
204
|
+
* @category Multiple comparisons
|
|
205
|
+
*/
|
|
96
206
|
export interface DunnTestOptions {
|
|
97
207
|
/** Adjustment of the p-values. Default `"none"`. */
|
|
98
208
|
method?: DunnTestMethod;
|
|
99
209
|
/** Report two-sided p-values (twice the upper tail of |Z|) instead of one-sided ones. Default `false`. */
|
|
100
210
|
altp?: boolean;
|
|
101
211
|
}
|
|
102
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* Result of {@link dunnTest} (dunn.test's list).
|
|
214
|
+
*
|
|
215
|
+
* @category Multiple comparisons
|
|
216
|
+
*/
|
|
103
217
|
export interface DunnTestResult {
|
|
104
218
|
/** Kruskal-Wallis chi-squared statistic (with the tie correction). */
|
|
105
219
|
chi2: number;
|
|
@@ -113,17 +227,36 @@ export interface DunnTestResult {
|
|
|
113
227
|
comparisons: string[];
|
|
114
228
|
}
|
|
115
229
|
/**
|
|
116
|
-
* Dunn's test of all pairs of mean ranks. Equivalent to dunn.test
|
|
230
|
+
* Dunn's test of all pairs of mean ranks. Equivalent to `dunn.test::dunn.test(x, g, method, altp)` in R. The step-wise
|
|
117
231
|
* adjustments multiply (or transform) each p-value by the factor of its rank and cap it at 1, without enforcing
|
|
118
232
|
* monotonicity, as dunn.test does (unlike `pAdjust`).
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
237
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
238
|
+
* const r = dunnTest(x, g, { method: "bonferroni" });
|
|
239
|
+
* r.comparisons; // ["a - b", "a - c", "b - c"]
|
|
240
|
+
* r.PAdjusted; // [0.26956874231849964, 0.01093553713730346, 0.26956874231849964]
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @category Multiple comparisons
|
|
119
244
|
*/
|
|
120
245
|
export declare function dunnTest(x: Sample, g: readonly GroupLabel[], options?: DunnTestOptions): DunnTestResult;
|
|
121
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* Options of {@link glhtDunnett}.
|
|
248
|
+
*
|
|
249
|
+
* @category Multiple comparisons
|
|
250
|
+
*/
|
|
122
251
|
export interface GlhtDunnettOptions {
|
|
123
252
|
/** Alternative hypothesis for each group against the control. Default `"two.sided"`. */
|
|
124
253
|
alternative?: Alternative | "two" | "l" | "g";
|
|
125
254
|
}
|
|
126
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* Result of {@link glhtDunnett}.
|
|
257
|
+
*
|
|
258
|
+
* @category Multiple comparisons
|
|
259
|
+
*/
|
|
127
260
|
export interface GlhtDunnettResult {
|
|
128
261
|
/** Labels of the contrasts, `"<level> - <level 1>"`. */
|
|
129
262
|
names: string[];
|
|
@@ -139,9 +272,20 @@ export interface GlhtDunnettResult {
|
|
|
139
272
|
df: number;
|
|
140
273
|
}
|
|
141
274
|
/**
|
|
142
|
-
* Dunnett's many-to-one comparisons of a one-way ANOVA with simultaneous p-values. Equivalent to
|
|
143
|
-
* `summary(glht(aov(y ~ g), linfct = mcp(g = "Dunnett"), alternative))`, with the
|
|
144
|
-
* (R approximates them by randomised integration): two-sided
|
|
145
|
-
* `P(min T_i <= t)`.
|
|
275
|
+
* Dunnett's many-to-one comparisons of a one-way ANOVA with simultaneous p-values. Equivalent to
|
|
276
|
+
* `multcomp::glht()` in R. It gives `summary(glht(aov(y ~ g), linfct = mcp(g = "Dunnett"), alternative))`, with the
|
|
277
|
+
* exact multivariate t probabilities (R approximates them by randomised integration): two-sided
|
|
278
|
+
* `P(max |T_i| >= |t|)`, greater `P(max T_i >= t)`, less `P(min T_i <= t)`.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
283
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
284
|
+
* const r = glhtDunnett(x, g);
|
|
285
|
+
* r.names; // ["b - a", "c - a"]
|
|
286
|
+
* r.p; // [0.02601829573165104, 0.0011091043143827048]
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @category Multiple comparisons
|
|
146
290
|
*/
|
|
147
291
|
export declare function glhtDunnett(x: Sample, g: readonly GroupLabel[], options?: GlhtDunnettOptions): GlhtDunnettResult;
|