@numero-uno-jpn/rstats 0.16.0 → 1.0.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 (243) hide show
  1. package/CHANGELOG.md +205 -0
  2. package/README.ja.md +57 -23
  3. package/README.md +60 -23
  4. package/dist/chunks/{chunk-5UQCRBAG.js → chunk-3W5NFFAA.js} +1 -1
  5. package/dist/chunks/chunk-4F2IALD4.js +3 -0
  6. package/dist/chunks/{chunk-QNNL7AZ3.js → chunk-4OLDGML4.js} +2 -2
  7. package/dist/chunks/chunk-63OPBEYO.js +2 -0
  8. package/dist/chunks/chunk-6XJBCRBV.js +2 -0
  9. package/dist/chunks/chunk-BQSIBJVX.js +2 -0
  10. package/dist/chunks/chunk-BWKHYRM6.js +3 -0
  11. package/dist/chunks/{chunk-W26LRYOJ.js → chunk-CKV4JWW2.js} +1 -1
  12. package/dist/chunks/chunk-DCAWMF4K.js +2 -0
  13. package/dist/chunks/chunk-F7YGX7PN.js +2 -0
  14. package/dist/chunks/chunk-H7I32ZZE.js +2 -0
  15. package/dist/chunks/chunk-IEOD5GWC.js +3 -0
  16. package/dist/chunks/chunk-KICBQGFN.js +2 -0
  17. package/dist/chunks/chunk-LROMWFAK.js +2 -0
  18. package/dist/chunks/chunk-NSWENS3S.js +2 -0
  19. package/dist/chunks/chunk-O2SQMGE3.js +2 -0
  20. package/dist/chunks/chunk-QQX46TCI.js +2 -0
  21. package/dist/chunks/chunk-QZK3CCBA.js +2 -0
  22. package/dist/chunks/chunk-UJ66VQIG.js +2 -0
  23. package/dist/chunks/chunk-UKNDX4BA.js +2 -0
  24. package/dist/chunks/chunk-WIBKS73G.js +2 -0
  25. package/dist/chunks/{chunk-URIO5LY5.js → chunk-WQWZ7FND.js} +2 -2
  26. package/dist/chunks/chunk-WWVMVZUL.js +2 -0
  27. package/dist/chunks/chunk-YG5S5AVP.js +2 -0
  28. package/dist/chunks/chunk-YHNMBYSW.js +2 -0
  29. package/dist/data/grouping.js +6 -2
  30. package/dist/descriptive/basic.js +20 -0
  31. package/dist/descriptive/cov.js +11 -0
  32. package/dist/descriptive/dataFrames.js +13 -5
  33. package/dist/descriptive/factanal.d.ts +2 -0
  34. package/dist/descriptive/factanal.js +10 -2
  35. package/dist/descriptive/hist.js +6 -0
  36. package/dist/descriptive/moments.js +14 -0
  37. package/dist/descriptive/omega.js +8 -3
  38. package/dist/descriptive/pivot.d.ts +4 -1
  39. package/dist/descriptive/pivot.js +27 -13
  40. package/dist/descriptive/quantile.js +8 -0
  41. package/dist/descriptive/rank.js +4 -0
  42. package/dist/descriptive/table.d.ts +20 -1
  43. package/dist/descriptive/table.js +14 -14
  44. package/dist/descriptive.js +2 -2
  45. package/dist/distributions/arcsine.js +8 -0
  46. package/dist/distributions/beta.js +9 -0
  47. package/dist/distributions/binomial.js +9 -0
  48. package/dist/distributions/cauchy.js +9 -0
  49. package/dist/distributions/chisq.js +9 -0
  50. package/dist/distributions/exponential.js +9 -0
  51. package/dist/distributions/f.js +9 -0
  52. package/dist/distributions/gamma.js +8 -0
  53. package/dist/distributions/geometric.js +9 -0
  54. package/dist/distributions/hypergeometric.js +8 -0
  55. package/dist/distributions/invgamma.js +8 -0
  56. package/dist/distributions/kumaraswamy.js +9 -0
  57. package/dist/distributions/laplace.js +9 -0
  58. package/dist/distributions/logistic.js +9 -0
  59. package/dist/distributions/lognormal.js +8 -0
  60. package/dist/distributions/multinomial.js +4 -0
  61. package/dist/distributions/negbinomial.js +8 -0
  62. package/dist/distributions/normal.js +8 -0
  63. package/dist/distributions/pareto.js +8 -0
  64. package/dist/distributions/poisson.js +9 -0
  65. package/dist/distributions/signrank.js +9 -0
  66. package/dist/distributions/summary.d.ts +2 -1
  67. package/dist/distributions/summary.js +31 -1
  68. package/dist/distributions/t.js +9 -0
  69. package/dist/distributions/triangular.js +9 -0
  70. package/dist/distributions/tukey.js +6 -0
  71. package/dist/distributions/uniform.js +8 -0
  72. package/dist/distributions/weibull.js +8 -0
  73. package/dist/distributions/wilcox.js +9 -0
  74. package/dist/distributions.js +2 -2
  75. package/dist/entries/descriptive.d.ts +3 -1
  76. package/dist/entries/descriptive.js +1 -1
  77. package/dist/entries/distributions.d.ts +1 -0
  78. package/dist/entries/distributions.js +2 -0
  79. package/dist/entries/linalg.d.ts +3 -1
  80. package/dist/entries/mixed.d.ts +9 -0
  81. package/dist/entries/mixed.js +8 -1
  82. package/dist/entries/numerics.d.ts +2 -1
  83. package/dist/entries/tests.d.ts +8 -5
  84. package/dist/entries/tests.js +3 -1
  85. package/dist/htest/agreement.d.ts +13 -0
  86. package/dist/htest/agreement.js +46 -7
  87. package/dist/htest/ansariTest.d.ts +2 -1
  88. package/dist/htest/ansariTest.js +43 -12
  89. package/dist/htest/aov.d.ts +28 -22
  90. package/dist/htest/aov.js +42 -13
  91. package/dist/htest/binomTest.js +6 -0
  92. package/dist/htest/brunnerMunzelTest.js +5 -0
  93. package/dist/htest/chisqTest.d.ts +3 -1
  94. package/dist/htest/chisqTest.js +21 -3
  95. package/dist/htest/cor.d.ts +7 -1
  96. package/dist/htest/cor.js +40 -7
  97. package/dist/htest/core/simulate.d.ts +6 -0
  98. package/dist/htest/core/simulate.js +20 -0
  99. package/dist/htest/effectSize.d.ts +3 -0
  100. package/dist/htest/effectSize.js +28 -8
  101. package/dist/htest/fisherTest.d.ts +2 -1
  102. package/dist/htest/fisherTest.js +52 -6
  103. package/dist/htest/ksTest.d.ts +4 -0
  104. package/dist/htest/ksTest.js +13 -4
  105. package/dist/htest/leveneTest.d.ts +2 -0
  106. package/dist/htest/leveneTest.js +9 -3
  107. package/dist/htest/mantelhaenTest.js +7 -0
  108. package/dist/htest/mcnemarTest.js +8 -0
  109. package/dist/htest/multipleComparisons.d.ts +16 -25
  110. package/dist/htest/multipleComparisons.js +26 -43
  111. package/dist/htest/normalityTests.js +10 -4
  112. package/dist/htest/onewayTest.js +10 -0
  113. package/dist/htest/pAdjust.js +4 -0
  114. package/dist/htest/pairwise.d.ts +2 -0
  115. package/dist/htest/pairwise.js +29 -6
  116. package/dist/htest/poissonTest.js +6 -0
  117. package/dist/htest/polycor.js +20 -10
  118. package/dist/htest/power.d.ts +4 -0
  119. package/dist/htest/power.js +16 -2
  120. package/dist/htest/propTest.d.ts +3 -0
  121. package/dist/htest/propTest.js +23 -2
  122. package/dist/htest/pwr.d.ts +38 -1
  123. package/dist/htest/pwr.js +38 -15
  124. package/dist/htest/rankTests.js +7 -1
  125. package/dist/htest/tTest.d.ts +2 -0
  126. package/dist/htest/tTest.js +9 -0
  127. package/dist/htest/testFormula.js +11 -11
  128. package/dist/htest/trendTests.d.ts +21 -1
  129. package/dist/htest/trendTests.js +13 -18
  130. package/dist/htest/types.d.ts +2 -0
  131. package/dist/htest/varTest.js +7 -0
  132. package/dist/htest/wilcoxTest.js +51 -9
  133. package/dist/internal/checkOptions.d.ts +11 -0
  134. package/dist/internal/checkOptions.js +31 -0
  135. package/dist/internal/optionalArgs.d.ts +12 -0
  136. package/dist/internal/optionalArgs.js +46 -0
  137. package/dist/internal/warnings.d.ts +66 -0
  138. package/dist/internal/warnings.js +122 -0
  139. package/dist/linalg/basic.js +7 -0
  140. package/dist/linalg/chol.js +6 -0
  141. package/dist/linalg/eigen.js +4 -0
  142. package/dist/linalg/expm.js +4 -0
  143. package/dist/linalg/kappa.js +6 -0
  144. package/dist/linalg/lu.js +5 -0
  145. package/dist/linalg/norm.js +4 -0
  146. package/dist/linalg/ops.d.ts +27 -2
  147. package/dist/linalg/ops.js +14 -13
  148. package/dist/linalg/qr.js +14 -0
  149. package/dist/linalg/solve.js +9 -0
  150. package/dist/linalg/svd.js +6 -2
  151. package/dist/linalg.js +2 -2
  152. package/dist/mixed.js +5 -4
  153. package/dist/models/anovaSequential.d.ts +16 -1
  154. package/dist/models/anovaSequential.js +50 -7
  155. package/dist/models/aovEz.js +16 -11
  156. package/dist/models/aovStrata.js +15 -4
  157. package/dist/models/carAnova.js +11 -17
  158. package/dist/models/coxph.d.ts +6 -0
  159. package/dist/models/coxph.js +21 -6
  160. package/dist/models/formula.d.ts +5 -2
  161. package/dist/models/formula.js +31 -8
  162. package/dist/models/glm.d.ts +22 -2
  163. package/dist/models/glm.js +32 -22
  164. package/dist/models/glmAnova.js +8 -3
  165. package/dist/models/glmConfint.js +6 -2
  166. package/dist/models/glmFamily.d.ts +1 -6
  167. package/dist/models/glmFamily.js +3 -22
  168. package/dist/models/glmer.d.ts +255 -0
  169. package/dist/models/glmer.js +635 -0
  170. package/dist/models/glmerAnova.d.ts +81 -0
  171. package/dist/models/glmerAnova.js +139 -0
  172. package/dist/models/glmerDeviance.d.ts +98 -0
  173. package/dist/models/glmerDeviance.js +576 -0
  174. package/dist/models/glmerFamily.d.ts +57 -0
  175. package/dist/models/glmerFamily.js +236 -0
  176. package/dist/models/glmerGradient.d.ts +46 -0
  177. package/dist/models/glmerGradient.js +301 -0
  178. package/dist/models/glmerStructure.d.ts +45 -0
  179. package/dist/models/glmerStructure.js +168 -0
  180. package/dist/models/glmerSummary.d.ts +102 -0
  181. package/dist/models/glmerSummary.js +94 -0
  182. package/dist/models/lm.js +13 -3
  183. package/dist/models/lmer.d.ts +27 -6
  184. package/dist/models/lmer.js +75 -321
  185. package/dist/models/lmerAnova.d.ts +52 -3
  186. package/dist/models/lmerAnova.js +101 -45
  187. package/dist/models/lmerTest.d.ts +12 -5
  188. package/dist/models/lmerTest.js +39 -18
  189. package/dist/models/mauchly.d.ts +2 -0
  190. package/dist/models/mauchly.js +7 -2
  191. package/dist/models/mixedDeviance.d.ts +28 -2
  192. package/dist/models/mixedDeviance.js +84 -56
  193. package/dist/models/mixedMinimiser.d.ts +83 -0
  194. package/dist/models/mixedMinimiser.js +438 -0
  195. package/dist/models/mixedPredict.d.ts +121 -0
  196. package/dist/models/mixedPredict.js +530 -0
  197. package/dist/models/mixedStructure.d.ts +62 -3
  198. package/dist/models/mixedStructure.js +74 -29
  199. package/dist/models/modelFrame.js +2 -2
  200. package/dist/models/modelMatrix.d.ts +8 -1
  201. package/dist/models/modelMatrix.js +56 -39
  202. package/dist/models/survival.d.ts +6 -0
  203. package/dist/models/survival.js +9 -2
  204. package/dist/numerics/deriv.js +8 -0
  205. package/dist/numerics/integrate.js +8 -0
  206. package/dist/numerics/interp.d.ts +32 -7
  207. package/dist/numerics/interp.js +27 -9
  208. package/dist/numerics/ode.js +4 -0
  209. package/dist/numerics.js +2 -2
  210. package/dist/optim/optim.js +17 -2
  211. package/dist/random/beta.js +5 -0
  212. package/dist/random/continuous.js +17 -0
  213. package/dist/random/extra.js +13 -0
  214. package/dist/random/gamma.js +11 -0
  215. package/dist/random/poisson.js +5 -0
  216. package/dist/random/rng.js +4 -0
  217. package/dist/random/sample.js +6 -0
  218. package/dist/rstats.js +17 -14
  219. package/dist/special/besselIK.js +7 -0
  220. package/dist/special/choose.js +7 -0
  221. package/dist/special/psigamma.js +7 -0
  222. package/dist/special.js +2 -2
  223. package/dist/tests.js +14 -11
  224. package/llms.txt +15 -4
  225. package/package.json +19 -10
  226. package/dist/chunks/chunk-2D2IQWUQ.js +0 -2
  227. package/dist/chunks/chunk-6CSTWA5E.js +0 -2
  228. package/dist/chunks/chunk-72Y3HZID.js +0 -2
  229. package/dist/chunks/chunk-BG2KLEHM.js +0 -2
  230. package/dist/chunks/chunk-CMEKBNHQ.js +0 -2
  231. package/dist/chunks/chunk-FLJNSXSW.js +0 -2
  232. package/dist/chunks/chunk-GM53LWSR.js +0 -2
  233. package/dist/chunks/chunk-JBCA56ZS.js +0 -3
  234. package/dist/chunks/chunk-K3RJAD2T.js +0 -2
  235. package/dist/chunks/chunk-KAZRWIB5.js +0 -2
  236. package/dist/chunks/chunk-KBVVIMXX.js +0 -3
  237. package/dist/chunks/chunk-N3SIFCZX.js +0 -2
  238. package/dist/chunks/chunk-SC6CV4Z3.js +0 -2
  239. package/dist/chunks/chunk-SYWOBOTR.js +0 -2
  240. package/dist/chunks/chunk-VTUGG2SV.js +0 -2
  241. package/dist/chunks/chunk-XHETEYVC.js +0 -2
  242. package/dist/chunks/chunk-YRZWONZB.js +0 -3
  243. package/dist/chunks/chunk-ZGABZMWX.js +0 -2
@@ -173,31 +173,6 @@ export declare function gamesHowellTest(x: Sample, g: readonly GroupLabel[]): PM
173
173
  * @category Multiple comparisons
174
174
  */
175
175
  export declare function tukeyTest(x: Sample, g: readonly GroupLabel[]): PMCMRResult;
176
- /**
177
- * Steel's many-to-one rank test. Equivalent to `PMCMRplus::steelTest()` in R. It behaves as `steelTest()` of
178
- * PMCMRplus 1.9.12 does: that fails on every input, so this reproduces its errors. A two-sided
179
- * alternative is rejected (`'arg' should be one of “greater”, “less”`), unequal group sizes give `Steel's test is
180
- * only valid for balanced designs.`, and balanced data the error PMCMRplus raises internally.
181
- *
182
- * @throws Always.
183
- *
184
- * @example
185
- * ```ts
186
- * const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
187
- * const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
188
- * const message = (() => {
189
- * try {
190
- * steelTest(x, g, { alternative: "greater" });
191
- * } catch (e) {
192
- * return (e as Error).message;
193
- * }
194
- * })();
195
- * message; // "'data' must be of a vector type, was 'NULL'"
196
- * ```
197
- *
198
- * @category Multiple comparisons
199
- */
200
- export declare function steelTest(x: Sample, g: readonly GroupLabel[], options?: ManyOneTestOptions): never;
201
176
  /**
202
177
  * Adjustment method of {@link dunnTest} (dunn.test's `method`).
203
178
  *
@@ -229,8 +204,16 @@ export interface DunnTestResult {
229
204
  P: number[];
230
205
  /** Adjusted p-values (no monotonicity step). */
231
206
  PAdjusted: number[];
207
+ /** Alias of `Z`: the same array. */
208
+ zValue: number[];
209
+ /** Alias of `P`: the same array. */
210
+ pValue: number[];
211
+ /** Alias of `PAdjusted`: the same array. */
212
+ pAdjusted: number[];
232
213
  /** Labels of the comparisons, `"<label j> - <label i>"`, in the order (2,1), (3,1), (3,2), (4,1), ... */
233
214
  comparisons: string[];
215
+ /** R's warnings, each once, in R's order (an empty array when there are none). */
216
+ warnings: string[];
234
217
  }
235
218
  /**
236
219
  * Dunn's test of all pairs of mean ranks. Equivalent to `dunn.test::dunn.test(x, g, method, altp)` in R. The step-wise
@@ -275,8 +258,16 @@ export interface GlhtDunnettResult {
275
258
  t: number[];
276
259
  /** Simultaneous (single-step) p-values. */
277
260
  p: number[];
261
+ /** Alias of `se`: the same array. */
262
+ stdError: number[];
263
+ /** Alias of `t`: the same array. */
264
+ tValue: number[];
265
+ /** Alias of `p`: the same array. */
266
+ pValue: number[];
278
267
  /** Residual degrees of freedom, N - k. */
279
268
  df: number;
269
+ /** R's warnings, each once, in R's order (an empty array when there are none). */
270
+ warnings: string[];
280
271
  }
281
272
  /**
282
273
  * Dunnett's many-to-one comparisons of a one-way ANOVA with simultaneous p-values. Equivalent to
@@ -1,5 +1,5 @@
1
1
  // Multiple comparisons after a one-way layout: PMCMRplus's dscfAllPairsTest, kwAllPairsDunnTest, kwManyOneDunnTest,
2
- // dunnettTest, gamesHowellTest, tukeyTest, steelTest and manyOneUTest, dunn.test's dunn.test and multcomp's Dunnett contrasts
2
+ // dunnettTest, gamesHowellTest, tukeyTest and manyOneUTest, dunn.test's dunn.test and multcomp's Dunnett contrasts
3
3
  // (summary(glht(aov(y ~ g), mcp(g = "Dunnett")))).
4
4
  //
5
5
  // Written for rStats.js from the published statistics and the behaviour described in oracle/mcomp-behaviour.md (no
@@ -22,6 +22,15 @@ import { labelledGroups } from "./groups.js";
22
22
  import { pAdjust } from "./pAdjust.js";
23
23
  import { kruskalTest } from "./rankTests.js";
24
24
  import { matchAlternative } from "./types.js";
25
+ import { reported } from "../internal/warnings.js";
26
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
27
+ import { checkOptions } from "../internal/checkOptions.js";
28
+ const KW_ALL_PAIRS_DUNN_TEST_KEYS = ["pAdjustMethod"];
29
+ const KW_MANY_ONE_DUNN_TEST_KEYS = ["pAdjustMethod", "alternative"];
30
+ const DUNNETT_TEST_KEYS = ["alternative"];
31
+ const MANY_ONE_UTEST_KEYS = ["pAdjustMethod", "alternative"];
32
+ const DUNN_TEST_KEYS = ["method", "altp"];
33
+ const GLHT_DUNNETT_KEYS = ["alternative"];
25
34
  const TIES_WARNING = "Ties are present. z-quantiles were corrected for ties.";
26
35
  function layout(x, g) {
27
36
  const { labels, groups } = labelledGroups(x, g);
@@ -136,13 +145,14 @@ export function checkPooledVariance(df, ssWithin) {
136
145
  * @category Multiple comparisons
137
146
  */
138
147
  export function kwAllPairsDunnTest(x, g, options = {}) {
148
+ checkOptions(options, KW_ALL_PAIRS_DUNN_TEST_KEYS, "kwAllPairsDunnTest"); // generated: option-keys.mjs
139
149
  const adjust = options.pAdjustMethod ?? "holm";
140
150
  const d = layout(x, g);
141
151
  const { R, C } = meanRanks(d);
142
152
  const v = (d.N * (d.N + 1)) / 12 - C;
143
153
  const z = lowerTable(d.k, (i, j) => Math.abs(R[i] - R[j]) / Math.sqrt(v * (1 / d.n[i] + 1 / d.n[j])));
144
154
  const p = adjustLower(z.map((row) => row.map((s) => 2 * upperNormal(s))), adjust);
145
- return allPairs(d, "Dunn's all-pairs test", z, p, adjust, C !== 0 ? [TIES_WARNING] : []);
155
+ return reported("kwAllPairsDunnTest", allPairs(d, "Dunn's all-pairs test", z, p, adjust, C !== 0 ? [TIES_WARNING] : []));
146
156
  }
147
157
  /**
148
158
  * Dunn's many-to-one test of mean ranks against the control (the first group). Equivalent to
@@ -159,6 +169,7 @@ export function kwAllPairsDunnTest(x, g, options = {}) {
159
169
  * @category Multiple comparisons
160
170
  */
161
171
  export function kwManyOneDunnTest(x, g, options = {}) {
172
+ checkOptions(options, KW_MANY_ONE_DUNN_TEST_KEYS, "kwManyOneDunnTest"); // generated: option-keys.mjs
162
173
  const alternative = matchAlternative(options.alternative);
163
174
  const adjust = options.pAdjustMethod ?? "single-step";
164
175
  const d = layout(x, g);
@@ -168,7 +179,7 @@ export function kwManyOneDunnTest(x, g, options = {}) {
168
179
  const z = idx.map((j) => (R[j] - R[0]) / Math.sqrt(v * (1 / d.n[0] + 1 / d.n[j])));
169
180
  const lambda = idx.map((j) => d.n[j] / (d.n[j] + d.n[0]));
170
181
  const p = manyOneNormalP(z, lambda, alternative, adjust);
171
- return manyOne(d, "Dunn's many-to-one test", z, p, adjust, C !== 0 ? [TIES_WARNING] : []);
182
+ return reported("kwManyOneDunnTest", manyOne(d, "Dunn's many-to-one test", z, p, adjust, C !== 0 ? [TIES_WARNING] : []));
172
183
  }
173
184
  /**
174
185
  * Many-to-one p-values of normal statistics z (one per group against the control): `"single-step"`, the exact
@@ -198,6 +209,7 @@ function manyOneNormalP(z, lambda, alternative, adjust) {
198
209
  * @category Multiple comparisons
199
210
  */
200
211
  export function dunnettTest(x, g, options = {}) {
212
+ checkOptions(options, DUNNETT_TEST_KEYS, "dunnettTest"); // generated: option-keys.mjs
201
213
  const alternative = matchAlternative(options.alternative);
202
214
  const d = layout(x, g);
203
215
  const { m, s2, df } = pooled(d);
@@ -208,7 +220,7 @@ export function dunnettTest(x, g, options = {}) {
208
220
  const p = t.map((v) => alternative === "two.sided"
209
221
  ? Math.min(1, 2 * pDunnettUpper(Math.abs(v), lambda, df, false))
210
222
  : pDunnettUpper(alternative === "greater" ? v : -v, lambda, df, false));
211
- return manyOne(d, "Dunnett's-test for multiple\t\n comparisons with one control", t, p, "single-step");
223
+ return reported("dunnettTest", manyOne(d, "Dunnett's-test for multiple\t\n comparisons with one control", t, p, "single-step"));
212
224
  }
213
225
  /**
214
226
  * Steel's many-to-one rank test in its normal approximation: the Mann-Whitney statistic of each group against the
@@ -230,6 +242,7 @@ export function dunnettTest(x, g, options = {}) {
230
242
  * @category Multiple comparisons
231
243
  */
232
244
  export function manyOneUTest(x, g, options = {}) {
245
+ checkOptions(options, MANY_ONE_UTEST_KEYS, "manyOneUTest"); // generated: option-keys.mjs
233
246
  const alternative = matchAlternative(options.alternative);
234
247
  const adjust = options.pAdjustMethod ?? "single-step";
235
248
  const d = layout(x, g);
@@ -258,7 +271,7 @@ export function manyOneUTest(x, g, options = {}) {
258
271
  });
259
272
  const lambda = idx.map((j) => d.n[j] / (d.n[j] + n1));
260
273
  const p = manyOneNormalP(z, lambda, alternative, adjust);
261
- return manyOne(d, "Wilcoxon, Mann, Whittney U-test\n\tfor multiple comparisons with one control", z, p, adjust);
274
+ return reported("manyOneUTest", manyOne(d, "Wilcoxon, Mann, Whittney U-test\n\tfor multiple comparisons with one control", z, p, adjust));
262
275
  }
263
276
  /**
264
277
  * Dwass-Steel-Critchlow-Fligner all-pairs test of pairwise Mann-Whitney statistics. Equivalent to
@@ -294,7 +307,7 @@ export function dscfAllPairsTest(x, g) {
294
307
  return (Math.SQRT2 * (u - (ni * nj) / 2)) / Math.sqrt(v);
295
308
  });
296
309
  const p = stat.map((row) => row.map((q) => (Number.isNaN(q) ? NaN : upperRange(q, d.k, Infinity))));
297
- return allPairs(d, "Dwass-Steele-Critchlow-Fligner all-pairs test", stat, p, "single-step");
310
+ return reported("dscfAllPairsTest", allPairs(d, "Dwass-Steele-Critchlow-Fligner all-pairs test", stat, p, "single-step"));
298
311
  }
299
312
  /**
300
313
  * Games-Howell all-pairs test of means with Welch's standard errors and degrees of freedom. Equivalent to
@@ -320,7 +333,7 @@ export function gamesHowellTest(x, g) {
320
333
  const df = satterthwaiteDfPM([gm.variance[i], gm.variance[j]], [d.n[i], d.n[j]]);
321
334
  return upperRange(q[i - 1][j], d.k, df);
322
335
  });
323
- return allPairs(d, "Games-Howell test", q, p, "none");
336
+ return reported("gamesHowellTest", allPairs(d, "Games-Howell test", q, p, "none"));
324
337
  }
325
338
  /**
326
339
  * Tukey's all-pairs test of means (Tukey-Kramer for unequal sizes). Equivalent to `PMCMRplus::tukeyTest()` in R.
@@ -342,40 +355,7 @@ export function tukeyTest(x, g) {
342
355
  throw new RangeError("the studentized range needs at least 2 residual degrees of freedom");
343
356
  const q = lowerTable(d.k, (i, j) => (m[i] - m[j]) / Math.sqrt((s2 * (1 / d.n[i] + 1 / d.n[j])) / 2));
344
357
  const p = q.map((row) => row.map((v) => (Number.isNaN(v) ? NaN : upperRange(v, d.k, df))));
345
- return allPairs(d, "Tukey's test", q, p, "single-step");
346
- }
347
- /**
348
- * Steel's many-to-one rank test. Equivalent to `PMCMRplus::steelTest()` in R. It behaves as `steelTest()` of
349
- * PMCMRplus 1.9.12 does: that fails on every input, so this reproduces its errors. A two-sided
350
- * alternative is rejected (`'arg' should be one of “greater”, “less”`), unequal group sizes give `Steel's test is
351
- * only valid for balanced designs.`, and balanced data the error PMCMRplus raises internally.
352
- *
353
- * @throws Always.
354
- *
355
- * @example
356
- * ```ts
357
- * const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
358
- * const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
359
- * const message = (() => {
360
- * try {
361
- * steelTest(x, g, { alternative: "greater" });
362
- * } catch (e) {
363
- * return (e as Error).message;
364
- * }
365
- * })();
366
- * message; // "'data' must be of a vector type, was 'NULL'"
367
- * ```
368
- *
369
- * @category Multiple comparisons
370
- */
371
- export function steelTest(x, g, options = {}) {
372
- const alternative = options.alternative === undefined ? "greater" : matchAlternative(options.alternative);
373
- if (alternative === "two.sided")
374
- throw new RangeError("'arg' should be one of “greater”, “less”");
375
- const d = layout(x, g);
376
- if (d.n.some((v) => v !== d.n[0]))
377
- throw new RangeError("Steel's test is only valid for balanced designs.");
378
- throw new Error("'data' must be of a vector type, was 'NULL'");
358
+ return reported("tukeyTest", allPairs(d, "Tukey's test", q, p, "single-step"));
379
359
  }
380
360
  /**
381
361
  * Dunn's test of all pairs of mean ranks. Equivalent to `dunn.test::dunn.test(x, g, method, altp)` in R. The step-wise
@@ -395,6 +375,7 @@ export function steelTest(x, g, options = {}) {
395
375
  * @category Multiple comparisons
396
376
  */
397
377
  export function dunnTest(x, g, options = {}) {
378
+ checkOptions(options, DUNN_TEST_KEYS, "dunnTest"); // generated: option-keys.mjs
398
379
  const method = options.method ?? "none";
399
380
  const altp = options.altp ?? false;
400
381
  const d = layout(x, g);
@@ -410,7 +391,8 @@ export function dunnTest(x, g, options = {}) {
410
391
  }
411
392
  }
412
393
  const P = Z.map((z) => (altp ? 2 : 1) * upperNormal(Math.abs(z)));
413
- return { chi2, Z, P, PAdjusted: dunnAdjust(P, method), comparisons };
394
+ const PAdjusted = dunnAdjust(P, method);
395
+ return { chi2, Z, P, PAdjusted, zValue: Z, pValue: P, pAdjusted: PAdjusted, comparisons, warnings: [] };
414
396
  }
415
397
  /** dunn.test's adjustments: each value by the factor of its rank (tied values: the same rank), capped at 1 */
416
398
  function dunnAdjust(P, method) {
@@ -478,6 +460,7 @@ function dunnAdjust(P, method) {
478
460
  * @category Multiple comparisons
479
461
  */
480
462
  export function glhtDunnett(x, g, options = {}) {
463
+ checkOptions(options, GLHT_DUNNETT_KEYS, "glhtDunnett"); // generated: option-keys.mjs
481
464
  const alternative = matchAlternative(options.alternative);
482
465
  const d = layout(x, g);
483
466
  const { m, s2, df, k } = pooled(d);
@@ -492,5 +475,5 @@ export function glhtDunnett(x, g, options = {}) {
492
475
  const p = t.map((v) => alternative === "two.sided"
493
476
  ? pDunnettUpper(v, lambda, df, true)
494
477
  : pDunnettUpper(alternative === "greater" ? v : -v, lambda, df, false));
495
- return { names: idx.map((j) => `${d.labels[j]} - ${d.labels[0]}`), estimate, se, t, p, df };
478
+ return { names: idx.map((j) => `${d.labels[j]} - ${d.labels[0]}`), estimate, se, t, p, stdError: se, tValue: t, pValue: p, df, warnings: [] };
496
479
  }
@@ -9,6 +9,10 @@
9
9
  import { pgamma1 } from "../distributions/gamma.js";
10
10
  import { pnorm, qnorm } from "../distributions/normal.js";
11
11
  import { covariance, dropNaN, scaleToUnit, standardize, variance } from "../internal/summary.js";
12
+ import { reported } from "../internal/warnings.js";
13
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
14
+ import { checkOptions } from "../internal/checkOptions.js";
15
+ const PEARSON_TEST_KEYS = ["nClasses", "adjust"];
12
16
  /** The sorted values without NaN */
13
17
  function sorted(x) {
14
18
  return dropNaN(Array.from(x)).sort((a, b) => a - b);
@@ -63,7 +67,7 @@ export function adTest(x) {
63
67
  pValue = Math.exp(1.2937 - 5.709 * aa + 0.0186 * aa ** 2);
64
68
  else
65
69
  pValue = 3.7e-24;
66
- return { method: "Anderson-Darling normality test", statistic: a, statisticName: "A", pValue };
70
+ return { method: "Anderson-Darling normality test", statistic: a, statisticName: "A", pValue, warnings: [] };
67
71
  }
68
72
  /**
69
73
  * Cramer-von Mises test for normality. Equivalent to `nortest::cvm.test()` in R. `NaN` values are dropped; at least 8
@@ -102,7 +106,7 @@ export function cvmTest(x) {
102
106
  pValue = 7.37e-10;
103
107
  warnings.push("p-value is smaller than 7.37e-10, cannot be computed more accurately");
104
108
  }
105
- return { method: "Cramer-von Mises normality test", statistic: w, statisticName: "W", pValue, warnings };
109
+ return reported("cvmTest", { method: "Cramer-von Mises normality test", statistic: w, statisticName: "W", pValue, warnings });
106
110
  }
107
111
  /**
108
112
  * Lilliefors (Kolmogorov-Smirnov) test for normality. Equivalent to `nortest::lillie.test()` in R. `NaN` values are
@@ -145,7 +149,7 @@ export function lillieTest(x) {
145
149
  else
146
150
  pValue = 0;
147
151
  }
148
- return { method: "Lilliefors (Kolmogorov-Smirnov) normality test", statistic: d, statisticName: "D", pValue };
152
+ return { method: "Lilliefors (Kolmogorov-Smirnov) normality test", statistic: d, statisticName: "D", pValue, warnings: [] };
149
153
  }
150
154
  /**
151
155
  * Shapiro-Francia test for normality. Equivalent to `nortest::sf.test()` in R. `NaN` values are dropped; the sample
@@ -178,7 +182,7 @@ export function sfTest(x) {
178
182
  const mu = -1.2725 + 1.0521 * (v - u);
179
183
  const sig = 1.0308 - 0.26758 * (v + 2 / u);
180
184
  const pValue = pnorm((Math.log(1 - w) - mu) / sig, { lowerTail: false });
181
- return { method: "Shapiro-Francia normality test", statistic: w, statisticName: "W", pValue };
185
+ return { method: "Shapiro-Francia normality test", statistic: w, statisticName: "W", pValue, warnings: [] };
182
186
  }
183
187
  /**
184
188
  * Pearson chi-square test for normality, with classes of equal probability under the fitted normal distribution.
@@ -193,6 +197,7 @@ export function sfTest(x) {
193
197
  * @category Hypothesis tests
194
198
  */
195
199
  export function pearsonTest(x, options = {}) {
200
+ checkOptions(options, PEARSON_TEST_KEYS, "pearsonTest"); // generated: option-keys.mjs
196
201
  const xs = sorted(x);
197
202
  const n = xs.length;
198
203
  const k = options.nClasses ?? Math.ceil(2 * n ** (2 / 5));
@@ -228,5 +233,6 @@ export function pearsonTest(x, options = {}) {
228
233
  statistic,
229
234
  statisticName: "P",
230
235
  pValue: pgamma1(statistic, df / 2, 2, false, false),
236
+ warnings: [],
231
237
  };
232
238
  }
@@ -11,8 +11,16 @@ import { swilkOneMinusW, swilkPValueFromOneMinusW } from "./core/shapiro.js";
11
11
  import { toGroups } from "./groups.js";
12
12
  import { checkPooledVariance } from "./multipleComparisons.js";
13
13
  import { onewayData } from "./testFormula.js";
14
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
15
+ import { checkOptions } from "../internal/checkOptions.js";
16
+ import { isOptionsObject } from "../internal/optionalArgs.js";
17
+ const ONEWAY_TEST_KEYS = ["varEqual"];
18
+ // Generated by `node scripts/option-keys.mjs --write` (end)
14
19
  const MIN_NORMAL = 2 ** -1022;
15
20
  export function onewayTest(x, g, options = {}) {
21
+ if (typeof x !== "string" && isOptionsObject(g))
22
+ checkOptions(g, ONEWAY_TEST_KEYS, "onewayTest"); // generated: option-keys.mjs
23
+ checkOptions(options, ONEWAY_TEST_KEYS, "onewayTest"); // generated: option-keys.mjs
16
24
  if (typeof x === "string") {
17
25
  const d = onewayData(x, g);
18
26
  return onewayTest(d.values, d.groups, options);
@@ -130,6 +138,7 @@ export function onewayTest(x, g, options = {}) {
130
138
  parameter: [k - 1, df2],
131
139
  parameterName: ["num df", "denom df"],
132
140
  pValue: pf1(statistic, k - 1, df2, false, false),
141
+ warnings: [],
133
142
  };
134
143
  }
135
144
  /**
@@ -163,6 +172,7 @@ export function shapiroTest(x) {
163
172
  statistic: 1 - w1,
164
173
  statisticName: "W",
165
174
  pValue: swilkPValueFromOneMinusW(w1, n),
175
+ warnings: [],
166
176
  };
167
177
  }
168
178
  /**
@@ -13,6 +13,9 @@
13
13
  // Differences from R: with Hommel, a non-integer n is an error (R silently returns something). For a length-0 p
14
14
  // with Hommel and n > 0, R returns a length-1 value; here a length-0 result is returned
15
15
  import { wideSum, wideSumAdd, wideSumValue } from "../internal/summary.js";
16
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
17
+ import { checkOptions } from "../internal/checkOptions.js";
18
+ const P_ADJUST_KEYS = ["method", "n"];
16
19
  const METHODS = ["holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"];
17
20
  function matchMethod(m) {
18
21
  if (METHODS.includes(m))
@@ -45,6 +48,7 @@ function matchMethod(m) {
45
48
  * @category Multiple comparisons
46
49
  */
47
50
  export function pAdjust(p, options = {}) {
51
+ checkOptions(options, P_ADJUST_KEYS, "pAdjust"); // generated: option-keys.mjs
48
52
  const opts = typeof options === "string" ? { method: options } : options;
49
53
  const method = matchMethod(opts.method ?? "holm");
50
54
  const all = Array.from(p);
@@ -21,6 +21,8 @@ export interface PairwiseResult {
21
21
  colNames: string[];
22
22
  /** Adjustment method. */
23
23
  pAdjustMethod: PAdjustMethod | string;
24
+ /** R's warnings, each once, in R's order (an empty array when there are none). */
25
+ warnings: string[];
24
26
  }
25
27
  /**
26
28
  * Common options of the pairwise comparisons.
@@ -15,6 +15,14 @@ import { propTest } from "./propTest.js";
15
15
  import { tTest } from "./tTest.js";
16
16
  import { matchAlternative } from "./types.js";
17
17
  import { wilcoxTest } from "./wilcoxTest.js";
18
+ import { reported, unreported, Warnings } from "../internal/warnings.js";
19
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
20
+ import { checkOptions } from "../internal/checkOptions.js";
21
+ const PAIRWISE_TTEST_KEYS = ["poolSd", "paired", "pAdjustMethod", "alternative"];
22
+ const PAIRWISE_WILCOX_TEST_KEYS = [
23
+ "mu", "paired", "exact", "correct", "confLevel", "tolRoot", "pAdjustMethod", "alternative",
24
+ ];
25
+ const PAIRWISE_PROP_TEST_KEYS = ["pAdjustMethod", "correct"];
18
26
  /** Group a sample by labels: levels sorted (numbers numerically, strings by code point), values in input order */
19
27
  function byLevel(x, g, dropNaN) {
20
28
  const xs = Array.from(x);
@@ -52,13 +60,14 @@ function table(k, compare, method) {
52
60
  pos.forEach(([r, c], idx) => (out[r][c] = adj[idx]));
53
61
  return out;
54
62
  }
55
- function result(method, levels, pValue, adjust) {
63
+ function result(method, levels, pValue, adjust, warnings = []) {
56
64
  return {
57
65
  method,
58
66
  pValue,
59
67
  rowNames: levels.slice(1).map(levelText),
60
68
  colNames: levels.slice(0, -1).map(levelText),
61
69
  pAdjustMethod: adjust,
70
+ warnings,
62
71
  };
63
72
  }
64
73
  /**
@@ -77,6 +86,7 @@ function result(method, levels, pValue, adjust) {
77
86
  * @category Multiple comparisons
78
87
  */
79
88
  export function pairwiseTTest(x, g, options = {}) {
89
+ checkOptions(options, PAIRWISE_TTEST_KEYS, "pairwiseTTest"); // generated: option-keys.mjs
80
90
  const paired = options.paired ?? false;
81
91
  const poolSd = options.poolSd ?? !paired;
82
92
  if (paired && poolSd)
@@ -113,7 +123,7 @@ export function pairwiseTTest(x, g, options = {}) {
113
123
  }
114
124
  else {
115
125
  method = paired ? "paired t tests" : "t tests with non-pooled SD";
116
- compare = (i, j) => tTest(groups[i], groups[j], { paired, alternative }).pValue;
126
+ compare = (i, j) => unreported(() => tTest(groups[i], groups[j], { paired, alternative })).pValue;
117
127
  }
118
128
  return result(method, levels, table(k, compare, adjust), adjust);
119
129
  }
@@ -131,6 +141,7 @@ export function pairwiseTTest(x, g, options = {}) {
131
141
  * @category Multiple comparisons
132
142
  */
133
143
  export function pairwiseWilcoxTest(x, g, options = {}) {
144
+ checkOptions(options, PAIRWISE_WILCOX_TEST_KEYS, "pairwiseWilcoxTest"); // generated: option-keys.mjs
134
145
  const { pAdjustMethod, alternative, ...rest } = options;
135
146
  const adjust = pAdjustMethod ?? "holm";
136
147
  const { levels, groups } = byLevel(x, g, !(rest.paired ?? false));
@@ -138,12 +149,16 @@ export function pairwiseWilcoxTest(x, g, options = {}) {
138
149
  if (k < 2)
139
150
  throw new RangeError("there must be at least two groups");
140
151
  let method = "";
152
+ // the comparisons' warnings, each once, in the order of the comparisons (R repeats them for each)
153
+ const warnings = new Warnings();
141
154
  const pv = table(k, (i, j) => {
142
- const r = wilcoxTest(groups[i], groups[j], { ...rest, ...(alternative === undefined ? {} : { alternative }) });
155
+ const r = unreported(() => wilcoxTest(groups[i], groups[j], { ...rest, ...(alternative === undefined ? {} : { alternative }) }));
143
156
  method = r.method;
157
+ for (const w of r.warnings)
158
+ warnings.add(w);
144
159
  return r.pValue;
145
160
  }, adjust);
146
- return result(method, levels, pv, adjust);
161
+ return reported("pairwiseWilcoxTest", result(method, levels, pv, adjust, warnings.list));
147
162
  }
148
163
  /**
149
164
  * Pairwise two-group tests of equal proportions, with adjusted p-values. Equivalent to R's `pairwise.prop.test()`.
@@ -160,6 +175,7 @@ export function pairwiseWilcoxTest(x, g, options = {}) {
160
175
  * @category Multiple comparisons
161
176
  */
162
177
  export function pairwisePropTest(x, n, options = {}) {
178
+ checkOptions(options, PAIRWISE_PROP_TEST_KEYS, "pairwisePropTest"); // generated: option-keys.mjs
163
179
  if (x.length !== n.length)
164
180
  throw new RangeError("'x' and 'n' must have the same length");
165
181
  // as in R, groups with a missing count are dropped and the rest numbered 1, 2, ... in their order
@@ -176,7 +192,14 @@ export function pairwisePropTest(x, n, options = {}) {
176
192
  throw new RangeError("too few groups");
177
193
  const adjust = options.pAdjustMethod ?? "holm";
178
194
  const correct = options.correct ?? true;
179
- const pv = table(k, (i, j) => propTest([xs[i], xs[j]], [ns[i], ns[j]], { correct }).pValue, adjust);
195
+ // the comparisons' warnings ("Chi-squared approximation may be incorrect"), each once (R repeats them for each)
196
+ const warnings = new Warnings();
197
+ const pv = table(k, (i, j) => {
198
+ const r = unreported(() => propTest([xs[i], xs[j]], [ns[i], ns[j]], { correct }));
199
+ for (const w of r.warnings)
200
+ warnings.add(w);
201
+ return r.pValue;
202
+ }, adjust);
180
203
  const levels = Array.from({ length: k }, (_, i) => i + 1);
181
- return result("Pairwise comparison of proportions", levels, pv, adjust);
204
+ return reported("pairwisePropTest", result("Pairwise comparison of proportions", levels, pv, adjust, warnings.list));
182
205
  }
@@ -12,6 +12,9 @@ import { firstTrue, lastTrue } from "../internal/discrete.js";
12
12
  import { ldexp } from "../internal/summary.js";
13
13
  import { binomTestCounts } from "./binomTest.js";
14
14
  import { checkConfLevel, checkConfLevelOpen, isCount, matchAlternative } from "./types.js";
15
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
16
+ import { checkOptions } from "../internal/checkOptions.js";
17
+ const POISSON_TEST_KEYS = ["T", "r", "alternative", "confLevel"];
15
18
  const REL_ERR = 1 + 1e-7;
16
19
  /**
17
20
  * Two-sided p-value of the count x under Poisson(m): the total probability of the counts whose probability is at most
@@ -111,6 +114,7 @@ function rateRatio(x1, x2, T1, T2) {
111
114
  * @category Hypothesis tests
112
115
  */
113
116
  export function poissonTest(x, options = {}) {
117
+ checkOptions(options, POISSON_TEST_KEYS, "poissonTest"); // generated: option-keys.mjs
114
118
  const xs = typeof x === "number" ? [x] : Array.from(x);
115
119
  if (xs.length < 1 || xs.length > 2)
116
120
  throw new RangeError("incorrect length of 'x'");
@@ -182,6 +186,7 @@ export function poissonTest(x, options = {}) {
182
186
  estimateNames: "rate ratio",
183
187
  nullValue: r,
184
188
  nullValueName: "rate ratio",
189
+ warnings: [],
185
190
  };
186
191
  }
187
192
  const xv = counts[0];
@@ -220,5 +225,6 @@ export function poissonTest(x, options = {}) {
220
225
  estimateNames: "event rate",
221
226
  nullValue: r,
222
227
  nullValueName: "event rate",
228
+ warnings: [],
223
229
  };
224
230
  }
@@ -22,6 +22,12 @@ import { optimize } from "../numerics/integrate.js";
22
22
  import { solve } from "../linalg/solve.js";
23
23
  import { formatR } from "./core/simulate.js";
24
24
  import { maxOf } from "../internal/extremes.js";
25
+ import { reported } from "../internal/warnings.js";
26
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
27
+ import { checkOptions } from "../internal/checkOptions.js";
28
+ import { isOptionsObject } from "../internal/optionalArgs.js";
29
+ const POLYCHOR_KEYS = ["ML", "stdErr"];
30
+ const POLYSERIAL_KEYS = ["ML", "stdErr"];
25
31
  const BOUND = 0.9999;
26
32
  /** Normal quantiles of the cumulative proportions of the counts, without the last (which would be +Inf) */
27
33
  function thresholds(counts) {
@@ -296,6 +302,9 @@ function inverseNegHessian(hessian, bounded) {
296
302
  }
297
303
  const inadmissibleWarning = (rho) => `inadmissible correlation set to ${rho > 0 ? "0.9999" : "-0.9999"}`;
298
304
  export function polychor(x, yOrOptions, maybeOptions) {
305
+ if (isOptionsObject(yOrOptions))
306
+ checkOptions(yOrOptions, POLYCHOR_KEYS, "polychor"); // generated: option-keys.mjs
307
+ checkOptions(maybeOptions, POLYCHOR_KEYS, "polychor"); // generated: option-keys.mjs
299
308
  let tab;
300
309
  let options;
301
310
  if (!isVector(yOrOptions)) {
@@ -352,7 +361,7 @@ export function polychor(x, yOrOptions, maybeOptions) {
352
361
  if (c < 2)
353
362
  warnings.push("the table has fewer than 2 columns");
354
363
  if (r < 2 || c < 2)
355
- return { rho: NaN, warnings };
364
+ return reported("polychor", { rho: NaN, warnings });
356
365
  const rowCuts = [-Infinity, ...thresholds(tab.map((row) => sum(row))), Infinity];
357
366
  const colCuts = [-Infinity, ...thresholds(tab[0].map((_, j) => sum(tab.map((row) => row[j])))), Infinity];
358
367
  const negLogLik = (rho0) => {
@@ -371,7 +380,7 @@ export function polychor(x, yOrOptions, maybeOptions) {
371
380
  };
372
381
  const twoStep = optimize(negLogLik, -BOUND, BOUND).optimum;
373
382
  if (!ML && !stdErr)
374
- return { rho: twoStep, warnings };
383
+ return reported("polychor", { rho: twoStep, warnings });
375
384
  // maximum likelihood: θ = (ρ, the inner row thresholds, the inner column thresholds) with ML, ρ alone otherwise
376
385
  const extend = (cuts) => [-Infinity, ...cuts, Infinity];
377
386
  const innerRow = rowCuts.slice(1, r);
@@ -384,7 +393,7 @@ export function polychor(x, yOrOptions, maybeOptions) {
384
393
  if (bounded)
385
394
  warnings.push(inadmissibleWarning(rho));
386
395
  if (!stdErr)
387
- return { rho, warnings };
396
+ return reported("polychor", { rho, warnings });
388
397
  const fittedRow = ML ? extend(theta.slice(1, r)) : rowCuts;
389
398
  const fittedCol = ML ? extend(theta.slice(r)) : colCuts;
390
399
  const n = sum(tab.map((row) => sum(row)));
@@ -408,7 +417,7 @@ export function polychor(x, yOrOptions, maybeOptions) {
408
417
  }
409
418
  }
410
419
  const variances = inverseNegHessian(at.hessian, bounded);
411
- return {
420
+ return reported("polychor", {
412
421
  rho,
413
422
  warnings,
414
423
  var: k === 0 ? variances : variances.map((row) => row.map((v) => ldexp(v, -k))),
@@ -417,7 +426,7 @@ export function polychor(x, yOrOptions, maybeOptions) {
417
426
  n: ldexp(n, k),
418
427
  rowCuts: fittedRow.slice(1, r),
419
428
  colCuts: fittedCol.slice(1, c),
420
- };
429
+ });
421
430
  }
422
431
  /** polycor's chi-square for the polyserial model: the standardised codes and z binned, against the bivariate normal */
423
432
  function polyserialChisq(codes, z, cuts, rho) {
@@ -441,6 +450,7 @@ function polyserialChisq(codes, z, cuts, rho) {
441
450
  return 2 * sum(terms);
442
451
  }
443
452
  export function polyserial(x, y, options = {}) {
453
+ checkOptions(options, POLYSERIAL_KEYS, "polyserial"); // generated: option-keys.mjs
444
454
  if (x.length !== y.length)
445
455
  throw new RangeError("'x' and 'y' must have the same length");
446
456
  const { ML = false, stdErr = false } = options;
@@ -450,7 +460,7 @@ export function polyserial(x, y, options = {}) {
450
460
  const n = xv.length;
451
461
  const levels = sortedDistinct(yv);
452
462
  if (levels.length < 2)
453
- return { rho: NaN, warnings: ["y has fewer than 2 levels"] };
463
+ return reported("polyserial", { rho: NaN, warnings: ["y has fewer than 2 levels"] });
454
464
  const code = new Map(levels.map((v, i) => [v, i + 1]));
455
465
  const yc = yv.map((v) => code.get(v));
456
466
  const counts = levels.map(() => 0);
@@ -465,7 +475,7 @@ export function polyserial(x, y, options = {}) {
465
475
  rho = bounded;
466
476
  }
467
477
  if (!ML && !stdErr)
468
- return { rho, warnings };
478
+ return reported("polyserial", { rho, warnings });
469
479
  // maximum likelihood: θ = (ρ, the thresholds) with ML, ρ alone otherwise
470
480
  const z = standardise(xv);
471
481
  const category = yc.map((v) => v - 1);
@@ -474,10 +484,10 @@ export function polyserial(x, y, options = {}) {
474
484
  if (bounded)
475
485
  warnings.push(inadmissibleWarning(theta[0]));
476
486
  if (!stdErr)
477
- return { rho: theta[0], warnings };
487
+ return reported("polyserial", { rho: theta[0], warnings });
478
488
  const fittedCuts = ML ? theta.slice(1) : cuts;
479
489
  const s = levels.length;
480
- return {
490
+ return reported("polyserial", {
481
491
  rho: theta[0],
482
492
  warnings,
483
493
  var: inverseNegHessian(at.hessian, bounded),
@@ -486,5 +496,5 @@ export function polyserial(x, y, options = {}) {
486
496
  df: 4 * s - s - 1,
487
497
  n,
488
498
  cuts: fittedCuts,
489
- };
499
+ });
490
500
  }
@@ -55,6 +55,8 @@ export interface PowerTTestResult {
55
55
  note?: string;
56
56
  /** Description of the calculation. */
57
57
  method: string;
58
+ /** R's warnings, each once, in R's order (an empty array when there are none). */
59
+ warnings: string[];
58
60
  }
59
61
  /**
60
62
  * Power of a one- or two-sample t test, or the sample size, difference, standard deviation or significance level
@@ -170,6 +172,8 @@ export interface PowerAnovaTestResult {
170
172
  note: string;
171
173
  /** Description of the calculation. */
172
174
  method: string;
175
+ /** R's warnings, each once, in R's order (an empty array when there are none). */
176
+ warnings: string[];
173
177
  }
174
178
  /** Whether an F test's power is taken from the normal approximation (df1 finite, both above 1e16) */
175
179
  export declare const hugeDf: (df1: number, df2: number) => boolean;