@numero-uno-jpn/rstats 0.16.0 → 0.17.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 (216) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/README.ja.md +44 -18
  3. package/README.md +45 -18
  4. package/dist/chunks/chunk-2C33MXSW.js +3 -0
  5. package/dist/chunks/chunk-34S5SQY6.js +2 -0
  6. package/dist/chunks/{chunk-URIO5LY5.js → chunk-4WE3OO62.js} +2 -2
  7. package/dist/chunks/chunk-5AYHCITP.js +2 -0
  8. package/dist/chunks/chunk-6JJQL6HL.js +2 -0
  9. package/dist/chunks/chunk-C7V2FH6L.js +3 -0
  10. package/dist/chunks/chunk-CZI7KUO3.js +2 -0
  11. package/dist/chunks/chunk-DXI5N2ET.js +2 -0
  12. package/dist/chunks/chunk-FY3FVOBM.js +2 -0
  13. package/dist/chunks/{chunk-QNNL7AZ3.js → chunk-H3WVPZDL.js} +2 -2
  14. package/dist/chunks/chunk-LHUIJQHY.js +2 -0
  15. package/dist/chunks/chunk-LV3W2F7N.js +2 -0
  16. package/dist/chunks/chunk-M4ITG7YR.js +2 -0
  17. package/dist/chunks/{chunk-FLJNSXSW.js → chunk-NSYZTS26.js} +2 -2
  18. package/dist/chunks/chunk-ONY5CISH.js +2 -0
  19. package/dist/chunks/chunk-RFE7MVP7.js +2 -0
  20. package/dist/chunks/{chunk-W26LRYOJ.js → chunk-SE7V2KLO.js} +1 -1
  21. package/dist/chunks/chunk-THIGHOKK.js +2 -0
  22. package/dist/chunks/chunk-TNMJPQPV.js +2 -0
  23. package/dist/chunks/chunk-WM7VFXTV.js +2 -0
  24. package/dist/chunks/chunk-WMDYDTVQ.js +2 -0
  25. package/dist/chunks/chunk-XLSFJTTK.js +2 -0
  26. package/dist/chunks/{chunk-5UQCRBAG.js → chunk-Z37NELOS.js} +1 -1
  27. package/dist/chunks/chunk-ZFQWB222.js +2 -0
  28. package/dist/data/grouping.js +6 -2
  29. package/dist/descriptive/basic.js +20 -0
  30. package/dist/descriptive/cov.js +11 -0
  31. package/dist/descriptive/dataFrames.js +13 -5
  32. package/dist/descriptive/factanal.d.ts +2 -0
  33. package/dist/descriptive/factanal.js +10 -2
  34. package/dist/descriptive/hist.js +6 -0
  35. package/dist/descriptive/moments.js +14 -0
  36. package/dist/descriptive/omega.js +8 -3
  37. package/dist/descriptive/pivot.d.ts +4 -1
  38. package/dist/descriptive/pivot.js +27 -13
  39. package/dist/descriptive/quantile.js +8 -0
  40. package/dist/descriptive/rank.js +4 -0
  41. package/dist/descriptive/table.d.ts +20 -1
  42. package/dist/descriptive/table.js +14 -14
  43. package/dist/descriptive.js +2 -2
  44. package/dist/distributions/arcsine.js +8 -0
  45. package/dist/distributions/beta.js +9 -0
  46. package/dist/distributions/binomial.js +9 -0
  47. package/dist/distributions/cauchy.js +9 -0
  48. package/dist/distributions/chisq.js +9 -0
  49. package/dist/distributions/exponential.js +9 -0
  50. package/dist/distributions/f.js +9 -0
  51. package/dist/distributions/gamma.js +8 -0
  52. package/dist/distributions/geometric.js +9 -0
  53. package/dist/distributions/hypergeometric.js +8 -0
  54. package/dist/distributions/invgamma.js +8 -0
  55. package/dist/distributions/kumaraswamy.js +9 -0
  56. package/dist/distributions/laplace.js +9 -0
  57. package/dist/distributions/logistic.js +9 -0
  58. package/dist/distributions/lognormal.js +8 -0
  59. package/dist/distributions/multinomial.js +4 -0
  60. package/dist/distributions/negbinomial.js +8 -0
  61. package/dist/distributions/normal.js +8 -0
  62. package/dist/distributions/pareto.js +8 -0
  63. package/dist/distributions/poisson.js +9 -0
  64. package/dist/distributions/signrank.js +9 -0
  65. package/dist/distributions/summary.d.ts +2 -1
  66. package/dist/distributions/summary.js +31 -1
  67. package/dist/distributions/t.js +9 -0
  68. package/dist/distributions/triangular.js +9 -0
  69. package/dist/distributions/tukey.js +6 -0
  70. package/dist/distributions/uniform.js +8 -0
  71. package/dist/distributions/weibull.js +8 -0
  72. package/dist/distributions/wilcox.js +9 -0
  73. package/dist/distributions.js +2 -2
  74. package/dist/entries/descriptive.d.ts +3 -1
  75. package/dist/entries/descriptive.js +1 -1
  76. package/dist/entries/distributions.d.ts +1 -0
  77. package/dist/entries/distributions.js +2 -0
  78. package/dist/entries/linalg.d.ts +3 -1
  79. package/dist/entries/mixed.d.ts +3 -0
  80. package/dist/entries/mixed.js +2 -0
  81. package/dist/entries/numerics.d.ts +2 -1
  82. package/dist/entries/tests.d.ts +8 -5
  83. package/dist/entries/tests.js +3 -1
  84. package/dist/htest/agreement.d.ts +13 -0
  85. package/dist/htest/agreement.js +46 -7
  86. package/dist/htest/ansariTest.d.ts +2 -1
  87. package/dist/htest/ansariTest.js +43 -12
  88. package/dist/htest/aov.d.ts +28 -22
  89. package/dist/htest/aov.js +42 -13
  90. package/dist/htest/binomTest.js +6 -0
  91. package/dist/htest/brunnerMunzelTest.js +5 -0
  92. package/dist/htest/chisqTest.d.ts +3 -1
  93. package/dist/htest/chisqTest.js +21 -3
  94. package/dist/htest/cor.d.ts +7 -1
  95. package/dist/htest/cor.js +40 -7
  96. package/dist/htest/core/simulate.d.ts +6 -0
  97. package/dist/htest/core/simulate.js +20 -0
  98. package/dist/htest/effectSize.d.ts +3 -0
  99. package/dist/htest/effectSize.js +28 -8
  100. package/dist/htest/fisherTest.d.ts +2 -1
  101. package/dist/htest/fisherTest.js +52 -6
  102. package/dist/htest/ksTest.d.ts +4 -0
  103. package/dist/htest/ksTest.js +13 -4
  104. package/dist/htest/leveneTest.d.ts +2 -0
  105. package/dist/htest/leveneTest.js +9 -3
  106. package/dist/htest/mantelhaenTest.js +7 -0
  107. package/dist/htest/mcnemarTest.js +8 -0
  108. package/dist/htest/multipleComparisons.d.ts +16 -25
  109. package/dist/htest/multipleComparisons.js +26 -43
  110. package/dist/htest/normalityTests.js +10 -4
  111. package/dist/htest/onewayTest.js +10 -0
  112. package/dist/htest/pAdjust.js +4 -0
  113. package/dist/htest/pairwise.d.ts +2 -0
  114. package/dist/htest/pairwise.js +29 -6
  115. package/dist/htest/poissonTest.js +6 -0
  116. package/dist/htest/polycor.js +20 -10
  117. package/dist/htest/power.d.ts +4 -0
  118. package/dist/htest/power.js +16 -2
  119. package/dist/htest/propTest.d.ts +3 -0
  120. package/dist/htest/propTest.js +23 -2
  121. package/dist/htest/pwr.d.ts +38 -1
  122. package/dist/htest/pwr.js +38 -15
  123. package/dist/htest/rankTests.js +7 -1
  124. package/dist/htest/tTest.d.ts +2 -0
  125. package/dist/htest/tTest.js +9 -0
  126. package/dist/htest/testFormula.js +11 -11
  127. package/dist/htest/trendTests.d.ts +21 -1
  128. package/dist/htest/trendTests.js +13 -18
  129. package/dist/htest/types.d.ts +2 -0
  130. package/dist/htest/varTest.js +7 -0
  131. package/dist/htest/wilcoxTest.js +51 -9
  132. package/dist/internal/checkOptions.d.ts +11 -0
  133. package/dist/internal/checkOptions.js +31 -0
  134. package/dist/internal/optionalArgs.d.ts +12 -0
  135. package/dist/internal/optionalArgs.js +46 -0
  136. package/dist/internal/warnings.d.ts +66 -0
  137. package/dist/internal/warnings.js +122 -0
  138. package/dist/linalg/basic.js +7 -0
  139. package/dist/linalg/chol.js +6 -0
  140. package/dist/linalg/eigen.js +4 -0
  141. package/dist/linalg/expm.js +4 -0
  142. package/dist/linalg/kappa.js +6 -0
  143. package/dist/linalg/lu.js +5 -0
  144. package/dist/linalg/norm.js +4 -0
  145. package/dist/linalg/ops.d.ts +27 -2
  146. package/dist/linalg/ops.js +14 -13
  147. package/dist/linalg/qr.js +14 -0
  148. package/dist/linalg/solve.js +9 -0
  149. package/dist/linalg/svd.js +6 -2
  150. package/dist/linalg.js +2 -2
  151. package/dist/mixed.js +4 -4
  152. package/dist/models/anovaSequential.d.ts +16 -1
  153. package/dist/models/anovaSequential.js +50 -7
  154. package/dist/models/aovEz.js +16 -11
  155. package/dist/models/aovStrata.js +15 -4
  156. package/dist/models/carAnova.js +11 -17
  157. package/dist/models/coxph.d.ts +6 -0
  158. package/dist/models/coxph.js +21 -6
  159. package/dist/models/glm.d.ts +22 -2
  160. package/dist/models/glm.js +32 -22
  161. package/dist/models/glmAnova.js +8 -3
  162. package/dist/models/glmConfint.js +6 -2
  163. package/dist/models/glmFamily.d.ts +1 -6
  164. package/dist/models/glmFamily.js +3 -22
  165. package/dist/models/lm.js +13 -3
  166. package/dist/models/lmer.d.ts +11 -6
  167. package/dist/models/lmer.js +20 -15
  168. package/dist/models/lmerAnova.d.ts +3 -3
  169. package/dist/models/lmerAnova.js +10 -5
  170. package/dist/models/lmerTest.d.ts +4 -4
  171. package/dist/models/lmerTest.js +19 -11
  172. package/dist/models/mauchly.d.ts +2 -0
  173. package/dist/models/mauchly.js +7 -2
  174. package/dist/models/modelFrame.js +2 -2
  175. package/dist/models/modelMatrix.js +7 -2
  176. package/dist/models/survival.d.ts +6 -0
  177. package/dist/models/survival.js +9 -2
  178. package/dist/numerics/deriv.js +8 -0
  179. package/dist/numerics/integrate.js +8 -0
  180. package/dist/numerics/interp.d.ts +32 -7
  181. package/dist/numerics/interp.js +27 -9
  182. package/dist/numerics/ode.js +4 -0
  183. package/dist/numerics.js +2 -2
  184. package/dist/optim/optim.js +17 -2
  185. package/dist/random/beta.js +5 -0
  186. package/dist/random/continuous.js +17 -0
  187. package/dist/random/extra.js +13 -0
  188. package/dist/random/gamma.js +11 -0
  189. package/dist/random/poisson.js +5 -0
  190. package/dist/random/rng.js +4 -0
  191. package/dist/random/sample.js +6 -0
  192. package/dist/rstats.js +17 -14
  193. package/dist/special/besselIK.js +7 -0
  194. package/dist/special/choose.js +7 -0
  195. package/dist/special/psigamma.js +7 -0
  196. package/dist/special.js +2 -2
  197. package/dist/tests.js +15 -11
  198. package/llms.txt +5 -2
  199. package/package.json +19 -10
  200. package/dist/chunks/chunk-2D2IQWUQ.js +0 -2
  201. package/dist/chunks/chunk-6CSTWA5E.js +0 -2
  202. package/dist/chunks/chunk-72Y3HZID.js +0 -2
  203. package/dist/chunks/chunk-BG2KLEHM.js +0 -2
  204. package/dist/chunks/chunk-CMEKBNHQ.js +0 -2
  205. package/dist/chunks/chunk-GM53LWSR.js +0 -2
  206. package/dist/chunks/chunk-JBCA56ZS.js +0 -3
  207. package/dist/chunks/chunk-K3RJAD2T.js +0 -2
  208. package/dist/chunks/chunk-KAZRWIB5.js +0 -2
  209. package/dist/chunks/chunk-KBVVIMXX.js +0 -3
  210. package/dist/chunks/chunk-N3SIFCZX.js +0 -2
  211. package/dist/chunks/chunk-SC6CV4Z3.js +0 -2
  212. package/dist/chunks/chunk-SYWOBOTR.js +0 -2
  213. package/dist/chunks/chunk-VTUGG2SV.js +0 -2
  214. package/dist/chunks/chunk-XHETEYVC.js +0 -2
  215. package/dist/chunks/chunk-YRZWONZB.js +0 -3
  216. package/dist/chunks/chunk-ZGABZMWX.js +0 -2
@@ -12,7 +12,11 @@ import { ldexp } from "../internal/summary.js";
12
12
  import { qr } from "../linalg/qr.js";
13
13
  import { ddAdd, ddMul, ddMulNum } from "../special/dd.js";
14
14
  import { ddLeastSquares, ddSqrtWeights } from "./ddLeastSquares.js";
15
- import { responseScale, scaledRss } from "./anovaSequential.js";
15
+ import { evenWeightExponent, responseScale, rssWithinRounding, scaledRss, weightedResponse } from "./anovaSequential.js";
16
+ import { reported } from "../internal/warnings.js";
17
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
18
+ import { checkOptions } from "../internal/checkOptions.js";
19
+ const ANOVA_KEYS = ["type"];
16
20
  /**
17
21
  * The sum of the squared effects of the columns `added` after the columns `base`, and the number of added columns
18
22
  * that are not aliased (the decrease of the residual sum of squares and the increase of the rank), for the response
@@ -66,6 +70,7 @@ function addedSS(fit, base, added, k, kw = 0) {
66
70
  * @category Linear models and ANOVA
67
71
  */
68
72
  export function Anova(fit, options = {}) {
73
+ checkOptions(options, ANOVA_KEYS, "Anova"); // generated: option-keys.mjs
69
74
  if (typeof fit !== "object" || fit === null || !Array.isArray(fit.effects)) {
70
75
  throw new TypeError("Anova() needs a fit from lm() with a formula");
71
76
  }
@@ -87,13 +92,9 @@ export function Anova(fit, options = {}) {
87
92
  // is 0 within rounding error below 1e-24 times the (weighted, uncentred) sum of squares of the response, residuals
88
93
  // below 1e-12 of the response's size (the level of aovEz's dataSS). sqrt(eps) times the centred total rejected data
89
94
  // with R^2 above 1 - 1.5e-8 that car computes (revision of review 4)
90
- const wy = fit.y.flatMap((v, i) => ((fit.weights?.[i] ?? 1) === 0 ? [] : [[fit.weights?.[i] ?? 1, ldexp(v, -k)]]));
95
+ const wy = weightedResponse(fit, k);
91
96
  // Where a sum over the weights overflows (the total of the weights of 1e308, #347), the weights are divided by an
92
97
  // even power of 2 2^kw: the sums of squares are then in units of 2^(2k + kw). kw is 0 otherwise (the same bits)
93
- const evenWeightExponent = () => {
94
- const e = Math.floor(Math.log2(wy.reduce((a, [w]) => Math.max(a, w), 0)));
95
- return e - (((e % 2) + 2) % 2);
96
- };
97
98
  const weightedTss = (kw) => {
98
99
  const ws = wy.map(([w, v]) => [ldexp(w, -kw), v]);
99
100
  const sw = ws.reduce((a, [w]) => a + w, 0);
@@ -103,19 +104,12 @@ export function Anova(fit, options = {}) {
103
104
  let kw = 0;
104
105
  let tss = weightedTss(0);
105
106
  if (!Number.isFinite(tss)) {
106
- kw = evenWeightExponent();
107
+ kw = evenWeightExponent(wy);
107
108
  tss = weightedTss(kw);
108
109
  }
109
110
  // (kw from the centred total as before, which the sums of squares of the terms use; the uncentred sum, at most
110
111
  // 16 times the total weight, takes its own even power of 2 where it overflows)
111
- const weightedSs = (kv) => wy.reduce((a, [w, v]) => a + ldexp(w, -kv) * v * v, 0);
112
- let kss = kw;
113
- let ss = weightedSs(kss);
114
- if (!Number.isFinite(ss)) {
115
- kss = evenWeightExponent();
116
- ss = weightedSs(kss);
117
- }
118
- if (!(ldexp(rss, -kss) >= 1e-24 * ss) || rss === 0)
112
+ if (rssWithinRounding(wy, rss, kw) || rss === 0)
119
113
  throw new Error("residual sum of squares is 0 (within rounding error)");
120
114
  // the fit's warnings (from its model matrix and summary) first, as for aov with Error(); R gives them when fitting
121
115
  const warnings = [...fit.warnings];
@@ -159,7 +153,7 @@ export function Anova(fit, options = {}) {
159
153
  };
160
154
  rows = termRows(kw);
161
155
  if (kw === 0 && fit.weights !== undefined && rows.some((r) => !Number.isFinite(r.ss))) {
162
- kw = evenWeightExponent();
156
+ kw = evenWeightExponent(wy);
163
157
  rows = termRows(kw);
164
158
  }
165
159
  const back = (v) => ldexp(v, 2 * k + kw);
@@ -170,5 +164,5 @@ export function Anova(fit, options = {}) {
170
164
  return [back(ss), df, f, pf1(f, df, rdf, false, false)];
171
165
  });
172
166
  table.push([back(rssW), rdf, NaN, NaN]);
173
- return { colNames: ["Sum Sq", "Df", "F value", "Pr(>F)"], rowNames: [...names, "Residuals"], table, warnings };
167
+ return reported("Anova", { colNames: ["Sum Sq", "Df", "F value", "Pr(>F)"], rowNames: [...names, "Residuals"], table, warnings }, fit);
174
168
  }
@@ -80,6 +80,12 @@ export interface CoxphResult {
80
80
  z: number[];
81
81
  /** Two-sided p-values `Pr(>|z|)` */
82
82
  p: number[];
83
+ /** Alias of `se`: the same array. */
84
+ stdError: number[];
85
+ /** Alias of `z`: the same array. */
86
+ zValue: number[];
87
+ /** Alias of `p`: the same array. */
88
+ pValue: number[];
83
89
  /** Lower confidence limits of exp(coef) */
84
90
  lower: number[];
85
91
  /** Upper confidence limits of exp(coef) */
@@ -14,8 +14,12 @@ import { qnorm } from "../distributions/normal.js";
14
14
  import { numberLevels } from "../internal/levels.js";
15
15
  import { ldexp, mean, scaleToUnit } from "../internal/summary.js";
16
16
  import { mergeTiedTimes } from "./tiedTimes.js";
17
- import { Warnings } from "./glmFamily.js";
17
+ import { reported, Warnings } from "../internal/warnings.js";
18
18
  import { maxOf } from "../internal/extremes.js";
19
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
20
+ import { checkOptions, nestedOptions } from "../internal/checkOptions.js";
21
+ const COXPH_KEYS = ["ties", "weights", "strata", "init", "control", "nocenter", "confLevel"];
22
+ const COXPH_CONTROL_KEYS = ["eps", "iterMax", "tolerChol", "tolerInf"];
19
23
  const isMissingLabel = (v) => v === null || v === undefined || (typeof v === "number" && Number.isNaN(v));
20
24
  const compareLabels = (a, b) => typeof a === "number" && typeof b === "number" ? a - b : String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0;
21
25
  /** Distance of eta from the shift of the risk sums beyond which exp would leave (or near) the doubles (e^709.8 overflows) */
@@ -245,6 +249,9 @@ function zeroEventResult(rows, p) {
245
249
  const n = rows.length;
246
250
  const nans = () => new Array(p).fill(NaN);
247
251
  const test = chisqTest(0, 0);
252
+ const se = new Array(p).fill(0);
253
+ const z = nans();
254
+ const pz = nans();
248
255
  return {
249
256
  coefficients: nans(),
250
257
  var: Array.from({ length: p }, () => new Array(p).fill(0)),
@@ -256,9 +263,12 @@ function zeroEventResult(rows, p) {
256
263
  n,
257
264
  nevent: 0,
258
265
  linearPredictors: new Array(n).fill(0),
259
- se: new Array(p).fill(0),
260
- z: nans(),
261
- p: nans(),
266
+ se,
267
+ z,
268
+ p: pz,
269
+ stdError: se,
270
+ zValue: z,
271
+ pValue: pz,
262
272
  lower: nans(),
263
273
  upper: nans(),
264
274
  logtest: test,
@@ -293,6 +303,8 @@ function zeroEventResult(rows, p) {
293
303
  * @category Survival analysis
294
304
  */
295
305
  export function coxph(time, status, x, options = {}) {
306
+ checkOptions(options, COXPH_KEYS, "coxph"); // generated: option-keys.mjs
307
+ checkOptions(nestedOptions(options, "control"), COXPH_CONTROL_KEYS, "coxph", "control"); // generated: option-keys.mjs
296
308
  const { ties = "efron", weights, strata, init, control = {}, nocenter = [-1, 0, 1], confLevel = 0.95 } = options;
297
309
  const { eps = 1e-9, iterMax = 20, tolerChol = 2 ** -39 } = control;
298
310
  const tolerInf = control.tolerInf ?? Math.sqrt(eps);
@@ -567,7 +579,7 @@ export function coxph(time, status, x, options = {}) {
567
579
  const lower = coefficients.map((c, j) => Math.exp(c - q * se[j]));
568
580
  const upper = coefficients.map((c, j) => Math.exp(c + q * se[j]));
569
581
  const lr = -2 * (loglik[0] - loglik[1]);
570
- return {
582
+ return reported("coxph", {
571
583
  coefficients,
572
584
  var: variance,
573
585
  loglik,
@@ -581,6 +593,9 @@ export function coxph(time, status, x, options = {}) {
581
593
  se,
582
594
  z,
583
595
  p: pz,
596
+ stdError: se,
597
+ zValue: z,
598
+ pValue: pz,
584
599
  lower,
585
600
  upper,
586
601
  logtest: chisqTest(lr, k),
@@ -588,5 +603,5 @@ export function coxph(time, status, x, options = {}) {
588
603
  waldtest: chisqTest(wald, k),
589
604
  rsq: { rsq: 1 - Math.exp(-lr / n), maxrsq: 1 - Math.exp((2 * loglik[0]) / n) },
590
605
  warnings: warnings.list,
591
- };
606
+ });
592
607
  }
@@ -1,7 +1,8 @@
1
1
  import type { MatrixInput } from "../linalg/matrix.js";
2
2
  import { type QR } from "../linalg/qr.js";
3
3
  import type { Sample } from "../htest/types.js";
4
- import { Warnings, type Family, type GlmFamilyName, type GlmFamilySpec, type GlmLink } from "./glmFamily.js";
4
+ import { type Family, type GlmFamilyName, type GlmFamilySpec, type GlmLink } from "./glmFamily.js";
5
+ import { Warnings } from "../internal/warnings.js";
5
6
  export type { GlmFamilyName, GlmFamilySpec, GlmLink, GlmLinkName, QuasiVariance } from "./glmFamily.js";
6
7
  /**
7
8
  * Options for {@link glm}.
@@ -274,9 +275,18 @@ export declare function glmSummary(given: GlmResult, options?: GlmSummaryOptions
274
275
  * @category Generalized linear models
275
276
  */
276
277
  export type GlmResidualType = "deviance" | "pearson" | "working" | "response";
278
+ /**
279
+ * Options for {@link glmResiduals}.
280
+ *
281
+ * @category Generalized linear models
282
+ */
283
+ export interface GlmResidualsOptions {
284
+ /** Kind of residuals. Default `"deviance"`. */
285
+ type?: GlmResidualType;
286
+ }
277
287
  /**
278
288
  * Residuals of a generalized linear model, one per row, for a `glm` fit (default `"deviance"`). Equivalent to R's
279
- * `residuals(fit, type)`.
289
+ * `residuals(fit, type)`. The kind is the second argument or the option `type` (giving both is a RangeError).
280
290
  *
281
291
  * @example
282
292
  * ```ts
@@ -288,6 +298,16 @@ export type GlmResidualType = "deviance" | "pearson" | "working" | "response";
288
298
  * @category Generalized linear models
289
299
  */
290
300
  export declare function glmResiduals(fit: GlmResult, type?: GlmResidualType): number[];
301
+ /**
302
+ * Residuals of a generalized linear model, with the kind in the options: `glmResiduals(fit, { type: "pearson" })`.
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * const fit = glm([1, 2, 3, 4, 5, 6], [0, 0, 1, 0, 1, 1], { family: "binomial" });
307
+ * glmResiduals(fit, { type: "pearson" }); // [-0.21925, -0.40231, 1.3546, -1.3546, 0.40231, 0.21925]
308
+ * ```
309
+ */
310
+ export declare function glmResiduals(fit: GlmResult, options: GlmResidualsOptions): number[];
291
311
  /**
292
312
  * Diagonal of the hat matrix of the last weighted least squares step, for the rows of non-zero prior weight, for a
293
313
  * `glm` fit. Equivalent to R's `hatvalues()`.
@@ -10,11 +10,24 @@ import { pt1 } from "../distributions/t.js";
10
10
  import { pnorm } from "../distributions/normal.js";
11
11
  import { chol2invColumns } from "../internal/scaledInverse.js";
12
12
  import { qr, qrCoef, qrQy } from "../linalg/qr.js";
13
- import { familyAic, makeFamily, prepareResponse, Warnings, withWarnings, } from "./glmFamily.js";
13
+ import { familyAic, makeFamily, prepareResponse, } from "./glmFamily.js";
14
14
  import { maxOf } from "../internal/extremes.js";
15
+ import { reported, Warnings, withWarnings } from "../internal/warnings.js";
16
+ import { optionalArgs } from "../internal/optionalArgs.js";
15
17
  import { ldexp, ldexpWide, scaleToUnit } from "../internal/summary.js";
16
18
  import { NON_ESTIMABLE_WARNING, nonEstimableRows } from "./estimable.js";
17
19
  import { checkDot, checkedDot } from "../linalg/dot.js";
20
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
21
+ import { checkOptions, nestedOptions } from "../internal/checkOptions.js";
22
+ import { optionsIn } from "../internal/optionalArgs.js";
23
+ const GLM_KEYS = ["family", "link", "weights", "offset", "start", "epsilon", "maxit", "intercept"];
24
+ const GLM_FAMILY_KEYS = ["family", "link", "variance"];
25
+ const GLM_FAMILY_LINK_KEYS = ["power"];
26
+ const GLM_SUMMARY_KEYS = ["dispersion"];
27
+ const GLM_RESIDUALS_KEYS = ["type"];
28
+ const GLM_RSTANDARD_KEYS = ["dispersion"];
29
+ const GLM_COOKS_DISTANCE_KEYS = ["dispersion"];
30
+ const GLM_PREDICT_KEYS = ["newdata", "newoffset", "type", "dispersion"];
18
31
  const EPS = 2 ** -52;
19
32
  function deparseNames(names) {
20
33
  const q = names.map((s) => `"${s}"`);
@@ -381,6 +394,10 @@ export function refit(model, cols, warnings, control = {}) {
381
394
  * @category Generalized linear models
382
395
  */
383
396
  export function glm(x, y, options = {}) {
397
+ checkOptions(options, GLM_KEYS, "glm"); // generated: option-keys.mjs
398
+ checkOptions(nestedOptions(options, "family"), GLM_FAMILY_KEYS, "glm", "family"); // generated: option-keys.mjs
399
+ checkOptions(nestedOptions(options, "family.link"), GLM_FAMILY_LINK_KEYS, "glm", "family.link"); // generated: option-keys.mjs
400
+ checkOptions(nestedOptions(options, "link"), GLM_FAMILY_LINK_KEYS, "glm", "link"); // generated: option-keys.mjs
384
401
  const intercept = options.intercept ?? true;
385
402
  const xr = toRows(x);
386
403
  // the shape of all the rows given, before the rows with a missing value are dropped (#463)
@@ -445,7 +462,7 @@ export function glm(x, y, options = {}) {
445
462
  // (exact; src/internal/summary.ts), so that the deviance stays in range; see scaledView
446
463
  const k = !yIsMatrix && scalesWithResponse(familySpec) ? scaleToUnit([yGiven]).k : 0;
447
464
  if (k === 0)
448
- return fitModel(model);
465
+ return reported("glm", fitModel(model));
449
466
  const down = (v) => ldexp(v, -k);
450
467
  const scaled = fitModel({
451
468
  ...model,
@@ -453,7 +470,7 @@ export function glm(x, y, options = {}) {
453
470
  offset: offset.map(down),
454
471
  start: model.start?.map(down),
455
472
  });
456
- return unscaledResult(scaled, k, { ...model, yScale: k });
473
+ return reported("glm", unscaledResult(scaled, k, { ...model, yScale: k }));
457
474
  }
458
475
  /** The fit of a model (the part of glm after its checks) */
459
476
  function fitModel(model) {
@@ -676,6 +693,7 @@ export function scaledDispersion(d, k) {
676
693
  * @category Generalized linear models
677
694
  */
678
695
  export function glmSummary(given, options = {}) {
696
+ checkOptions(options, GLM_SUMMARY_KEYS, "glmSummary"); // generated: option-keys.mjs
679
697
  // computed on the scaled fit (scaledView); estimates, standard errors and the dispersion scaled back
680
698
  const { fit, k } = scaledView(given);
681
699
  const warnings = new Warnings();
@@ -702,7 +720,7 @@ export function glmSummary(given, options = {}) {
702
720
  }
703
721
  const up = (v) => ldexp(v, k);
704
722
  const up2 = (v) => ldexp(v, 2 * k);
705
- return {
723
+ return reported("glmSummary", {
706
724
  dispersion: s === 0 ? up2(dispersion) : options.dispersion,
707
725
  estimate: estimate.map(up),
708
726
  // (with s != 0 in the original units at once: sqrt(inv m) 2^(s + k - e))
@@ -717,22 +735,11 @@ export function glmSummary(given, options = {}) {
717
735
  : inv.map((r, j) => r.map((v, l) => ldexpWide(v * dispersion, 2 * (s + k) - e[j] - e[l]))),
718
736
  dfResidual: fit.dfResidual,
719
737
  warnings: warnings.list,
720
- };
738
+ }, given);
721
739
  }
722
- /**
723
- * Residuals of a generalized linear model, one per row, for a `glm` fit (default `"deviance"`). Equivalent to R's
724
- * `residuals(fit, type)`.
725
- *
726
- * @example
727
- * ```ts
728
- * const fit = glm([1, 2, 3, 4, 5, 6], [0, 0, 1, 0, 1, 1], { family: "binomial" });
729
- * glmResiduals(fit); // [-0.30644, -0.54776, 1.4436, -1.4436, 0.54776, 0.30644]
730
- * glmResiduals(fit, "pearson"); // [-0.21925, -0.40231, 1.3546, -1.3546, 0.40231, 0.21925]
731
- * ```
732
- *
733
- * @category Generalized linear models
734
- */
735
- export function glmResiduals(fit, type = "deviance") {
740
+ export function glmResiduals(fit, ...args) {
741
+ checkOptions(optionsIn(args), GLM_RESIDUALS_KEYS, "glmResiduals"); // generated: option-keys.mjs
742
+ const type = optionalArgs(["type"], args).type ?? "deviance";
736
743
  // of the scaled fit (scaledView), scaled back: for the families that are scaled, every kind has the response's units
737
744
  const v = scaledView(fit);
738
745
  return residualsOf(v.fit, type).map((r) => ldexp(r, v.k));
@@ -805,6 +812,7 @@ function median(v) {
805
812
  * @category Generalized linear models
806
813
  */
807
814
  export function glmRstandard(given, options = {}) {
815
+ checkOptions(options, GLM_RSTANDARD_KEYS, "glmRstandard"); // generated: option-keys.mjs
808
816
  // on the scaled fit (scaledView): the standardized residuals have no units
809
817
  const { fit, k } = scaledView(given);
810
818
  const h = glmHatvalues(fit);
@@ -830,6 +838,7 @@ export function glmRstandard(given, options = {}) {
830
838
  * @category Generalized linear models
831
839
  */
832
840
  export function glmCooksDistance(given, options = {}) {
841
+ checkOptions(options, GLM_COOKS_DISTANCE_KEYS, "glmCooksDistance"); // generated: option-keys.mjs
833
842
  // on the scaled fit (scaledView): Cook's distances have no units
834
843
  const { fit, k } = scaledView(given);
835
844
  const h = glmHatvalues(fit);
@@ -875,6 +884,7 @@ function cookScaled(r, h, d, p) {
875
884
  * @category Generalized linear models
876
885
  */
877
886
  export function glmPredict(given, options = {}) {
887
+ checkOptions(options, GLM_PREDICT_KEYS, "glmPredict"); // generated: option-keys.mjs
878
888
  // on the scaled fit (scaledView), with the new offset and the dispersion scaled alike; predictions and standard
879
889
  // errors scaled back (the families that are scaled use the identity link)
880
890
  const { fit, k } = scaledView(given);
@@ -939,10 +949,10 @@ export function glmPredict(given, options = {}) {
939
949
  const nonEstimable = options.newdata === undefined ? [] : nonEstimableRows(fit.qr, rank, X);
940
950
  const extra = nonEstimable.length > 0 ? { nonEstimable, warnings: [NON_ESTIMABLE_WARNING] } : {};
941
951
  if (type === "link")
942
- return { fit: eta.map(up), seFit: se.map(upSe), ...extra };
943
- return withWarnings(new Warnings(), () => ({
952
+ return reported("glmPredict", { fit: eta.map(up), seFit: se.map(upSe), ...extra }, given);
953
+ return reported("glmPredict", withWarnings(new Warnings(), () => ({
944
954
  fit: eta.map((e) => up(fam.linkinv(e))),
945
955
  seFit: se.map((s, i) => upSe(s * Math.abs(fam.muEta(eta[i])))),
946
956
  ...extra,
947
- }));
957
+ })), given);
948
958
  }
@@ -10,8 +10,12 @@ import { pgamma1 } from "../distributions/gamma.js";
10
10
  import { ldexp, ldexpWide } from "../internal/summary.js";
11
11
  import { nestedColumns } from "./estimable.js";
12
12
  import { glmDispersion, refit, scaledDispersion, scaledView } from "./glm.js";
13
- import { makeFamily, Warnings } from "./glmFamily.js";
13
+ import { makeFamily } from "./glmFamily.js";
14
+ import { reported, Warnings } from "../internal/warnings.js";
14
15
  import { scoreStatistic } from "./glmConfint.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 GLM_ANOVA_KEYS = ["test", "dispersion"];
15
19
  /** Upper tail of chi-squared with df degrees of freedom */
16
20
  const pchisqUpper = (q, df) => pgamma1(q, df / 2, 2, false, false);
17
21
  /**
@@ -48,6 +52,7 @@ const rao = (small, large) => scoreStatistic(large.x, small.fit.workingResiduals
48
52
  * @category Generalized linear models
49
53
  */
50
54
  export function glmAnova(fits, options = {}) {
55
+ checkOptions(options, GLM_ANOVA_KEYS, "glmAnova"); // generated: option-keys.mjs
51
56
  const given = Array.isArray(fits) ? fits : [fits];
52
57
  if (given.length === 0)
53
58
  throw new RangeError("no fits to compare");
@@ -61,7 +66,7 @@ export function glmAnova(fits, options = {}) {
61
66
  const shift = user?.s ?? 0;
62
67
  const table = glmAnovaScaled(list, Array.isArray(fits) && list.length > 1, { ...options, ...(user === undefined ? {} : { dispersion: user.m }) }, shift);
63
68
  if (k === 0 && shift === 0)
64
- return table;
69
+ return reported("glmAnova", table, ...given);
65
70
  const squared = new Set(["Deviance", "Resid. Dev", "Rao", "Cp"]);
66
71
  const cols = table.colNames.map((c) => squared.has(c));
67
72
  const scaledBack = table.table.map((r) => r.map((v, j) => (cols[j] ? ldexp(v, 2 * k) : v)));
@@ -74,7 +79,7 @@ export function glmAnova(fits, options = {}) {
74
79
  for (const r of scaledBack)
75
80
  r[cp] = r[dev] + 2 * (n - r[dfRes]) * options.dispersion;
76
81
  }
77
- return { ...table, table: scaledBack };
82
+ return reported("glmAnova", { ...table, table: scaledBack }, ...given);
78
83
  }
79
84
  function glmAnovaScaled(list, compare, options, shift = 0) {
80
85
  const warnings = new Warnings();
@@ -15,7 +15,10 @@ import { ldexp } from "../internal/summary.js";
15
15
  import { uniroot } from "../internal/uniroot.js";
16
16
  import { qr, qrResid } from "../linalg/qr.js";
17
17
  import { glmSummary, refit, scaledView } from "./glm.js";
18
- import { Warnings } from "./glmFamily.js";
18
+ import { 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 GLM_CONFINT_KEYS = ["parm", "level", "test"];
19
22
  /**
20
23
  * Settings of the fits iterated to convergence: until the coefficients stop changing (at most 100 iterations), and
21
24
  * the tolerance of the QR decomposition that of epsilon = 1e-300 (columns found aliased by the fit are left out)
@@ -102,6 +105,7 @@ export function scoreStatistic(x, r, v, intercept, tol = 1e-11) {
102
105
  * @category Generalized linear models
103
106
  */
104
107
  export function glmConfint(given, options = {}) {
108
+ checkOptions(options, GLM_CONFINT_KEYS, "glmConfint"); // generated: option-keys.mjs
105
109
  // on the scaled fit (scaledView); the limits scaled back
106
110
  const { fit, k } = scaledView(given);
107
111
  const level = options.level ?? 0.95;
@@ -139,7 +143,7 @@ export function glmConfint(given, options = {}) {
139
143
  qr: full.fit.qr,
140
144
  rank: full.fit.rank,
141
145
  };
142
- const summary = glmSummary(convergedFit);
146
+ const summary = unreported(() => glmSummary(convergedFit));
143
147
  const dispersion = summary.dispersion;
144
148
  const se = new Array(p).fill(NaN);
145
149
  const piv = full.fit.qr === undefined ? [] : full.fit.qr.pivot.slice(0, full.fit.rank);
@@ -1,3 +1,4 @@
1
+ import { type Warnings } from "../internal/warnings.js";
1
2
  /**
2
3
  * Names of the families of R's stats.
3
4
  *
@@ -72,12 +73,6 @@ export interface Family extends LinkFunctions {
72
73
  /** The variance function is mu^varPower (gaussian 0, poisson 1, Gamma 2, inverse.gaussian 3 and their quasi) */
73
74
  varPower?: number;
74
75
  }
75
- /** Collects warnings in order of first appearance, each once (as the fixtures list R's warnings) */
76
- export declare class Warnings {
77
- readonly list: string[];
78
- add(message: string): void;
79
- }
80
- export declare function withWarnings<T>(sink: Warnings, f: () => T): T;
81
76
  /** Resolves a family name or specification (and a link given separately) to its functions */
82
77
  export declare function makeFamily(family: GlmFamilyName | GlmFamilySpec, link?: GlmLink): Family;
83
78
  /** The response after the family has read it, with the prior weights, the starting means and the binomial sizes */
@@ -11,6 +11,7 @@ import { dnorm, pnorm, qnorm } from "../distributions/normal.js";
11
11
  import { dpois1, nonInteger } from "../distributions/poisson.js";
12
12
  import { roundHalfEven } from "../internal/integer.js";
13
13
  import { ldexp } from "../internal/summary.js";
14
+ import { warn } from "../internal/warnings.js";
14
15
  import { bd0 } from "../special/loader.js";
15
16
  import { log1pmx } from "../special/log1p.js";
16
17
  const ALLOWED = {
@@ -25,30 +26,10 @@ const ALLOWED = {
25
26
  };
26
27
  const positive = (eta) => Number.isFinite(eta) && eta > 0;
27
28
  const anyEta = () => true;
28
- /** Collects warnings in order of first appearance, each once (as the fixtures list R's warnings) */
29
- export class Warnings {
30
- list = [];
31
- add(message) {
32
- if (!this.list.includes(message))
33
- this.list.push(message);
34
- }
35
- }
36
- /** The warnings sink of the link functions that warn ("NaNs produced"); set while a fit runs */
37
- let currentWarnings;
38
- export function withWarnings(sink, f) {
39
- const saved = currentWarnings;
40
- currentWarnings = sink;
41
- try {
42
- return f();
43
- }
44
- finally {
45
- currentWarnings = saved;
46
- }
47
- }
48
29
  /** Square root that warns as R's sqrt does when it produces NaN */
49
30
  function sqrtWarn(x) {
50
31
  if (x < 0)
51
- currentWarnings?.add("NaNs produced");
32
+ warn("NaNs produced");
52
33
  return Math.sqrt(x);
53
34
  }
54
35
  /**
@@ -57,7 +38,7 @@ function sqrtWarn(x) {
57
38
  */
58
39
  function logWarn(x) {
59
40
  if (x < 0)
60
- currentWarnings?.add("NaNs produced");
41
+ warn("NaNs produced");
61
42
  return Math.log(x);
62
43
  }
63
44
  /** A number as C's printf("%g") writes it: 6 significant digits, fixed or scientific, trailing zeros dropped */
package/dist/models/lm.js CHANGED
@@ -24,6 +24,13 @@ import { parseFormula } from "./formula.js";
24
24
  import { design } from "./modelMatrix.js";
25
25
  import { NON_ESTIMABLE_WARNING, nonEstimableRows } from "./estimable.js";
26
26
  import { checkDot, checkedDot } from "../linalg/dot.js";
27
+ import { reported } from "../internal/warnings.js";
28
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
29
+ import { checkOptions } from "../internal/checkOptions.js";
30
+ const LM_KEYS = ["weights", "contrasts", "levels", "intercept"];
31
+ const CONFINT_KEYS = ["level"];
32
+ const PREDICT_KEYS = ["interval", "level"];
33
+ // Generated by `node scripts/option-keys.mjs --write` (end)
27
34
  const MIN_NORMAL = 2 ** -1022;
28
35
  /** The formula fit (lm, and aov without Error()) */
29
36
  export function lmFormulaFit(formula, d, aov) {
@@ -68,8 +75,9 @@ export function lmFormulaFit(formula, d, aov) {
68
75
  return out;
69
76
  }
70
77
  export function lm(x, y, options = {}) {
78
+ checkOptions(options, LM_KEYS, "lm"); // generated: option-keys.mjs
71
79
  if (typeof x === "string") {
72
- return lmFormulaFit(x, design(parseFormula(x), y, { ...options, dropUnusedLevels: true }), false);
80
+ return reported("lm", lmFormulaFit(x, design(parseFormula(x), y, { ...options, dropUnusedLevels: true }), false));
73
81
  }
74
82
  return lmMatrix(x, y, options);
75
83
  }
@@ -395,6 +403,7 @@ function tQuantile(level, df) {
395
403
  * @category Linear models and ANOVA
396
404
  */
397
405
  export function confint(fit, options = {}) {
406
+ checkOptions(options, CONFINT_KEYS, "confint"); // generated: option-keys.mjs
398
407
  const level = options.level ?? 0.95;
399
408
  // R's confint gives NaN limits for a level outside (0, 1) and predict an interval of some other coverage; an error
400
409
  if (!(level > 0 && level < 1))
@@ -437,6 +446,7 @@ function scaledProduct(a, b, s) {
437
446
  * @category Linear models and ANOVA
438
447
  */
439
448
  export function predict(fit, newdata, options = {}) {
449
+ checkOptions(options, PREDICT_KEYS, "predict"); // generated: option-keys.mjs
440
450
  const rows = newdata.length > 0 && typeof newdata[0] !== "number"
441
451
  ? newdata.map((r) => Array.from(r))
442
452
  : Array.from(newdata, (v) => [v]);
@@ -491,11 +501,11 @@ export function predict(fit, newdata, options = {}) {
491
501
  const nonEstimable = nonEstimableRows(fit.qr, fit.rank, X);
492
502
  const extra = nonEstimable.length > 0 ? { nonEstimable, warnings: [NON_ESTIMABLE_WARNING] } : {};
493
503
  if (interval === "none")
494
- return { fit: values, seFit, ...extra };
504
+ return reported("predict", { fit: values, seFit, ...extra }, fit);
495
505
  const level = options.level ?? 0.95;
496
506
  if (!(level > 0 && level < 1))
497
507
  throw new RangeError("'level' must be between 0 and 1");
498
508
  const t = tQuantile(level, fit.dfResidual);
499
509
  const half = seFit.map((s) => t * (interval === "prediction" ? Math.hypot(s, fit.sigma) : s));
500
- return { fit: values, seFit, lwr: values.map((v, i) => v - half[i]), upr: values.map((v, i) => v + half[i]), ...extra };
510
+ return reported("predict", { fit: values, seFit, lwr: values.map((v, i) => v - half[i]), upr: values.map((v, i) => v + half[i]), ...extra }, fit);
501
511
  }
@@ -11,7 +11,7 @@ export type LmerContrastName = ContrastName | "contr.poly";
11
11
  /**
12
12
  * Options of {@link lmer}. Only the keys below are accepted: R's `weights`, `offset`, `subset`, `naAction`,
13
13
  * `na.action`, `control`, `start`, `verbose` and `devFunOnly` give the Error `lmer: argument '<key>' is not
14
- * supported`, any other key the TypeError `unused argument (<key>)` (a key whose value is `undefined` included).
14
+ * supported`, any other key a RangeError (a key whose value is `undefined` included).
15
15
  *
16
16
  * @category Mixed models
17
17
  */
@@ -147,12 +147,13 @@ export declare function thetaColumnExponents(s: MixedModelStructure): {
147
147
  z: number[];
148
148
  };
149
149
  /**
150
- * The option checks of lmer and of lmerTest's functions (internal; oracle/report-0.14.0-behaviour.md, section 3):
151
- * `options` must be an object when given (not null, not an array); its own keys, in order, may be neither among those
152
- * of R that are not supported (the first gives an Error) nor unknown (a TypeError listing all of them). A key whose
153
- * value is `undefined` counts as given. Returns the options as an object (`{}` when not given).
150
+ * The first option check of lmer and of lmerTest's functions (internal; oracle/report-0.14.0-behaviour.md, section
151
+ * 3): `options` must be an object when given (not null, not an array), and none of its own keys, in order, among those
152
+ * of R that are not supported (the first gives an Error naming it). A key whose value is `undefined` counts as given.
153
+ * The unknown keys are checked after it (a RangeError of checkOptions, generated by scripts/option-keys.mjs, which
154
+ * keeps a first statement calling this function before its checks).
154
155
  */
155
- export declare function checkOptions<T extends object>(fn: string, options: T | undefined, accepted: readonly string[], unsupported: readonly string[]): T;
156
+ export declare function checkLmerOptions(fn: string, options: unknown, unsupported: readonly string[]): void;
156
157
  /**
157
158
  * A logical option as R's conditions take it (internal): `undefined` gives the default, a boolean itself, a number
158
159
  * other than NaN `false` for 0 and `true` otherwise; `null` and anything else are TypeErrors.
@@ -173,6 +174,10 @@ export declare function logicalOption(value: unknown, defaultValue: boolean): bo
173
174
  * differ in the 5th to 9th significant digit). Elements on the boundary are exactly 0, and the fit is then singular.
174
175
  * The computation is sparse (a sparse Cholesky factorisation, as in lme4), so many groups are handled quickly.
175
176
  *
177
+ * The functions that take the fit ({@link lmerSummary}, {@link lmerAnova}, {@link lmerContest} and the others) need
178
+ * the object `lmer` returned itself: a copy of it (`structuredClone`, `{ ...fit }`, JSON or `postMessage`) lacks the
179
+ * internal values they use and is a TypeError. The fields of a copy keep their values.
180
+ *
176
181
  * @param formula A formula such as `"Reaction ~ Days + (Days | Subject)"`.
177
182
  * @param data The data frame: an object of columns.
178
183
  * @param options `REML`, and `contrasts` and `levels` as in {@link lm} (see {@link LmerOptions} for the keys accepted).