@numero-uno-jpn/rstats 0.11.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 +13 -0
- package/README.ja.md +5 -4
- package/README.md +6 -4
- package/dist/chunks/{chunk-YSWGDOWK.js → chunk-2X7JYQBI.js} +2 -2
- package/dist/chunks/{chunk-F5EDJFEO.js → chunk-36GVER3O.js} +2 -2
- package/dist/chunks/{chunk-7GQMKH3Z.js → chunk-3WUXRSM6.js} +1 -1
- package/dist/chunks/{chunk-JWBO5WVN.js → chunk-6I6QKTFK.js} +2 -2
- package/dist/chunks/{chunk-EZWBRCJL.js → chunk-ETOEZTGL.js} +1 -1
- package/dist/chunks/{chunk-VJ4BDBMU.js → chunk-FVPDVRJQ.js} +2 -2
- package/dist/chunks/{chunk-EZAFN5CD.js → chunk-GG4BJMJW.js} +1 -1
- package/dist/chunks/{chunk-5WDJPHYY.js → chunk-HITD7CX6.js} +1 -1
- package/dist/chunks/{chunk-Y5PYRAYP.js → chunk-KK4GE65D.js} +2 -2
- package/dist/chunks/{chunk-AHHS6AC4.js → chunk-LAUYSGV4.js} +2 -2
- package/dist/chunks/{chunk-ALM3VHFP.js → chunk-M6GDXKKS.js} +1 -1
- package/dist/chunks/{chunk-C5XTWMGB.js → chunk-PHHUHR7T.js} +1 -1
- package/dist/chunks/{chunk-TOGXTCZO.js → chunk-WQPFDDIY.js} +2 -2
- package/dist/chunks/{chunk-CGBNKHNZ.js → chunk-X2AWQSVS.js} +2 -2
- package/dist/chunks/{chunk-Y5CNQ266.js → chunk-ZRJQD7VS.js} +2 -2
- package/dist/data/grouping.d.ts +33 -12
- package/dist/data/grouping.js +2 -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 +39 -11
- package/dist/descriptive/dataFrames.js +14 -6
- 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 +13 -6
- package/dist/descriptive/missing.js +4 -2
- 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 +22 -6
- package/dist/descriptive/pivot.js +7 -3
- 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 +1 -1
- 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 +8 -2
- 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 +20 -4
- 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 +20 -3
- 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 +32 -3
- package/dist/htest/onewayTest.js +10 -0
- 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 +80 -12
- package/dist/htest/rankTests.js +11 -2
- package/dist/htest/tTest.d.ts +13 -3
- 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 +25 -8
- package/dist/htest/wilcoxTest.d.ts +10 -2
- 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 +156 -35
- package/dist/linalg/ops.js +96 -15
- 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 +1 -1
- 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 +2 -2
- package/llms.txt +2 -0
- package/package.json +1 -1
package/dist/htest/agreement.js
CHANGED
|
@@ -28,8 +28,8 @@ function requireComplete(x, what) {
|
|
|
28
28
|
/** Two-sided normal p-value 2 Φ(−|z|) */
|
|
29
29
|
const twoSidedP = (z) => 2 * pnorm(-Math.abs(z));
|
|
30
30
|
/**
|
|
31
|
-
* Cohen's kappa for two raters, unweighted or weighted, with the z test of kappa = 0. Equivalent to
|
|
32
|
-
* `kappa2(ratings, weight)`
|
|
31
|
+
* Cohen's kappa for two raters, unweighted or weighted, with the z test of kappa = 0. Equivalent to
|
|
32
|
+
* `irr::kappa2(ratings, weight)` in R. The ratings are numeric.
|
|
33
33
|
*
|
|
34
34
|
* The levels are the distinct ratings of both raters sorted as R sorts their character forms (so 10 sorts before 2,
|
|
35
35
|
* which matters for the weighted kappas). Rows with a missing value (`NaN`) are dropped. The variance of the test is
|
|
@@ -43,6 +43,8 @@ const twoSidedP = (z) => 2 * pnorm(-Math.abs(z));
|
|
|
43
43
|
* ```ts
|
|
44
44
|
* kappa2([[1, 1], [2, 2], [3, 2], [1, 1], [2, 3], [3, 3]]); // { value: 0.49999999999999994, statistic: 1.7320508075688772, pValue: 0.08326451666355043 }
|
|
45
45
|
* ```
|
|
46
|
+
*
|
|
47
|
+
* @category Agreement, reliability and factor analysis
|
|
46
48
|
*/
|
|
47
49
|
export function kappa2(ratings, options = {}) {
|
|
48
50
|
const weight = matchChoice(options.weight, ["unweighted", "equal", "squared"]);
|
|
@@ -81,7 +83,7 @@ export function kappa2(ratings, options = {}) {
|
|
|
81
83
|
}
|
|
82
84
|
/**
|
|
83
85
|
* Fleiss' kappa for several raters (or Conger's exact kappa), with the z test of kappa = 0 for Fleiss' kappa.
|
|
84
|
-
* Equivalent to irr
|
|
86
|
+
* Equivalent to `irr::kappam.fleiss(ratings, exact)` in R. The ratings are numeric, without missing values.
|
|
85
87
|
*
|
|
86
88
|
* The p-value is computed as 2 Φ(−|z|), so small p-values are more accurate than irr's.
|
|
87
89
|
*
|
|
@@ -92,6 +94,8 @@ export function kappa2(ratings, options = {}) {
|
|
|
92
94
|
* ```ts
|
|
93
95
|
* kappamFleiss([[1, 1, 2], [2, 2, 2], [3, 3, 2], [1, 1, 1], [2, 3, 3]]).value; // 0.3918918918918918
|
|
94
96
|
* ```
|
|
97
|
+
*
|
|
98
|
+
* @category Agreement, reliability and factor analysis
|
|
95
99
|
*/
|
|
96
100
|
export function kappamFleiss(ratings, options = {}) {
|
|
97
101
|
const exact = options.exact ?? false;
|
|
@@ -132,8 +136,8 @@ export function kappamFleiss(ratings, options = {}) {
|
|
|
132
136
|
return { value, statistic, pValue: twoSidedP(statistic) };
|
|
133
137
|
}
|
|
134
138
|
/**
|
|
135
|
-
* Intraclass correlation coefficient with its F test and confidence interval (McGraw and Wong's forms).
|
|
136
|
-
* to irr
|
|
139
|
+
* Intraclass correlation coefficient with its F test and confidence interval (McGraw and Wong's forms).
|
|
140
|
+
* Equivalent to `irr::icc(ratings, model, type, unit, r0, conf.level)` in R. No missing values are allowed.
|
|
137
141
|
*
|
|
138
142
|
* @param ratings - An n × k matrix (array of rows): the ratings of the k raters for each of the n subjects.
|
|
139
143
|
* @param options - See {@link IccOptions}.
|
|
@@ -143,6 +147,8 @@ export function kappamFleiss(ratings, options = {}) {
|
|
|
143
147
|
* icc([[9, 2, 5, 8], [6, 1, 3, 2], [8, 4, 6, 8], [7, 1, 2, 6], [10, 5, 6, 9], [6, 2, 4, 7]],
|
|
144
148
|
* { model: "twoway", type: "agreement" }).value; // 0.28976377952755905
|
|
145
149
|
* ```
|
|
150
|
+
*
|
|
151
|
+
* @category Agreement, reliability and factor analysis
|
|
146
152
|
*/
|
|
147
153
|
export function icc(ratings, options = {}) {
|
|
148
154
|
const model = matchChoice(options.model, ["oneway", "twoway"]);
|
|
@@ -206,8 +212,8 @@ function rawAlphaOf(C, keep) {
|
|
|
206
212
|
}
|
|
207
213
|
/**
|
|
208
214
|
* Cronbach's alpha of a set of items, standardized alpha, Guttman's lambda 6 and the mean inter-item correlation,
|
|
209
|
-
* and alpha with each item dropped. Equivalent to
|
|
210
|
-
* with its defaults (no missing values, no reversed items).
|
|
215
|
+
* and alpha with each item dropped. Equivalent to `psych::alpha()` in R. It gives the `total` row and
|
|
216
|
+
* `alpha.drop$raw_alpha` of `alpha(x)` with its defaults (no missing values, no reversed items).
|
|
211
217
|
*
|
|
212
218
|
* @param x - An n × k matrix (array of rows): k items observed on n subjects.
|
|
213
219
|
*
|
|
@@ -215,6 +221,8 @@ function rawAlphaOf(C, keep) {
|
|
|
215
221
|
* ```ts
|
|
216
222
|
* cronbachAlpha([[1, 2, 2], [2, 3, 3], [3, 3, 4], [4, 5, 4], [2, 2, 3]]).rawAlpha; // 0.935483870967742
|
|
217
223
|
* ```
|
|
224
|
+
*
|
|
225
|
+
* @category Agreement, reliability and factor analysis
|
|
218
226
|
*/
|
|
219
227
|
export function cronbachAlpha(x) {
|
|
220
228
|
const k = columnsOf(x, "x").length;
|
|
@@ -236,8 +244,8 @@ export function cronbachAlpha(x) {
|
|
|
236
244
|
};
|
|
237
245
|
}
|
|
238
246
|
/**
|
|
239
|
-
* Partial correlation of columns `i` and `j` of `x` given all its other columns. Equivalent to
|
|
240
|
-
* `partial.r(x, c(i, j), others)`
|
|
247
|
+
* Partial correlation of columns `i` and `j` of `x` given all its other columns. Equivalent to
|
|
248
|
+
* `psych::partial.r(x, c(i, j), others)` in R. Returns its off-diagonal element (no missing values).
|
|
241
249
|
*
|
|
242
250
|
* @param x - An n × p matrix (array of rows), the variables in the columns.
|
|
243
251
|
* @param i - 0-based column index.
|
|
@@ -247,6 +255,8 @@ export function cronbachAlpha(x) {
|
|
|
247
255
|
* ```ts
|
|
248
256
|
* partialR([[1, 2, 3], [2, 1, 5], [3, 5, 4], [4, 3, 8], [5, 6, 7]], 0, 1); // 0.9804877404385672
|
|
249
257
|
* ```
|
|
258
|
+
*
|
|
259
|
+
* @category Agreement, reliability and factor analysis
|
|
250
260
|
*/
|
|
251
261
|
export function partialR(x, i, j) {
|
|
252
262
|
const p = columnsOf(x, "x").length;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { DataFrame } from "../models/modelFrame.js";
|
|
2
2
|
import { type Alternative, type HTest, type Sample } from "./types.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link ansariTest}.
|
|
5
|
+
*
|
|
6
|
+
* @category Hypothesis tests
|
|
7
|
+
*/
|
|
4
8
|
export interface AnsariTestOptions {
|
|
5
9
|
/** Alternative hypothesis (unambiguous abbreviations accepted). Default `"two.sided"`. */
|
|
6
10
|
alternative?: Alternative | "two" | "l" | "g";
|
|
@@ -29,10 +33,12 @@ export interface AnsariTestOptions {
|
|
|
29
33
|
* ```
|
|
30
34
|
*
|
|
31
35
|
* There is also a formula form, `ansariTest("y ~ g", data, options)` (next overload).
|
|
36
|
+
*
|
|
37
|
+
* @category Hypothesis tests
|
|
32
38
|
*/
|
|
33
39
|
export declare function ansariTest(x: Sample, y: Sample, options?: AnsariTestOptions): HTest;
|
|
34
40
|
/**
|
|
35
|
-
* Ansari-Bradley test from a formula and a data frame.
|
|
41
|
+
* Ansari-Bradley test from a formula and a data frame. As R's `ansari.test(formula, data)`: `"y ~ g"`
|
|
36
42
|
* compares the two levels of `g` (the first level is `x`). Only the variables of the formula count: the rows where
|
|
37
43
|
* one of them is missing are dropped.
|
|
38
44
|
*
|
package/dist/htest/aov.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { type LmFormulaOptions, type LmFormulaResult } from "../models/lm.js";
|
|
|
3
3
|
import type { DataFrame } from "../models/modelFrame.js";
|
|
4
4
|
import { type GroupLabel } from "./groups.js";
|
|
5
5
|
import { type Alternative, type HTest, type Sample } from "./types.js";
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Result of {@link aov}: the one-way ANOVA table, rows "between groups" and "residuals".
|
|
8
|
+
*
|
|
9
|
+
* @category Linear models and ANOVA
|
|
10
|
+
*/
|
|
7
11
|
export interface AovResult {
|
|
8
12
|
/** Degrees of freedom `[k - 1, N - k]`. */
|
|
9
13
|
df: [number, number];
|
|
@@ -17,7 +21,8 @@ export interface AovResult {
|
|
|
17
21
|
pValue: number;
|
|
18
22
|
}
|
|
19
23
|
/**
|
|
20
|
-
* One-way analysis of variance. Equivalent to the table of R's `summary(aov(y ~ g))` for one
|
|
24
|
+
* One-way analysis of variance. Equivalent to R's `aov()`. Gives the table of R's `summary(aov(y ~ g))` for one
|
|
25
|
+
* factor.
|
|
21
26
|
*
|
|
22
27
|
* @param x An array of samples (groups), or one sample with group labels `g`.
|
|
23
28
|
* @param g Group labels, parallel to `x`.
|
|
@@ -25,13 +30,15 @@ export interface AovResult {
|
|
|
25
30
|
* @example
|
|
26
31
|
* ```ts
|
|
27
32
|
* const r = aov([[2.9, 3.0, 2.5, 2.6, 3.2], [3.8, 2.7, 4.0, 2.4], [2.8, 3.4, 3.7, 2.2, 2.0]]);
|
|
28
|
-
* r.fValue; // 0.
|
|
33
|
+
* r.fValue; // 0.56007326007326
|
|
29
34
|
* r.pValue; // 0.586632991041738
|
|
30
35
|
* ```
|
|
36
|
+
*
|
|
37
|
+
* @category Linear models and ANOVA
|
|
31
38
|
*/
|
|
32
39
|
export declare function aov(x: Sample | readonly Sample[], g?: readonly GroupLabel[]): AovResult;
|
|
33
40
|
/**
|
|
34
|
-
* Analysis of variance from a model formula
|
|
41
|
+
* Analysis of variance from a model formula, as R's `aov(formula, data)` (with `weights` and
|
|
35
42
|
* `contrasts`): the same fit as {@link lm} with a formula; {@link aovSummary} gives the table of R's
|
|
36
43
|
* `summary(aov(...))`. With one `Error()` term (`y ~ W + Error(id/W)`) the fit has error strata: the result is an
|
|
37
44
|
* {@link AovStrataFit} whose tables {@link aovSummary} returns, one per stratum.
|
|
@@ -46,12 +53,20 @@ export declare function aov(x: Sample | readonly Sample[], g?: readonly GroupLab
|
|
|
46
53
|
* ```
|
|
47
54
|
*/
|
|
48
55
|
export declare function aov(formula: string, data: DataFrame, options?: LmFormulaOptions): LmFormulaResult | AovStrataFit;
|
|
49
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Options for {@link TukeyHSD}.
|
|
58
|
+
*
|
|
59
|
+
* @category Multiple comparisons
|
|
60
|
+
*/
|
|
50
61
|
export interface TukeyHSDOptions {
|
|
51
62
|
/** Family-wise confidence level. Default `0.95`. */
|
|
52
63
|
confLevel?: number;
|
|
53
64
|
}
|
|
54
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Result of {@link TukeyHSD}: one entry per pair of groups, in R's order (2-1, 3-1, ..., k-1, 3-2, ...).
|
|
67
|
+
*
|
|
68
|
+
* @category Multiple comparisons
|
|
69
|
+
*/
|
|
55
70
|
export interface TukeyHSDResult {
|
|
56
71
|
/**
|
|
57
72
|
* Labels of the comparisons, `"a-b"`: the group labels when given, otherwise the positions of the samples in the
|
|
@@ -76,9 +91,25 @@ export interface TukeyHSDResult {
|
|
|
76
91
|
* sizes). Equivalent to R's `TukeyHSD(aov(y ~ g))`.
|
|
77
92
|
*
|
|
78
93
|
* @param x An array of samples (groups), or one sample with group labels `g` (then `options` comes third).
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
98
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
99
|
+
* const r = TukeyHSD(x, g);
|
|
100
|
+
* r.names; // ["b-a", "c-a", "c-b"]
|
|
101
|
+
* r.diff; // [1.4333333333333336, 2.7666666666666666, 1.333333333333333]
|
|
102
|
+
* r.pAdj; // [0.03403130149294014, 0.001492661804896774, 0.04527523376597547]
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @category Multiple comparisons
|
|
79
106
|
*/
|
|
80
107
|
export declare function TukeyHSD(x: Sample | readonly Sample[], g?: readonly GroupLabel[] | TukeyHSDOptions, options?: TukeyHSDOptions): TukeyHSDResult;
|
|
81
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Options for {@link zTest}.
|
|
110
|
+
*
|
|
111
|
+
* @category Hypothesis tests
|
|
112
|
+
*/
|
|
82
113
|
export interface ZTestOptions {
|
|
83
114
|
/** Known standard deviation of the population of `x` (required). */
|
|
84
115
|
sigmaX?: number;
|
|
@@ -93,12 +124,14 @@ export interface ZTestOptions {
|
|
|
93
124
|
}
|
|
94
125
|
/**
|
|
95
126
|
* z test for the mean of one sample, or the difference of the means of two, with known standard deviations.
|
|
96
|
-
* Equivalent to `BSDA::z.test()`
|
|
97
|
-
* are dropped.
|
|
127
|
+
* Equivalent to `BSDA::z.test()` in R. The open end of a one-sided interval is ±Infinity here (NA in BSDA). `NaN`
|
|
128
|
+
* values are dropped.
|
|
98
129
|
*
|
|
99
130
|
* @example
|
|
100
131
|
* ```ts
|
|
101
|
-
* zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue;
|
|
132
|
+
* zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue; // 0.031823127386490346
|
|
102
133
|
* ```
|
|
134
|
+
*
|
|
135
|
+
* @category Hypothesis tests
|
|
103
136
|
*/
|
|
104
137
|
export declare function zTest(x: Sample, y?: Sample | ZTestOptions, options?: ZTestOptions): HTest;
|
package/dist/htest/aov.js
CHANGED
|
@@ -78,6 +78,18 @@ function aovOneway(x, g) {
|
|
|
78
78
|
* sizes). Equivalent to R's `TukeyHSD(aov(y ~ g))`.
|
|
79
79
|
*
|
|
80
80
|
* @param x An array of samples (groups), or one sample with group labels `g` (then `options` comes third).
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
|
|
85
|
+
* const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
|
|
86
|
+
* const r = TukeyHSD(x, g);
|
|
87
|
+
* r.names; // ["b-a", "c-a", "c-b"]
|
|
88
|
+
* r.diff; // [1.4333333333333336, 2.7666666666666666, 1.333333333333333]
|
|
89
|
+
* r.pAdj; // [0.03403130149294014, 0.001492661804896774, 0.04527523376597547]
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @category Multiple comparisons
|
|
81
93
|
*/
|
|
82
94
|
export function TukeyHSD(x, g, options = {}) {
|
|
83
95
|
let labels;
|
|
@@ -115,13 +127,15 @@ export function TukeyHSD(x, g, options = {}) {
|
|
|
115
127
|
}
|
|
116
128
|
/**
|
|
117
129
|
* z test for the mean of one sample, or the difference of the means of two, with known standard deviations.
|
|
118
|
-
* Equivalent to `BSDA::z.test()`
|
|
119
|
-
* are dropped.
|
|
130
|
+
* Equivalent to `BSDA::z.test()` in R. The open end of a one-sided interval is ±Infinity here (NA in BSDA). `NaN`
|
|
131
|
+
* values are dropped.
|
|
120
132
|
*
|
|
121
133
|
* @example
|
|
122
134
|
* ```ts
|
|
123
|
-
* zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue;
|
|
135
|
+
* zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue; // 0.031823127386490346
|
|
124
136
|
* ```
|
|
137
|
+
*
|
|
138
|
+
* @category Hypothesis tests
|
|
125
139
|
*/
|
|
126
140
|
export function zTest(x, y, options = {}) {
|
|
127
141
|
let ys;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Alternative, type HTest } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link binomTest}.
|
|
4
|
+
*
|
|
5
|
+
* @category Hypothesis tests
|
|
6
|
+
*/
|
|
3
7
|
export interface BinomTestOptions {
|
|
4
8
|
/** Hypothesized probability of success. Default `0.5`. */
|
|
5
9
|
p?: number;
|
|
@@ -8,7 +12,11 @@ export interface BinomTestOptions {
|
|
|
8
12
|
/** Confidence level of the interval. Default `0.95`. */
|
|
9
13
|
confLevel?: number;
|
|
10
14
|
}
|
|
11
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Result of {@link binomTest}.
|
|
17
|
+
*
|
|
18
|
+
* @category Hypothesis tests
|
|
19
|
+
*/
|
|
12
20
|
export interface BinomTestResult extends HTest {
|
|
13
21
|
/** Number of trials (`parameterName` is `"number of trials"`). */
|
|
14
22
|
parameter: number;
|
|
@@ -32,5 +40,7 @@ export interface BinomTestResult extends HTest {
|
|
|
32
40
|
* ```ts
|
|
33
41
|
* binomTest(682, 925, { p: 0.75 }).pValue; // 0.3824916
|
|
34
42
|
* ```
|
|
43
|
+
*
|
|
44
|
+
* @category Hypothesis tests
|
|
35
45
|
*/
|
|
36
46
|
export declare function binomTest(x: number | readonly [number, number], n?: number | BinomTestOptions, options?: BinomTestOptions): BinomTestResult;
|
package/dist/htest/binomTest.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Alternative, type HTest, type Sample } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link brunnerMunzelTest}.
|
|
4
|
+
*
|
|
5
|
+
* @category Hypothesis tests
|
|
6
|
+
*/
|
|
3
7
|
export interface BrunnerMunzelTestOptions {
|
|
4
8
|
/**
|
|
5
9
|
* Alternative hypothesis (unambiguous abbreviations accepted). Default `"two.sided"`. As in lawstat, `"greater"`
|
|
@@ -11,7 +15,7 @@ export interface BrunnerMunzelTestOptions {
|
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Brunner-Munzel test that two samples have the relative effect P(X < Y) + P(X = Y)/2 = 1/2, without assuming equal
|
|
14
|
-
* variances or shapes. Equivalent to `lawstat::brunner.munzel.test()
|
|
18
|
+
* variances or shapes. Equivalent to `lawstat::brunner.munzel.test()` in R. `NaN` values are dropped.
|
|
15
19
|
*
|
|
16
20
|
* `estimate` is the estimated relative effect and `confInt` its two-sided interval (not clipped to [0, 1]). When a
|
|
17
21
|
* sample has one value, or when the variance estimates are 0 (for example completely separated samples), the
|
|
@@ -21,8 +25,10 @@ export interface BrunnerMunzelTestOptions {
|
|
|
21
25
|
* ```ts
|
|
22
26
|
* const r = brunnerMunzelTest([1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1], [3, 3, 4, 3, 1, 2, 3, 1, 1, 5, 4]);
|
|
23
27
|
* r.statistic; // 3.1374674823029509
|
|
24
|
-
* r.pValue; // 0.
|
|
28
|
+
* r.pValue; // 0.0057862086661514605
|
|
25
29
|
* r.estimate; // 0.78896103896103909
|
|
26
30
|
* ```
|
|
31
|
+
*
|
|
32
|
+
* @category Hypothesis tests
|
|
27
33
|
*/
|
|
28
34
|
export declare function brunnerMunzelTest(x: Sample, y: Sample, options?: BrunnerMunzelTestOptions): HTest;
|
|
@@ -16,7 +16,7 @@ import { rank } from "../internal/summary.js";
|
|
|
16
16
|
import { checkConfLevel, matchAlternative } from "./types.js";
|
|
17
17
|
/**
|
|
18
18
|
* Brunner-Munzel test that two samples have the relative effect P(X < Y) + P(X = Y)/2 = 1/2, without assuming equal
|
|
19
|
-
* variances or shapes. Equivalent to `lawstat::brunner.munzel.test()
|
|
19
|
+
* variances or shapes. Equivalent to `lawstat::brunner.munzel.test()` in R. `NaN` values are dropped.
|
|
20
20
|
*
|
|
21
21
|
* `estimate` is the estimated relative effect and `confInt` its two-sided interval (not clipped to [0, 1]). When a
|
|
22
22
|
* sample has one value, or when the variance estimates are 0 (for example completely separated samples), the
|
|
@@ -26,9 +26,11 @@ import { checkConfLevel, matchAlternative } from "./types.js";
|
|
|
26
26
|
* ```ts
|
|
27
27
|
* const r = brunnerMunzelTest([1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1], [3, 3, 4, 3, 1, 2, 3, 1, 1, 5, 4]);
|
|
28
28
|
* r.statistic; // 3.1374674823029509
|
|
29
|
-
* r.pValue; // 0.
|
|
29
|
+
* r.pValue; // 0.0057862086661514605
|
|
30
30
|
* r.estimate; // 0.78896103896103909
|
|
31
31
|
* ```
|
|
32
|
+
*
|
|
33
|
+
* @category Hypothesis tests
|
|
32
34
|
*/
|
|
33
35
|
export function brunnerMunzelTest(x, y, options = {}) {
|
|
34
36
|
const xs = Array.from(x).filter((v) => !Number.isNaN(v));
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { HTest, Counts } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link chisqTest}.
|
|
4
|
+
*
|
|
5
|
+
* @category Hypothesis tests
|
|
6
|
+
*/
|
|
3
7
|
export interface ChisqTestOptions {
|
|
4
8
|
/** Apply Yates' continuity correction (2 x 2 tables only). Default `true`. */
|
|
5
9
|
correct?: boolean;
|
|
@@ -17,6 +21,8 @@ export interface ChisqTestOptions {
|
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Result of {@link chisqTest}. Has no `alternative`, because R's `chisq.test()` does not return one.
|
|
24
|
+
*
|
|
25
|
+
* @category Hypothesis tests
|
|
20
26
|
*/
|
|
21
27
|
export interface ChisqTestResult extends Omit<HTest, "alternative"> {
|
|
22
28
|
/** Degrees of freedom (`parameterName` is `"df"`). */
|
|
@@ -34,7 +40,11 @@ export interface ChisqTestResult extends Omit<HTest, "alternative"> {
|
|
|
34
40
|
*/
|
|
35
41
|
stdres: number[] | number[][];
|
|
36
42
|
}
|
|
37
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Result of {@link chisqTest} with two factor vectors: also the levels that label the rows and columns.
|
|
45
|
+
*
|
|
46
|
+
* @category Hypothesis tests
|
|
47
|
+
*/
|
|
38
48
|
export interface ChisqTestFactorsResult extends ChisqTestResult {
|
|
39
49
|
observed: number[][];
|
|
40
50
|
expected: number[][];
|
|
@@ -45,7 +55,11 @@ export interface ChisqTestFactorsResult extends ChisqTestResult {
|
|
|
45
55
|
/** Levels of `y` (columns of the table), sorted by code point. */
|
|
46
56
|
colLevels: string[];
|
|
47
57
|
}
|
|
48
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* A factor: category labels, with `null` or `undefined` for missing values (R's NA).
|
|
60
|
+
*
|
|
61
|
+
* @category Hypothesis tests
|
|
62
|
+
*/
|
|
49
63
|
export type Factor = readonly (string | null | undefined)[];
|
|
50
64
|
/**
|
|
51
65
|
* Pearson's chi-squared test. Equivalent to R's `chisq.test()`.
|
|
@@ -82,6 +96,8 @@ export type Factor = readonly (string | null | undefined)[];
|
|
|
82
96
|
*
|
|
83
97
|
* chisqTest(["a", "b", "a", "b"], ["u", "u", "v", "v"]).rowLevels; // ["a", "b"]
|
|
84
98
|
* ```
|
|
99
|
+
*
|
|
100
|
+
* @category Hypothesis tests
|
|
85
101
|
*/
|
|
86
102
|
export declare function chisqTest(x: Counts | readonly Counts[], options?: ChisqTestOptions): ChisqTestResult;
|
|
87
103
|
export declare function chisqTest(x: Factor, y: Factor, options?: ChisqTestOptions): ChisqTestFactorsResult;
|
package/dist/htest/cor.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { type DD } from "../special/dd.js";
|
|
2
2
|
import type { DataFrame } from "../models/modelFrame.js";
|
|
3
3
|
import { type Alternative, type HTest, type Sample } from "./types.js";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Correlation coefficient: Pearson's r, Kendall's tau or Spearman's rho.
|
|
6
|
+
*
|
|
7
|
+
* @category Descriptive statistics
|
|
8
|
+
*/
|
|
5
9
|
export type CorMethod = "pearson" | "kendall" | "spearman";
|
|
6
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Options for {@link cor}.
|
|
12
|
+
*
|
|
13
|
+
* @category Hypothesis tests
|
|
14
|
+
*/
|
|
7
15
|
export interface CorOptions {
|
|
8
16
|
/** Correlation coefficient to compute. Default `"pearson"`. Unambiguous abbreviations are accepted. */
|
|
9
17
|
method?: CorMethod | (string & {});
|
|
10
18
|
}
|
|
11
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Options for {@link corTest}.
|
|
21
|
+
*
|
|
22
|
+
* @category Hypothesis tests
|
|
23
|
+
*/
|
|
12
24
|
export interface CorTestOptions extends CorOptions {
|
|
13
25
|
/**
|
|
14
26
|
* Alternative hypothesis: `"two.sided"`, `"less"` or `"greater"`. Default `"two.sided"`.
|
|
@@ -29,6 +41,8 @@ export interface CorTestOptions extends CorOptions {
|
|
|
29
41
|
/**
|
|
30
42
|
* Result of {@link corTest}. For Pearson, `statisticName` is `"t"` with `parameter` (df)
|
|
31
43
|
* and `confInt`; for Kendall `"T"` (exact) or `"z"`; for Spearman `"S"`.
|
|
44
|
+
*
|
|
45
|
+
* @category Hypothesis tests
|
|
32
46
|
*/
|
|
33
47
|
export interface CorTestResult extends HTest {
|
|
34
48
|
/** Sample correlation coefficient. */
|
|
@@ -93,10 +107,12 @@ export declare function kendall(x: readonly number[], y: readonly number[]): Ken
|
|
|
93
107
|
* ```
|
|
94
108
|
*
|
|
95
109
|
* There is also a formula form, `corTest("~ x + y", data, options)` (next overload).
|
|
110
|
+
*
|
|
111
|
+
* @category Hypothesis tests
|
|
96
112
|
*/
|
|
97
113
|
export declare function corTest(x: Sample, y: Sample, options?: CorTestOptions): CorTestResult;
|
|
98
114
|
/**
|
|
99
|
-
* Test for correlation from a formula and a data frame.
|
|
115
|
+
* Test for correlation from a formula and a data frame. As R's `cor.test(formula, data)`: the one-sided
|
|
100
116
|
* formula `"~ x + y"` names the two variables. Only they count: the rows where one of them is missing are dropped.
|
|
101
117
|
*
|
|
102
118
|
* @param formula `"~ x + y"` (exactly two variables, no response).
|
|
@@ -3,7 +3,11 @@ import type { AovEzResult } from "../models/aovEz.js";
|
|
|
3
3
|
import type { AovStrataFit } from "../models/aovStrata.js";
|
|
4
4
|
import type { LmFormulaResult } from "../models/lm.js";
|
|
5
5
|
import type { Alternative, Sample } from "./types.js";
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Options for {@link cohensD} and {@link hedgesG}.
|
|
8
|
+
*
|
|
9
|
+
* @category Effect sizes and power
|
|
10
|
+
*/
|
|
7
11
|
export interface CohensDOptions {
|
|
8
12
|
/** Two samples: standardize by the pooled standard deviation (default `true`) or by `sqrt((s1² + s2²)/2)`. */
|
|
9
13
|
pooledSd?: boolean;
|
|
@@ -18,35 +22,55 @@ export interface CohensDOptions {
|
|
|
18
22
|
/** {@link cohensD} only: apply Hedges' small-sample correction (the result is Hedges' g). Default `false`. */
|
|
19
23
|
adjust?: boolean;
|
|
20
24
|
}
|
|
21
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Result of {@link cohensD} and {@link hedgesG}.
|
|
27
|
+
*
|
|
28
|
+
* @category Effect sizes and power
|
|
29
|
+
*/
|
|
22
30
|
export interface CohensDResult {
|
|
23
31
|
/** `"Cohens_d"` or `"Hedges_g"`. */
|
|
24
32
|
name: "Cohens_d" | "Hedges_g";
|
|
33
|
+
/** The effect size. */
|
|
25
34
|
value: number;
|
|
26
35
|
/** Confidence level (absent without an interval). */
|
|
27
36
|
ci?: number;
|
|
37
|
+
/** Lower confidence limit (R's `CI_low`; `-Infinity` for `"less"`). */
|
|
28
38
|
ciLow?: number;
|
|
39
|
+
/** Upper confidence limit (R's `CI_high`; `Infinity` for `"greater"`). */
|
|
29
40
|
ciHigh?: number;
|
|
30
41
|
/** effectsize's warnings. */
|
|
31
42
|
warnings: string[];
|
|
32
43
|
}
|
|
33
44
|
/**
|
|
34
45
|
* Cohen's d: the standardized difference of means of two samples (pooled or averaged standard deviation), of paired
|
|
35
|
-
* samples, or of one sample against `mu`, with a confidence interval from the noncentral t distribution.
|
|
36
|
-
* to effectsize
|
|
46
|
+
* samples, or of one sample against `mu`, with a confidence interval from the noncentral t distribution.
|
|
47
|
+
* Equivalent to `effectsize::cohens_d()` in R.
|
|
37
48
|
*
|
|
38
49
|
* @example
|
|
39
50
|
* ```ts
|
|
40
51
|
* cohensD([5.1, 4.9, 6.2, 5.8], [4.1, 4.5, 3.9, 5.0]).value; // 2.049693834034246
|
|
41
52
|
* ```
|
|
53
|
+
*
|
|
54
|
+
* @category Effect sizes and power
|
|
42
55
|
*/
|
|
43
56
|
export declare function cohensD(x: Sample, y?: Sample, options?: CohensDOptions): CohensDResult;
|
|
44
57
|
/**
|
|
45
|
-
* Hedges' g: Cohen's d and its interval multiplied by the small-sample correction J(df). Equivalent to
|
|
46
|
-
* `hedges_g()
|
|
58
|
+
* Hedges' g: Cohen's d and its interval multiplied by the small-sample correction J(df). Equivalent to
|
|
59
|
+
* `effectsize::hedges_g()` in R.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* hedgesG([5.1, 4.9, 6.2, 5.8], [4.1, 4.5, 3.9, 5.0]).value; // 1.7804187661174387
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @category Effect sizes and power
|
|
47
67
|
*/
|
|
48
68
|
export declare function hedgesG(x: Sample, y?: Sample, options?: Omit<CohensDOptions, "adjust">): CohensDResult;
|
|
49
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Options for {@link etaSquared}, {@link omegaSquared} and {@link epsilonSquared}.
|
|
71
|
+
*
|
|
72
|
+
* @category Effect sizes and power
|
|
73
|
+
*/
|
|
50
74
|
export interface AnovaEffectSizeOptions {
|
|
51
75
|
/**
|
|
52
76
|
* Partial effect sizes (default `true`). A table with a single term always gives the non-partial one (not so for
|
|
@@ -58,7 +82,11 @@ export interface AnovaEffectSizeOptions {
|
|
|
58
82
|
/** `"greater"` (default: the interval is [lower, 1]), `"two.sided"` or `"less"` ([0, upper]). */
|
|
59
83
|
alternative?: Alternative | (string & {});
|
|
60
84
|
}
|
|
61
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Options for {@link etaSquared}.
|
|
87
|
+
*
|
|
88
|
+
* @category Effect sizes and power
|
|
89
|
+
*/
|
|
62
90
|
export interface EtaSquaredOptions extends AnovaEffectSizeOptions {
|
|
63
91
|
/**
|
|
64
92
|
* Generalized eta squared: `true` (all factors manipulated) or the names of the observed factors. Default
|
|
@@ -66,7 +94,11 @@ export interface EtaSquaredOptions extends AnovaEffectSizeOptions {
|
|
|
66
94
|
*/
|
|
67
95
|
generalized?: boolean | readonly string[];
|
|
68
96
|
}
|
|
69
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Result of the ANOVA effect sizes: one row per term.
|
|
99
|
+
*
|
|
100
|
+
* @category Effect sizes and power
|
|
101
|
+
*/
|
|
70
102
|
export interface AnovaEffectSizeTable {
|
|
71
103
|
/** effectsize's columns: the effect size (`"Eta2_partial"`, `"Omega2"`, ...), then `"CI"`, `"CI_low"`, `"CI_high"`. */
|
|
72
104
|
colNames: string[];
|
|
@@ -82,11 +114,13 @@ export interface AnovaEffectSizeTable {
|
|
|
82
114
|
/**
|
|
83
115
|
* A model of the ANOVA effect sizes: a table of `anova()` or `Anova()`, a fit from `lm()` or `aov()` (also with
|
|
84
116
|
* `Error()`), the `aovSummary()` of an `aov()` fit with `Error()`, or a result of `aovEz()`.
|
|
117
|
+
*
|
|
118
|
+
* @category Effect sizes and power
|
|
85
119
|
*/
|
|
86
120
|
export type AnovaEffectSizeModel = AnovaTable | LmFormulaResult | AovStrataFit | AovStrataSummary | AovEzResult;
|
|
87
121
|
/**
|
|
88
122
|
* Eta squared of the terms of an analysis-of-variance table (partial by default, or generalized), with confidence
|
|
89
|
-
* intervals from the noncentral F distribution. Equivalent to effectsize
|
|
123
|
+
* intervals from the noncentral F distribution. Equivalent to `effectsize::eta_squared()` in R. It takes a table of
|
|
90
124
|
* `anova()` or `Anova()`; a fit from `lm()` with a formula is replaced by its `anova()` table.
|
|
91
125
|
*
|
|
92
126
|
* Repeated measures: for a fit of `aov()` with an `Error()` term (or its {@link aovSummary}) each term is measured
|
|
@@ -95,18 +129,42 @@ export type AnovaEffectSizeModel = AnovaTable | LmFormulaResult | AovStrataFit |
|
|
|
95
129
|
*
|
|
96
130
|
* @example
|
|
97
131
|
* ```ts
|
|
132
|
+
* const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
|
|
98
133
|
* etaSquared(anova(lm("y ~ g", data))).colNames; // ["Eta2", "CI", "CI_low", "CI_high"]
|
|
134
|
+
* const long = {
|
|
135
|
+
* y: [5, 7, 8, 4, 6, 9, 6, 8, 8, 5, 5, 7],
|
|
136
|
+
* W: ["a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"],
|
|
137
|
+
* id: ["s1", "s1", "s1", "s2", "s2", "s2", "s3", "s3", "s3", "s4", "s4", "s4"],
|
|
138
|
+
* };
|
|
99
139
|
* etaSquared(aov("y ~ W + Error(id/W)", long)).groups; // ["id:W"]
|
|
100
140
|
* ```
|
|
141
|
+
*
|
|
142
|
+
* @category Effect sizes and power
|
|
101
143
|
*/
|
|
102
144
|
export declare function etaSquared(model: AnovaEffectSizeModel, options?: EtaSquaredOptions): AnovaEffectSizeTable;
|
|
103
145
|
/**
|
|
104
146
|
* Omega squared of the terms of an analysis-of-variance table, also of repeated-measures designs (see
|
|
105
|
-
* {@link etaSquared}). Equivalent to effectsize
|
|
147
|
+
* {@link etaSquared}). Equivalent to `effectsize::omega_squared()` in R.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
|
|
152
|
+
* omegaSquared(anova(lm("y ~ g", data))).table; // [[0.8740518865645682, 0.95, 0.0566677410780818, 1]]
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @category Effect sizes and power
|
|
106
156
|
*/
|
|
107
157
|
export declare function omegaSquared(model: AnovaEffectSizeModel, options?: AnovaEffectSizeOptions): AnovaEffectSizeTable;
|
|
108
158
|
/**
|
|
109
159
|
* Epsilon squared of the terms of an analysis-of-variance table, also of repeated-measures designs (see
|
|
110
|
-
* {@link etaSquared}). Equivalent to effectsize
|
|
160
|
+
* {@link etaSquared}). Equivalent to `effectsize::epsilon_squared()` in R.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
|
|
165
|
+
* epsilonSquared(anova(lm("y ~ g", data))).table; // [[0.8927928150213428, 0.95, 0.1720126241673212, 1]]
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @category Effect sizes and power
|
|
111
169
|
*/
|
|
112
170
|
export declare function epsilonSquared(model: AnovaEffectSizeModel, options?: AnovaEffectSizeOptions): AnovaEffectSizeTable;
|