@numero-uno-jpn/rstats 0.9.0 → 0.11.0

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.ja.md +64 -12
  3. package/README.md +63 -11
  4. package/THIRD_PARTY_NOTICES.md +7 -2
  5. package/dist/chunks/chunk-5WDJPHYY.js +2 -0
  6. package/dist/chunks/chunk-7GQMKH3Z.js +2 -0
  7. package/dist/chunks/chunk-AHHS6AC4.js +3 -0
  8. package/dist/chunks/chunk-ALM3VHFP.js +2 -0
  9. package/dist/chunks/{chunk-TOVTN5Y2.js → chunk-C5XTWMGB.js} +1 -1
  10. package/dist/chunks/chunk-CGBNKHNZ.js +2 -0
  11. package/dist/chunks/{chunk-LWUSYIQ4.js → chunk-EZAFN5CD.js} +1 -1
  12. package/dist/chunks/{chunk-H2AP6TCR.js → chunk-EZWBRCJL.js} +1 -1
  13. package/dist/chunks/chunk-F5EDJFEO.js +2 -0
  14. package/dist/chunks/{chunk-FC2TLHZC.js → chunk-JWBO5WVN.js} +2 -2
  15. package/dist/chunks/{chunk-LE7TBHNI.js → chunk-TOGXTCZO.js} +2 -2
  16. package/dist/chunks/chunk-VJ4BDBMU.js +3 -0
  17. package/dist/chunks/chunk-Y5CNQ266.js +2 -0
  18. package/dist/chunks/{chunk-BGVMSDVJ.js → chunk-Y5PYRAYP.js} +2 -2
  19. package/dist/chunks/{chunk-5K4PS7IV.js → chunk-YSWGDOWK.js} +2 -2
  20. package/dist/data/grouping.d.ts +79 -0
  21. package/dist/data/grouping.js +262 -0
  22. package/dist/descriptive/dataFrames.d.ts +110 -0
  23. package/dist/descriptive/dataFrames.js +392 -0
  24. package/dist/descriptive/factanal.d.ts +56 -0
  25. package/dist/descriptive/factanal.js +186 -0
  26. package/dist/descriptive/missing.d.ts +35 -0
  27. package/dist/descriptive/missing.js +50 -0
  28. package/dist/descriptive/omega.d.ts +56 -0
  29. package/dist/descriptive/omega.js +323 -0
  30. package/dist/descriptive/pivot.d.ts +89 -0
  31. package/dist/descriptive/pivot.js +343 -0
  32. package/dist/descriptive.js +2 -2
  33. package/dist/distributions/bvnorm.d.ts +15 -0
  34. package/dist/distributions/bvnorm.js +131 -0
  35. package/dist/distributions/nbeta.js +34 -1
  36. package/dist/distributions/nchisq.d.ts +10 -0
  37. package/dist/distributions/nchisq.js +46 -0
  38. package/dist/distributions.js +2 -2
  39. package/dist/entries/descriptive.d.ts +4 -0
  40. package/dist/entries/descriptive.js +4 -0
  41. package/dist/entries/distributions.d.ts +1 -0
  42. package/dist/entries/distributions.js +1 -0
  43. package/dist/entries/linalg.d.ts +2 -0
  44. package/dist/entries/linalg.js +2 -0
  45. package/dist/entries/numerics.d.ts +2 -0
  46. package/dist/entries/numerics.js +1 -0
  47. package/dist/entries/tests.d.ts +22 -1
  48. package/dist/entries/tests.js +19 -1
  49. package/dist/htest/agreement.d.ts +141 -0
  50. package/dist/htest/agreement.js +274 -0
  51. package/dist/htest/ansariTest.d.ts +12 -0
  52. package/dist/htest/ansariTest.js +5 -17
  53. package/dist/htest/aov.d.ts +19 -0
  54. package/dist/htest/aov.js +22 -15
  55. package/dist/htest/cor.d.ts +12 -0
  56. package/dist/htest/cor.js +9 -27
  57. package/dist/htest/core/simulate.d.ts +2 -0
  58. package/dist/htest/core/simulate.js +1 -1
  59. package/dist/htest/dunnett.d.ts +5 -0
  60. package/dist/htest/dunnett.js +89 -0
  61. package/dist/htest/effectSize.d.ts +112 -0
  62. package/dist/htest/effectSize.js +385 -0
  63. package/dist/htest/ksTest.d.ts +13 -0
  64. package/dist/htest/ksTest.js +5 -8
  65. package/dist/htest/leveneTest.d.ts +30 -0
  66. package/dist/htest/leveneTest.js +41 -0
  67. package/dist/htest/multipleComparisons.d.ts +147 -0
  68. package/dist/htest/multipleComparisons.js +369 -0
  69. package/dist/htest/normalityTests.d.ts +44 -0
  70. package/dist/htest/normalityTests.js +164 -0
  71. package/dist/htest/onewayTest.d.ts +14 -0
  72. package/dist/htest/onewayTest.js +5 -7
  73. package/dist/htest/polycor.d.ts +117 -0
  74. package/dist/htest/polycor.js +468 -0
  75. package/dist/htest/power.d.ts +132 -0
  76. package/dist/htest/power.js +227 -0
  77. package/dist/htest/pwr.d.ts +263 -0
  78. package/dist/htest/pwr.js +440 -0
  79. package/dist/htest/rankTests.d.ts +64 -0
  80. package/dist/htest/rankTests.js +27 -29
  81. package/dist/htest/tTest.d.ts +20 -0
  82. package/dist/htest/tTest.js +19 -24
  83. package/dist/htest/testFormula.d.ts +57 -0
  84. package/dist/htest/testFormula.js +171 -0
  85. package/dist/htest/trendTests.d.ts +57 -0
  86. package/dist/htest/trendTests.js +167 -0
  87. package/dist/htest/varTest.d.ts +23 -0
  88. package/dist/htest/varTest.js +11 -21
  89. package/dist/htest/wilcoxTest.d.ts +14 -0
  90. package/dist/htest/wilcoxTest.js +9 -24
  91. package/dist/linalg/eigen.d.ts +8 -0
  92. package/dist/linalg/eigen.js +5 -4
  93. package/dist/linalg/expm.d.ts +48 -0
  94. package/dist/linalg/expm.js +472 -0
  95. package/dist/linalg/ops.d.ts +13 -2
  96. package/dist/linalg/ops.js +20 -5
  97. package/dist/linalg/schur.d.ts +48 -0
  98. package/dist/linalg/schur.js +225 -0
  99. package/dist/linalg.js +2 -2
  100. package/dist/models/anovaSequential.d.ts +58 -0
  101. package/dist/models/anovaSequential.js +138 -0
  102. package/dist/models/aovEz.d.ts +64 -0
  103. package/dist/models/aovEz.js +332 -0
  104. package/dist/models/aovStrata.d.ts +32 -0
  105. package/dist/models/aovStrata.js +104 -0
  106. package/dist/models/carAnova.d.ts +30 -0
  107. package/dist/models/carAnova.js +121 -0
  108. package/dist/models/coxph.d.ts +101 -0
  109. package/dist/models/coxph.js +502 -0
  110. package/dist/models/ddLeastSquares.d.ts +30 -0
  111. package/dist/models/ddLeastSquares.js +90 -0
  112. package/dist/models/ddMatrix.d.ts +10 -0
  113. package/dist/models/ddMatrix.js +91 -0
  114. package/dist/models/formula.d.ts +83 -0
  115. package/dist/models/formula.js +333 -0
  116. package/dist/models/lm.d.ts +84 -3
  117. package/dist/models/lm.js +141 -44
  118. package/dist/models/mauchly.d.ts +48 -0
  119. package/dist/models/mauchly.js +123 -0
  120. package/dist/models/modelFrame.d.ts +40 -0
  121. package/dist/models/modelFrame.js +131 -0
  122. package/dist/models/modelMatrix.d.ts +88 -0
  123. package/dist/models/modelMatrix.js +170 -0
  124. package/dist/models/survival.d.ts +87 -0
  125. package/dist/models/survival.js +238 -0
  126. package/dist/numerics.js +2 -2
  127. package/dist/optim/lbfgsb.d.ts +20 -0
  128. package/dist/optim/lbfgsb.js +1240 -0
  129. package/dist/optim/optim.d.ts +85 -0
  130. package/dist/optim/optim.js +610 -0
  131. package/dist/rstats.js +19 -4
  132. package/dist/special.js +2 -2
  133. package/dist/tests.js +17 -4
  134. package/llms.txt +114 -0
  135. package/package.json +3 -2
  136. package/dist/chunks/chunk-24U4DKRY.js +0 -2
  137. package/dist/chunks/chunk-IVOBWYLV.js +0 -2
  138. package/dist/chunks/chunk-JLSTEMSN.js +0 -2
  139. package/dist/chunks/chunk-MF4VBCHQ.js +0 -2
  140. package/dist/chunks/chunk-MSAUU6PY.js +0 -2
  141. package/dist/chunks/chunk-YC4JWUKG.js +0 -2
  142. package/dist/chunks/chunk-ZRO446BP.js +0 -2
@@ -0,0 +1,164 @@
1
+ // Tests of normality as the nortest package computes them: Anderson-Darling (ad.test), Cramer-von Mises (cvm.test),
2
+ // Lilliefors' Kolmogorov-Smirnov (lillie.test), Shapiro-Francia (sf.test) and the Pearson chi-square test
3
+ // (pearson.test), each with the composite hypothesis (mean and standard deviation estimated).
4
+ //
5
+ // Written for rStats.js from oracle/rm-tests-behaviour.md (no ported code; nortest's source was not read): the
6
+ // statistics from the standardised order statistics, the p-values from the closed-form approximations given there
7
+ // (piecewise exponentials of A and W, Dallal and Wilkinson's formula for D, a normal approximation of log(1 - W) for
8
+ // the Shapiro-Francia W), and the chi-square test on classes of equal probability.
9
+ import { pgamma1 } from "../distributions/gamma.js";
10
+ import { pnorm, qnorm } from "../distributions/normal.js";
11
+ import { covariance, dropNaN, mean, variance } from "../internal/summary.js";
12
+ /** The sorted values without NaN */
13
+ function sorted(x) {
14
+ return dropNaN(Array.from(x)).sort((a, b) => a - b);
15
+ }
16
+ /** The sorted values standardised by their mean and standard deviation */
17
+ function standardized(xs) {
18
+ const m = mean(xs);
19
+ const s = Math.sqrt(variance(xs));
20
+ return xs.map((v) => (v - m) / s);
21
+ }
22
+ /**
23
+ * Anderson-Darling test for normality. Equivalent to nortest's `ad.test()`. `NaN` values are dropped; at least 8
24
+ * values are needed.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * adTest([2.1, 3.4, 1.9, 5.6, 4.4, 3.8, 2.9, 4.1, 3.3, 2.6]).statistic; // 0.15414195923525043
29
+ * ```
30
+ */
31
+ export function adTest(x) {
32
+ const xs = sorted(x);
33
+ const n = xs.length;
34
+ if (n < 8)
35
+ throw new RangeError("sample size must be greater than 7");
36
+ const z = standardized(xs);
37
+ let s = 0;
38
+ for (let i = 1; i <= n; i++) {
39
+ s += (2 * i - 1) * (pnorm(z[i - 1], { logP: true }) + pnorm(z[n - i], { lowerTail: false, logP: true }));
40
+ }
41
+ const a = -n - s / n;
42
+ const aa = (1 + 0.75 / n + 2.25 / n ** 2) * a;
43
+ let pValue;
44
+ if (aa < 0.2)
45
+ pValue = 1 - Math.exp(-13.436 + 101.14 * aa - 223.73 * aa ** 2);
46
+ else if (aa < 0.34)
47
+ pValue = 1 - Math.exp(-8.318 + 42.796 * aa - 59.938 * aa ** 2);
48
+ else if (aa < 0.6)
49
+ pValue = Math.exp(0.9177 - 4.279 * aa - 1.38 * aa ** 2);
50
+ else if (aa < 10)
51
+ pValue = Math.exp(1.2937 - 5.709 * aa + 0.0186 * aa ** 2);
52
+ else
53
+ pValue = 3.7e-24;
54
+ return { method: "Anderson-Darling normality test", statistic: a, statisticName: "A", pValue };
55
+ }
56
+ /**
57
+ * Cramer-von Mises test for normality. Equivalent to nortest's `cvm.test()`. `NaN` values are dropped; at least 8
58
+ * values are needed.
59
+ */
60
+ export function cvmTest(x) {
61
+ const xs = sorted(x);
62
+ const n = xs.length;
63
+ if (n < 8)
64
+ throw new RangeError("sample size must be greater than 7");
65
+ const z = standardized(xs);
66
+ let w = 1 / (12 * n);
67
+ z.forEach((zi, k) => {
68
+ w += (pnorm(zi) - (2 * (k + 1) - 1) / (2 * n)) ** 2;
69
+ });
70
+ const ww = (1 + 0.5 / n) * w;
71
+ const warnings = [];
72
+ let pValue;
73
+ if (ww < 0.0275)
74
+ pValue = 1 - Math.exp(-13.953 + 775.5 * ww - 12542.61 * ww ** 2);
75
+ else if (ww < 0.051)
76
+ pValue = 1 - Math.exp(-5.903 + 179.546 * ww - 1515.29 * ww ** 2);
77
+ else if (ww < 0.092)
78
+ pValue = Math.exp(0.886 - 31.62 * ww + 10.897 * ww ** 2);
79
+ else if (ww < 1.1)
80
+ pValue = Math.exp(1.111 - 34.242 * ww + 12.832 * ww ** 2);
81
+ else {
82
+ pValue = 7.37e-10;
83
+ warnings.push("p-value is smaller than 7.37e-10, cannot be computed more accurately");
84
+ }
85
+ return { method: "Cramer-von Mises normality test", statistic: w, statisticName: "W", pValue, warnings };
86
+ }
87
+ /**
88
+ * Lilliefors (Kolmogorov-Smirnov) test for normality. Equivalent to nortest's `lillie.test()`. `NaN` values are
89
+ * dropped; at least 5 values are needed.
90
+ */
91
+ export function lillieTest(x) {
92
+ const xs = sorted(x);
93
+ const n = xs.length;
94
+ if (n < 5)
95
+ throw new RangeError("sample size must be greater than 4");
96
+ const p = standardized(xs).map((v) => pnorm(v));
97
+ let dPlus = -Infinity;
98
+ let dMinus = -Infinity;
99
+ p.forEach((pi, k) => {
100
+ dPlus = Math.max(dPlus, (k + 1) / n - pi);
101
+ dMinus = Math.max(dMinus, pi - k / n);
102
+ });
103
+ const d = Math.max(dPlus, dMinus);
104
+ const kd = n <= 100 ? d : d * (n / 100) ** 0.49;
105
+ const nd = n <= 100 ? n : 100;
106
+ let pValue = Math.exp(-7.01256 * kd ** 2 * (nd + 2.78019) + 2.99587 * kd * Math.sqrt(nd + 2.78019) - 0.122119 + 0.974598 / Math.sqrt(nd) + 1.67997 / nd);
107
+ if (pValue > 0.1) {
108
+ const kk = (Math.sqrt(n) - 0.01 + 0.85 / Math.sqrt(n)) * d;
109
+ if (kk <= 0.302)
110
+ pValue = 1;
111
+ else if (kk <= 0.5)
112
+ pValue = 2.76773 - 19.828315 * kk + 80.709644 * kk ** 2 - 138.55152 * kk ** 3 + 81.218052 * kk ** 4;
113
+ else if (kk <= 0.9)
114
+ pValue = -4.901232 + 40.662806 * kk - 97.490286 * kk ** 2 + 94.029866 * kk ** 3 - 32.355711 * kk ** 4;
115
+ else if (kk <= 1.31)
116
+ pValue = 6.198765 - 19.558097 * kk + 23.186922 * kk ** 2 - 12.234627 * kk ** 3 + 2.423045 * kk ** 4;
117
+ else
118
+ pValue = 0;
119
+ }
120
+ return { method: "Lilliefors (Kolmogorov-Smirnov) normality test", statistic: d, statisticName: "D", pValue };
121
+ }
122
+ /**
123
+ * Shapiro-Francia test for normality. Equivalent to nortest's `sf.test()`. `NaN` values are dropped; the sample size
124
+ * must be between 5 and 5000.
125
+ */
126
+ export function sfTest(x) {
127
+ const xs = sorted(x);
128
+ const n = xs.length;
129
+ if (n < 5 || n > 5000)
130
+ throw new RangeError("sample size must be between 5 and 5000");
131
+ const q = xs.map((_, k) => qnorm((k + 1 - 3 / 8) / (n + 1 / 4)));
132
+ const w = covariance(xs, q) ** 2 / (variance(xs) * variance(q));
133
+ const u = Math.log(n);
134
+ const v = Math.log(u);
135
+ const mu = -1.2725 + 1.0521 * (v - u);
136
+ const sig = 1.0308 - 0.26758 * (v + 2 / u);
137
+ const pValue = pnorm((Math.log(1 - w) - mu) / sig, { lowerTail: false });
138
+ return { method: "Shapiro-Francia normality test", statistic: w, statisticName: "W", pValue };
139
+ }
140
+ /**
141
+ * Pearson chi-square test for normality, with classes of equal probability under the fitted normal distribution.
142
+ * Equivalent to nortest's `pearson.test()`. `NaN` values are dropped.
143
+ */
144
+ export function pearsonTest(x, options = {}) {
145
+ const xs = sorted(x);
146
+ const n = xs.length;
147
+ const k = options.nClasses ?? Math.ceil(2 * n ** (2 / 5));
148
+ const adjust = options.adjust ?? true;
149
+ const counts = new Array(k).fill(0);
150
+ for (const z of standardized(xs)) {
151
+ const c = Math.floor(1 + k * pnorm(z));
152
+ if (c >= 1 && c <= k)
153
+ counts[c - 1]++;
154
+ }
155
+ const e = n / k;
156
+ const statistic = counts.reduce((a, c) => a + (c - e) ** 2 / e, 0);
157
+ const df = k - 1 - (adjust ? 2 : 0);
158
+ return {
159
+ method: "Pearson chi-square normality test",
160
+ statistic,
161
+ statisticName: "P",
162
+ pValue: pgamma1(statistic, df / 2, 2, false, false),
163
+ };
164
+ }
@@ -1,3 +1,4 @@
1
+ import type { DataFrame } from "../models/modelFrame.js";
1
2
  import { type GroupLabel } from "./groups.js";
2
3
  import type { HTest, Sample } from "./types.js";
3
4
  /** Options for {@link onewayTest}. */
@@ -17,8 +18,21 @@ export interface OnewayTestResult extends Omit<HTest, "alternative" | "parameter
17
18
  *
18
19
  * @param x An array of samples, or one sample with group labels `g`.
19
20
  * @param g Group labels, parallel to `x` (or the options, when `x` is an array of samples).
21
+ *
22
+ * There is also a formula form, `onewayTest("y ~ A + B", data, options)` (next overload).
20
23
  */
21
24
  export declare function onewayTest(x: Sample | readonly Sample[], g?: readonly GroupLabel[] | OnewayTestOptions, options?: OnewayTestOptions): OnewayTestResult;
25
+ /**
26
+ * One-way analysis of means from a formula and a data frame. Equivalent to R's `oneway.test(formula, data)`:
27
+ * `"y ~ A"` has one group per level of `A`; with several factors, `"y ~ A + B"`, the groups are the combinations of
28
+ * their levels present in the data (R's `interaction()`, the first factor varying fastest). Only the variables of
29
+ * the formula count: the rows where one of them is missing are dropped.
30
+ *
31
+ * @param formula `"y ~ A"` or `"y ~ A + B + ..."`.
32
+ * @param data The data frame: an object of columns (`null` or `NaN` for a missing value).
33
+ * @param options See {@link OnewayTestOptions}.
34
+ */
35
+ export declare function onewayTest(formula: string, data: DataFrame, options?: OnewayTestOptions): OnewayTestResult;
22
36
  /**
23
37
  * Shapiro-Wilk test of normality. Equivalent to R's `shapiro.test()`. `NaN` values are dropped; the sample size must
24
38
  * be between 3 and 5000.
@@ -9,14 +9,12 @@ import { pf1 } from "../distributions/f.js";
9
9
  import { mean, variance } from "../internal/summary.js";
10
10
  import { swilkOneMinusW, swilkPValueFromOneMinusW } from "./core/shapiro.js";
11
11
  import { toGroups } from "./groups.js";
12
- /**
13
- * Test that several normal samples have equal means, without (default) or with the assumption of equal variances.
14
- * Equivalent to R's `oneway.test()`.
15
- *
16
- * @param x An array of samples, or one sample with group labels `g`.
17
- * @param g Group labels, parallel to `x` (or the options, when `x` is an array of samples).
18
- */
12
+ import { onewayData } from "./testFormula.js";
19
13
  export function onewayTest(x, g, options = {}) {
14
+ if (typeof x === "string") {
15
+ const d = onewayData(x, g);
16
+ return onewayTest(d.values, d.groups, options);
17
+ }
20
18
  let labels;
21
19
  if (g !== undefined && !Array.isArray(g))
22
20
  options = g;
@@ -0,0 +1,117 @@
1
+ /** Result of {@link polychor} and {@link polyserial}. */
2
+ export interface PolycorResult {
3
+ /** The correlation (`NaN` where polycor returns NA). */
4
+ rho: number;
5
+ /** polycor's warnings, in order. */
6
+ warnings: string[];
7
+ }
8
+ /** Options of {@link polychor} and {@link polyserial}. */
9
+ export interface PolycorOptions {
10
+ /**
11
+ * Estimate the correlation and the thresholds together by maximum likelihood (polycor's `ML = TRUE`), instead of
12
+ * the two-step estimate. Default `false`.
13
+ */
14
+ ML?: boolean;
15
+ /**
16
+ * Also return the variances of the estimates, the chi-square test of bivariate normality and the thresholds
17
+ * (polycor's `std.err = TRUE`). Without `ML`, the correlation is the maximum-likelihood one given the two-step
18
+ * thresholds. Default `false`.
19
+ */
20
+ stdErr?: boolean;
21
+ }
22
+ /** Result of {@link polychor} with `stdErr`. */
23
+ export interface PolychorStdErrResult extends PolycorResult {
24
+ /**
25
+ * Variances and covariances of the estimates (the inverse of the negative Hessian of the log-likelihood at the
26
+ * maximum), in the order rho, the row thresholds, the column thresholds; 1 × 1 (rho alone) without `ML`.
27
+ */
28
+ var: number[][];
29
+ /** Chi-square statistic of the test of bivariate normality. */
30
+ chisq: number;
31
+ /** Its degrees of freedom, r c − r − c. */
32
+ df: number;
33
+ /** The number of observations (the total of the table). */
34
+ n: number;
35
+ /** The row thresholds (the estimates with `ML`, the two-step ones otherwise). */
36
+ rowCuts: number[];
37
+ /** The column thresholds. */
38
+ colCuts: number[];
39
+ }
40
+ /** Result of {@link polyserial} with `stdErr`. */
41
+ export interface PolyserialStdErrResult extends PolycorResult {
42
+ /** Variances and covariances of the estimates, in the order rho, the thresholds; 1 × 1 (rho alone) without `ML`. */
43
+ var: number[][];
44
+ /** Chi-square statistic of the test of bivariate normality (polycor's, on a binned table). */
45
+ chisq: number;
46
+ /** Its degrees of freedom, 3 s − 1 for s categories. */
47
+ df: number;
48
+ /** The number of observations used. */
49
+ n: number;
50
+ /** The thresholds of the ordinal variable (the estimates with `ML`, the two-step ones otherwise). */
51
+ cuts: number[];
52
+ }
53
+ type Table = readonly (readonly number[])[];
54
+ /**
55
+ * Polychoric correlation of two ordinal variables. By default the two-step estimate: thresholds from the margins,
56
+ * then the maximum-likelihood correlation given them. Equivalent to polycor's `polychor(x, y)` or `polychor(table)`.
57
+ *
58
+ * Given `x` and `y`, the table has the sorted distinct values of `x` as rows and those of `y` as columns (pairs with
59
+ * a missing value are not counted). Rows and columns with a zero margin are removed with a warning; with fewer than
60
+ * two rows or columns left, `rho` is `NaN` (and the result has no other fields).
61
+ *
62
+ * With `ML`, the correlation and the thresholds are estimated together by maximum likelihood; with `stdErr`, the
63
+ * result also has their variances, the chi-square test of bivariate normality and the thresholds (with `stdErr`
64
+ * alone, the correlation is maximised given the two-step thresholds). The exact maximum is returned (R's optimisers
65
+ * stop about 1e-4 short of it). If the likelihood increases up to |rho| = 0.9999, `rho` is ±0.9999 with a warning.
66
+ *
67
+ * @param table - A contingency table (array of rows of counts).
68
+ * @param options - `ML` and `stdErr` (see {@link PolycorOptions}).
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]]).rho; // 0.785882312445335
73
+ * polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]], { ML: true }).rho; // 0.7911463316235798
74
+ * ```
75
+ */
76
+ export declare function polychor(table: Table, options: PolycorOptions & {
77
+ stdErr: true;
78
+ }): PolychorStdErrResult;
79
+ export declare function polychor(table: Table, options?: PolycorOptions): PolycorResult;
80
+ /**
81
+ * Polychoric correlation of two ordinal variables given as vectors of category codes (see the table form).
82
+ *
83
+ * @param x - Categories of the first variable.
84
+ * @param y - Categories of the second variable, the same length.
85
+ * @param options - `ML` and `stdErr` (see {@link PolycorOptions}).
86
+ */
87
+ export declare function polychor(x: readonly number[], y: readonly number[], options: PolycorOptions & {
88
+ stdErr: true;
89
+ }): PolychorStdErrResult;
90
+ export declare function polychor(x: readonly number[], y: readonly number[], options?: PolycorOptions): PolycorResult;
91
+ /**
92
+ * Polyserial correlation of a numeric variable and an ordinal one. By default the two-step (ad hoc) estimate.
93
+ * Equivalent to polycor's `polyserial(x, y)`.
94
+ *
95
+ * Pairs with a missing value are dropped. The categories of `y` are its sorted distinct values, coded 1, 2, ...;
96
+ * with fewer than two, `rho` is `NaN` (and the result has no other fields). A two-step estimate beyond ±0.9999 is set
97
+ * to ±0.9999 with a warning.
98
+ *
99
+ * With `ML`, the correlation and the thresholds are estimated together by maximum likelihood; with `stdErr`, the
100
+ * result also has their variances, polycor's chi-square test of bivariate normality and the thresholds (with `stdErr`
101
+ * alone, the correlation is maximised given the two-step thresholds). The exact maximum is returned (R's optimisers
102
+ * stop about 1e-4 short of it). If the likelihood increases up to |rho| = 0.9999, `rho` is ±0.9999 with a warning.
103
+ *
104
+ * @param x - The numeric variable.
105
+ * @param y - Categories of the ordinal variable, the same length.
106
+ * @param options - `ML` and `stdErr` (see {@link PolycorOptions}).
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * polyserial([0.2, -1.1, 0.8, 1.5, -0.3, 0.1, -0.9, 2.0], [1, 1, 2, 3, 2, 2, 1, 2]).rho; // 0.8085111526489707
111
+ * ```
112
+ */
113
+ export declare function polyserial(x: readonly number[], y: readonly number[], options: PolycorOptions & {
114
+ stdErr: true;
115
+ }): PolyserialStdErrResult;
116
+ export declare function polyserial(x: readonly number[], y: readonly number[], options?: PolycorOptions): PolycorResult;
117
+ export {};