@numero-uno-jpn/rstats 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.ja.md +13 -9
  3. package/README.md +13 -8
  4. package/dist/chunks/{chunk-QJJWGNJP.js → chunk-2X7JYQBI.js} +2 -2
  5. package/dist/chunks/{chunk-O6PT7IVU.js → chunk-36GVER3O.js} +2 -2
  6. package/dist/chunks/{chunk-EWC6I75B.js → chunk-3WUXRSM6.js} +1 -1
  7. package/dist/chunks/{chunk-4NM37MGA.js → chunk-6I6QKTFK.js} +2 -2
  8. package/dist/chunks/{chunk-2XKG3DX4.js → chunk-ETOEZTGL.js} +1 -1
  9. package/dist/chunks/{chunk-IT354SHV.js → chunk-FVPDVRJQ.js} +2 -2
  10. package/dist/chunks/{chunk-QULPY6YM.js → chunk-GG4BJMJW.js} +1 -1
  11. package/dist/chunks/{chunk-7HPVUVZB.js → chunk-HITD7CX6.js} +1 -1
  12. package/dist/chunks/{chunk-LIMZKONM.js → chunk-KK4GE65D.js} +2 -2
  13. package/dist/chunks/chunk-LAUYSGV4.js +3 -0
  14. package/dist/chunks/chunk-M6GDXKKS.js +2 -0
  15. package/dist/chunks/{chunk-QFULZNHL.js → chunk-PHHUHR7T.js} +1 -1
  16. package/dist/chunks/{chunk-ENL43FNO.js → chunk-WQPFDDIY.js} +2 -2
  17. package/dist/chunks/chunk-X2AWQSVS.js +2 -0
  18. package/dist/chunks/{chunk-ZRIM4R4A.js → chunk-ZRJQD7VS.js} +2 -2
  19. package/dist/data/grouping.d.ts +100 -0
  20. package/dist/data/grouping.js +264 -0
  21. package/dist/descriptive/basic.d.ts +130 -17
  22. package/dist/descriptive/basic.js +115 -14
  23. package/dist/descriptive/cov.d.ts +22 -12
  24. package/dist/descriptive/dataFrames.d.ts +138 -0
  25. package/dist/descriptive/dataFrames.js +400 -0
  26. package/dist/descriptive/factanal.d.ts +26 -6
  27. package/dist/descriptive/factanal.js +7 -3
  28. package/dist/descriptive/hist.d.ts +27 -6
  29. package/dist/descriptive/hist.js +9 -3
  30. package/dist/descriptive/missing.d.ts +42 -0
  31. package/dist/descriptive/missing.js +52 -0
  32. package/dist/descriptive/moments.d.ts +91 -13
  33. package/dist/descriptive/moments.js +66 -9
  34. package/dist/descriptive/omega.d.ts +28 -6
  35. package/dist/descriptive/omega.js +16 -4
  36. package/dist/descriptive/pivot.d.ts +105 -0
  37. package/dist/descriptive/pivot.js +347 -0
  38. package/dist/descriptive/quantile.d.ts +33 -5
  39. package/dist/descriptive/quantile.js +20 -2
  40. package/dist/descriptive/rank.d.ts +12 -2
  41. package/dist/descriptive/rank.js +2 -0
  42. package/dist/descriptive/table.d.ts +55 -7
  43. package/dist/descriptive/table.js +38 -4
  44. package/dist/descriptive.js +2 -2
  45. package/dist/distributions/arcsine.d.ts +40 -5
  46. package/dist/distributions/arcsine.js +35 -4
  47. package/dist/distributions/beta.d.ts +12 -0
  48. package/dist/distributions/beta.js +12 -0
  49. package/dist/distributions/binomial.d.ts +18 -0
  50. package/dist/distributions/binomial.js +18 -0
  51. package/dist/distributions/bvnorm.d.ts +4 -1
  52. package/dist/distributions/bvnorm.js +4 -1
  53. package/dist/distributions/cauchy.d.ts +24 -0
  54. package/dist/distributions/cauchy.js +24 -0
  55. package/dist/distributions/chisq.d.ts +18 -0
  56. package/dist/distributions/chisq.js +18 -0
  57. package/dist/distributions/exponential.d.ts +29 -1
  58. package/dist/distributions/exponential.js +24 -0
  59. package/dist/distributions/f.d.ts +18 -0
  60. package/dist/distributions/f.js +18 -0
  61. package/dist/distributions/gamma.d.ts +20 -0
  62. package/dist/distributions/gamma.js +18 -0
  63. package/dist/distributions/geometric.d.ts +24 -0
  64. package/dist/distributions/geometric.js +24 -0
  65. package/dist/distributions/hypergeometric.d.ts +24 -0
  66. package/dist/distributions/hypergeometric.js +24 -0
  67. package/dist/distributions/invgamma.d.ts +32 -4
  68. package/dist/distributions/invgamma.js +27 -3
  69. package/dist/distributions/kumaraswamy.d.ts +31 -3
  70. package/dist/distributions/kumaraswamy.js +31 -3
  71. package/dist/distributions/laplace.d.ts +36 -4
  72. package/dist/distributions/laplace.js +31 -3
  73. package/dist/distributions/logistic.d.ts +29 -1
  74. package/dist/distributions/logistic.js +24 -0
  75. package/dist/distributions/lognormal.d.ts +29 -1
  76. package/dist/distributions/lognormal.js +24 -0
  77. package/dist/distributions/multinomial.d.ts +7 -1
  78. package/dist/distributions/multinomial.js +2 -0
  79. package/dist/distributions/negbinomial.d.ts +29 -1
  80. package/dist/distributions/negbinomial.js +24 -0
  81. package/dist/distributions/normal.d.ts +11 -1
  82. package/dist/distributions/normal.js +6 -0
  83. package/dist/distributions/pareto.d.ts +36 -4
  84. package/dist/distributions/pareto.js +31 -3
  85. package/dist/distributions/poisson.d.ts +18 -0
  86. package/dist/distributions/poisson.js +18 -0
  87. package/dist/distributions/signrank.d.ts +24 -0
  88. package/dist/distributions/signrank.js +24 -0
  89. package/dist/distributions/summary.d.ts +20 -2
  90. package/dist/distributions/summary.js +4 -0
  91. package/dist/distributions/t.d.ts +18 -0
  92. package/dist/distributions/t.js +18 -0
  93. package/dist/distributions/triangular.d.ts +36 -4
  94. package/dist/distributions/triangular.js +31 -3
  95. package/dist/distributions/tukey.d.ts +15 -1
  96. package/dist/distributions/tukey.js +10 -0
  97. package/dist/distributions/uniform.d.ts +29 -1
  98. package/dist/distributions/uniform.js +24 -0
  99. package/dist/distributions/weibull.d.ts +29 -1
  100. package/dist/distributions/weibull.js +24 -0
  101. package/dist/distributions/wilcox.d.ts +24 -0
  102. package/dist/distributions/wilcox.js +24 -0
  103. package/dist/distributions.js +2 -2
  104. package/dist/entries/descriptive.d.ts +5 -1
  105. package/dist/entries/descriptive.js +4 -0
  106. package/dist/entries/numerics.d.ts +1 -1
  107. package/dist/entries/tests.js +1 -1
  108. package/dist/htest/agreement.d.ts +61 -23
  109. package/dist/htest/agreement.js +19 -9
  110. package/dist/htest/ansariTest.d.ts +19 -1
  111. package/dist/htest/ansariTest.js +5 -17
  112. package/dist/htest/aov.d.ts +43 -10
  113. package/dist/htest/aov.js +17 -3
  114. package/dist/htest/binomTest.d.ts +12 -2
  115. package/dist/htest/binomTest.js +2 -0
  116. package/dist/htest/brunnerMunzelTest.d.ts +9 -3
  117. package/dist/htest/brunnerMunzelTest.js +4 -2
  118. package/dist/htest/chisqTest.d.ts +19 -3
  119. package/dist/htest/cor.d.ts +31 -3
  120. package/dist/htest/cor.js +9 -27
  121. package/dist/htest/effectSize.d.ts +70 -12
  122. package/dist/htest/effectSize.js +40 -7
  123. package/dist/htest/fisherTest.d.ts +9 -1
  124. package/dist/htest/fisherTest.js +2 -0
  125. package/dist/htest/groups.d.ts +5 -1
  126. package/dist/htest/ksTest.d.ts +32 -2
  127. package/dist/htest/ksTest.js +5 -8
  128. package/dist/htest/leveneTest.d.ts +15 -4
  129. package/dist/htest/leveneTest.js +5 -2
  130. package/dist/htest/mantelhaenTest.d.ts +25 -3
  131. package/dist/htest/mantelhaenTest.js +15 -1
  132. package/dist/htest/mcnemarTest.d.ts +14 -4
  133. package/dist/htest/mcnemarTest.js +4 -2
  134. package/dist/htest/multipleComparisons.d.ts +173 -29
  135. package/dist/htest/multipleComparisons.js +123 -19
  136. package/dist/htest/normalityTests.d.ts +56 -9
  137. package/dist/htest/normalityTests.js +40 -6
  138. package/dist/htest/onewayTest.d.ts +45 -2
  139. package/dist/htest/onewayTest.js +15 -7
  140. package/dist/htest/pAdjust.d.ts +9 -1
  141. package/dist/htest/pAdjust.js +2 -0
  142. package/dist/htest/pairwise.d.ts +50 -5
  143. package/dist/htest/pairwise.js +25 -0
  144. package/dist/htest/poissonTest.d.ts +12 -2
  145. package/dist/htest/poissonTest.js +2 -0
  146. package/dist/htest/polycor.d.ts +29 -10
  147. package/dist/htest/power.d.ts +60 -6
  148. package/dist/htest/power.js +6 -0
  149. package/dist/htest/propTest.d.ts +13 -2
  150. package/dist/htest/propTest.js +2 -0
  151. package/dist/htest/pwr.d.ts +286 -36
  152. package/dist/htest/pwr.js +116 -15
  153. package/dist/htest/rankTests.d.ts +132 -7
  154. package/dist/htest/rankTests.js +30 -33
  155. package/dist/htest/tTest.d.ts +32 -2
  156. package/dist/htest/tTest.js +19 -24
  157. package/dist/htest/testFormula.d.ts +57 -0
  158. package/dist/htest/testFormula.js +171 -0
  159. package/dist/htest/trendTests.d.ts +29 -8
  160. package/dist/htest/trendTests.js +8 -4
  161. package/dist/htest/types.d.ts +14 -2
  162. package/dist/htest/varTest.d.ts +46 -6
  163. package/dist/htest/varTest.js +11 -21
  164. package/dist/htest/wilcoxTest.d.ts +23 -1
  165. package/dist/htest/wilcoxTest.js +9 -24
  166. package/dist/internal/dpq.d.ts +4 -0
  167. package/dist/internal/noncentral.d.ts +2 -0
  168. package/dist/internal/vectorize.d.ts +4 -0
  169. package/dist/linalg/basic.d.ts +39 -5
  170. package/dist/linalg/basic.js +15 -0
  171. package/dist/linalg/chol.d.ts +26 -5
  172. package/dist/linalg/chol.js +7 -0
  173. package/dist/linalg/eigen.d.ts +16 -7
  174. package/dist/linalg/eigen.js +6 -5
  175. package/dist/linalg/expm.d.ts +15 -5
  176. package/dist/linalg/expm.js +5 -3
  177. package/dist/linalg/kappa.d.ts +21 -1
  178. package/dist/linalg/kappa.js +16 -0
  179. package/dist/linalg/lu.d.ts +30 -6
  180. package/dist/linalg/lu.js +15 -3
  181. package/dist/linalg/matrix.d.ts +4 -0
  182. package/dist/linalg/norm.d.ts +16 -1
  183. package/dist/linalg/norm.js +9 -0
  184. package/dist/linalg/ops.d.ts +168 -36
  185. package/dist/linalg/ops.js +116 -20
  186. package/dist/linalg/qr.d.ts +87 -12
  187. package/dist/linalg/qr.js +31 -0
  188. package/dist/linalg/schur.d.ts +8 -2
  189. package/dist/linalg/schur.js +3 -1
  190. package/dist/linalg/solve.d.ts +42 -6
  191. package/dist/linalg/solve.js +22 -0
  192. package/dist/linalg/svd.d.ts +12 -2
  193. package/dist/linalg/svd.js +2 -0
  194. package/dist/linalg.js +2 -2
  195. package/dist/models/anovaSequential.d.ts +26 -4
  196. package/dist/models/anovaSequential.js +3 -1
  197. package/dist/models/aovEz.d.ts +29 -6
  198. package/dist/models/aovEz.js +5 -2
  199. package/dist/models/aovStrata.d.ts +12 -2
  200. package/dist/models/carAnova.d.ts +9 -3
  201. package/dist/models/carAnova.js +4 -2
  202. package/dist/models/coxph.d.ts +33 -7
  203. package/dist/models/coxph.js +8 -3
  204. package/dist/models/glm.d.ts +128 -21
  205. package/dist/models/glm.js +71 -14
  206. package/dist/models/glmAnova.d.ts +30 -5
  207. package/dist/models/glmAnova.js +15 -2
  208. package/dist/models/glmConfint.d.ts +16 -2
  209. package/dist/models/glmConfint.js +9 -1
  210. package/dist/models/glmFamily.d.ts +27 -5
  211. package/dist/models/lm.d.ts +75 -17
  212. package/dist/models/lm.js +22 -4
  213. package/dist/models/mauchly.d.ts +20 -5
  214. package/dist/models/mauchly.js +7 -3
  215. package/dist/models/modelFrame.d.ts +5 -1
  216. package/dist/models/modelMatrix.d.ts +18 -4
  217. package/dist/models/modelMatrix.js +3 -1
  218. package/dist/models/survival.d.ts +41 -9
  219. package/dist/models/survival.js +10 -4
  220. package/dist/numerics/deriv.d.ts +21 -6
  221. package/dist/numerics/deriv.js +16 -5
  222. package/dist/numerics/integrate.d.ts +37 -7
  223. package/dist/numerics/integrate.js +8 -2
  224. package/dist/numerics/interp.d.ts +63 -12
  225. package/dist/numerics/interp.js +30 -6
  226. package/dist/numerics/ode.d.ts +15 -5
  227. package/dist/numerics/ode.js +5 -3
  228. package/dist/numerics.js +2 -2
  229. package/dist/optim/optim.d.ts +32 -8
  230. package/dist/optim/optim.js +8 -4
  231. package/dist/random/beta.d.ts +8 -0
  232. package/dist/random/beta.js +8 -0
  233. package/dist/random/binomial.d.ts +16 -0
  234. package/dist/random/binomial.js +16 -0
  235. package/dist/random/continuous.d.ts +51 -0
  236. package/dist/random/continuous.js +51 -0
  237. package/dist/random/extra.d.ts +66 -6
  238. package/dist/random/extra.js +66 -6
  239. package/dist/random/gamma.d.ts +33 -0
  240. package/dist/random/gamma.js +33 -0
  241. package/dist/random/hyper.d.ts +8 -0
  242. package/dist/random/hyper.js +8 -0
  243. package/dist/random/poisson.d.ts +25 -0
  244. package/dist/random/poisson.js +25 -0
  245. package/dist/random/r2dtable.d.ts +2 -0
  246. package/dist/random/r2dtable.js +2 -0
  247. package/dist/random/rank.d.ts +16 -0
  248. package/dist/random/rank.js +16 -0
  249. package/dist/random/rng.d.ts +49 -6
  250. package/dist/random/rng.js +29 -2
  251. package/dist/random/sample.d.ts +10 -2
  252. package/dist/random/sample.js +5 -1
  253. package/dist/random/streams.d.ts +13 -0
  254. package/dist/random/streams.js +13 -0
  255. package/dist/rstats.js +14 -14
  256. package/dist/special/besselIK.d.ts +11 -3
  257. package/dist/special/besselIK.js +6 -2
  258. package/dist/special/besselJY.d.ts +6 -2
  259. package/dist/special/besselJY.js +6 -2
  260. package/dist/special/beta.d.ts +16 -2
  261. package/dist/special/beta.js +16 -2
  262. package/dist/special/choose.d.ts +13 -5
  263. package/dist/special/choose.js +13 -5
  264. package/dist/special/erf.d.ts +8 -3
  265. package/dist/special/erf.js +8 -3
  266. package/dist/special/extra.d.ts +30 -10
  267. package/dist/special/extra.js +25 -9
  268. package/dist/special/gamma.d.ts +18 -2
  269. package/dist/special/gamma.js +18 -2
  270. package/dist/special/log1p.d.ts +16 -7
  271. package/dist/special/log1p.js +16 -7
  272. package/dist/special/psigamma.d.ts +9 -3
  273. package/dist/special/psigamma.js +9 -3
  274. package/dist/special/rCompatible.d.ts +5 -1
  275. package/dist/special.js +2 -2
  276. package/dist/tests.js +12 -13
  277. package/llms.txt +14 -0
  278. package/package.json +1 -1
  279. package/dist/chunks/chunk-AECGWZHD.js +0 -2
  280. package/dist/chunks/chunk-XWTZ4RTR.js +0 -2
@@ -3,7 +3,11 @@ import { type LmFormulaOptions, type LmFormulaResult } from "../models/lm.js";
3
3
  import type { DataFrame } from "../models/modelFrame.js";
4
4
  import { type GroupLabel } from "./groups.js";
5
5
  import { type Alternative, type HTest, type Sample } from "./types.js";
6
- /** Result of {@link aov}: the one-way ANOVA table, rows "between groups" and "residuals". */
6
+ /**
7
+ * Result of {@link aov}: the one-way ANOVA table, rows "between groups" and "residuals".
8
+ *
9
+ * @category Linear models and ANOVA
10
+ */
7
11
  export interface AovResult {
8
12
  /** Degrees of freedom `[k - 1, N - k]`. */
9
13
  df: [number, number];
@@ -17,7 +21,8 @@ export interface AovResult {
17
21
  pValue: number;
18
22
  }
19
23
  /**
20
- * One-way analysis of variance. Equivalent to the table of R's `summary(aov(y ~ g))` for one factor.
24
+ * One-way analysis of variance. Equivalent to R's `aov()`. Gives the table of R's `summary(aov(y ~ g))` for one
25
+ * factor.
21
26
  *
22
27
  * @param x An array of samples (groups), or one sample with group labels `g`.
23
28
  * @param g Group labels, parallel to `x`.
@@ -25,13 +30,15 @@ export interface AovResult {
25
30
  * @example
26
31
  * ```ts
27
32
  * const r = aov([[2.9, 3.0, 2.5, 2.6, 3.2], [3.8, 2.7, 4.0, 2.4], [2.8, 3.4, 3.7, 2.2, 2.0]]);
28
- * r.fValue; // 0.5600732600732597
33
+ * r.fValue; // 0.56007326007326
29
34
  * r.pValue; // 0.586632991041738
30
35
  * ```
36
+ *
37
+ * @category Linear models and ANOVA
31
38
  */
32
39
  export declare function aov(x: Sample | readonly Sample[], g?: readonly GroupLabel[]): AovResult;
33
40
  /**
34
- * Analysis of variance from a model formula. Equivalent to R's `aov(formula, data)` (with `weights` and
41
+ * Analysis of variance from a model formula, as R's `aov(formula, data)` (with `weights` and
35
42
  * `contrasts`): the same fit as {@link lm} with a formula; {@link aovSummary} gives the table of R's
36
43
  * `summary(aov(...))`. With one `Error()` term (`y ~ W + Error(id/W)`) the fit has error strata: the result is an
37
44
  * {@link AovStrataFit} whose tables {@link aovSummary} returns, one per stratum.
@@ -46,12 +53,20 @@ export declare function aov(x: Sample | readonly Sample[], g?: readonly GroupLab
46
53
  * ```
47
54
  */
48
55
  export declare function aov(formula: string, data: DataFrame, options?: LmFormulaOptions): LmFormulaResult | AovStrataFit;
49
- /** Options for {@link TukeyHSD}. */
56
+ /**
57
+ * Options for {@link TukeyHSD}.
58
+ *
59
+ * @category Multiple comparisons
60
+ */
50
61
  export interface TukeyHSDOptions {
51
62
  /** Family-wise confidence level. Default `0.95`. */
52
63
  confLevel?: number;
53
64
  }
54
- /** Result of {@link TukeyHSD}: one entry per pair of groups, in R's order (2-1, 3-1, ..., k-1, 3-2, ...). */
65
+ /**
66
+ * Result of {@link TukeyHSD}: one entry per pair of groups, in R's order (2-1, 3-1, ..., k-1, 3-2, ...).
67
+ *
68
+ * @category Multiple comparisons
69
+ */
55
70
  export interface TukeyHSDResult {
56
71
  /**
57
72
  * Labels of the comparisons, `"a-b"`: the group labels when given, otherwise the positions of the samples in the
@@ -76,9 +91,25 @@ export interface TukeyHSDResult {
76
91
  * sizes). Equivalent to R's `TukeyHSD(aov(y ~ g))`.
77
92
  *
78
93
  * @param x An array of samples (groups), or one sample with group labels `g` (then `options` comes third).
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
98
+ * const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
99
+ * const r = TukeyHSD(x, g);
100
+ * r.names; // ["b-a", "c-a", "c-b"]
101
+ * r.diff; // [1.4333333333333336, 2.7666666666666666, 1.333333333333333]
102
+ * r.pAdj; // [0.03403130149294014, 0.001492661804896774, 0.04527523376597547]
103
+ * ```
104
+ *
105
+ * @category Multiple comparisons
79
106
  */
80
107
  export declare function TukeyHSD(x: Sample | readonly Sample[], g?: readonly GroupLabel[] | TukeyHSDOptions, options?: TukeyHSDOptions): TukeyHSDResult;
81
- /** Options for {@link zTest}. */
108
+ /**
109
+ * Options for {@link zTest}.
110
+ *
111
+ * @category Hypothesis tests
112
+ */
82
113
  export interface ZTestOptions {
83
114
  /** Known standard deviation of the population of `x` (required). */
84
115
  sigmaX?: number;
@@ -93,12 +124,14 @@ export interface ZTestOptions {
93
124
  }
94
125
  /**
95
126
  * z test for the mean of one sample, or the difference of the means of two, with known standard deviations.
96
- * Equivalent to `BSDA::z.test()` (the open end of a one-sided interval is ±Infinity here, NA in BSDA). `NaN` values
97
- * are dropped.
127
+ * Equivalent to `BSDA::z.test()` in R. The open end of a one-sided interval is ±Infinity here (NA in BSDA). `NaN`
128
+ * values are dropped.
98
129
  *
99
130
  * @example
100
131
  * ```ts
101
- * zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue;
132
+ * zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue; // 0.031823127386490346
102
133
  * ```
134
+ *
135
+ * @category Hypothesis tests
103
136
  */
104
137
  export declare function zTest(x: Sample, y?: Sample | ZTestOptions, options?: ZTestOptions): HTest;
package/dist/htest/aov.js CHANGED
@@ -78,6 +78,18 @@ function aovOneway(x, g) {
78
78
  * sizes). Equivalent to R's `TukeyHSD(aov(y ~ g))`.
79
79
  *
80
80
  * @param x An array of samples (groups), or one sample with group labels `g` (then `options` comes third).
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const x = [1.2, 2.3, 1.8, 2.9, 3.1, 3.6, 4.0, 4.4, 5.2];
85
+ * const g = ["a", "a", "a", "b", "b", "b", "c", "c", "c"];
86
+ * const r = TukeyHSD(x, g);
87
+ * r.names; // ["b-a", "c-a", "c-b"]
88
+ * r.diff; // [1.4333333333333336, 2.7666666666666666, 1.333333333333333]
89
+ * r.pAdj; // [0.03403130149294014, 0.001492661804896774, 0.04527523376597547]
90
+ * ```
91
+ *
92
+ * @category Multiple comparisons
81
93
  */
82
94
  export function TukeyHSD(x, g, options = {}) {
83
95
  let labels;
@@ -115,13 +127,15 @@ export function TukeyHSD(x, g, options = {}) {
115
127
  }
116
128
  /**
117
129
  * z test for the mean of one sample, or the difference of the means of two, with known standard deviations.
118
- * Equivalent to `BSDA::z.test()` (the open end of a one-sided interval is ±Infinity here, NA in BSDA). `NaN` values
119
- * are dropped.
130
+ * Equivalent to `BSDA::z.test()` in R. The open end of a one-sided interval is ±Infinity here (NA in BSDA). `NaN`
131
+ * values are dropped.
120
132
  *
121
133
  * @example
122
134
  * ```ts
123
- * zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue;
135
+ * zTest([5.1, 4.9, 5.6, 5.8, 6.0], { mu: 5, sigmaX: 0.5 }).pValue; // 0.031823127386490346
124
136
  * ```
137
+ *
138
+ * @category Hypothesis tests
125
139
  */
126
140
  export function zTest(x, y, options = {}) {
127
141
  let ys;
@@ -1,5 +1,9 @@
1
1
  import { type Alternative, type HTest } from "./types.js";
2
- /** Options for {@link binomTest}. */
2
+ /**
3
+ * Options for {@link binomTest}.
4
+ *
5
+ * @category Hypothesis tests
6
+ */
3
7
  export interface BinomTestOptions {
4
8
  /** Hypothesized probability of success. Default `0.5`. */
5
9
  p?: number;
@@ -8,7 +12,11 @@ export interface BinomTestOptions {
8
12
  /** Confidence level of the interval. Default `0.95`. */
9
13
  confLevel?: number;
10
14
  }
11
- /** Result of {@link binomTest}. */
15
+ /**
16
+ * Result of {@link binomTest}.
17
+ *
18
+ * @category Hypothesis tests
19
+ */
12
20
  export interface BinomTestResult extends HTest {
13
21
  /** Number of trials (`parameterName` is `"number of trials"`). */
14
22
  parameter: number;
@@ -32,5 +40,7 @@ export interface BinomTestResult extends HTest {
32
40
  * ```ts
33
41
  * binomTest(682, 925, { p: 0.75 }).pValue; // 0.3824916
34
42
  * ```
43
+ *
44
+ * @category Hypothesis tests
35
45
  */
36
46
  export declare function binomTest(x: number | readonly [number, number], n?: number | BinomTestOptions, options?: BinomTestOptions): BinomTestResult;
@@ -55,6 +55,8 @@ function twoSidedP(x, n, p) {
55
55
  * ```ts
56
56
  * binomTest(682, 925, { p: 0.75 }).pValue; // 0.3824916
57
57
  * ```
58
+ *
59
+ * @category Hypothesis tests
58
60
  */
59
61
  export function binomTest(x, n, options = {}) {
60
62
  let xs;
@@ -1,5 +1,9 @@
1
1
  import { type Alternative, type HTest, type Sample } from "./types.js";
2
- /** Options for {@link brunnerMunzelTest}. */
2
+ /**
3
+ * Options for {@link brunnerMunzelTest}.
4
+ *
5
+ * @category Hypothesis tests
6
+ */
3
7
  export interface BrunnerMunzelTestOptions {
4
8
  /**
5
9
  * Alternative hypothesis (unambiguous abbreviations accepted). Default `"two.sided"`. As in lawstat, `"greater"`
@@ -11,7 +15,7 @@ export interface BrunnerMunzelTestOptions {
11
15
  }
12
16
  /**
13
17
  * Brunner-Munzel test that two samples have the relative effect P(X < Y) + P(X = Y)/2 = 1/2, without assuming equal
14
- * variances or shapes. Equivalent to `lawstat::brunner.munzel.test()`. `NaN` values are dropped.
18
+ * variances or shapes. Equivalent to `lawstat::brunner.munzel.test()` in R. `NaN` values are dropped.
15
19
  *
16
20
  * `estimate` is the estimated relative effect and `confInt` its two-sided interval (not clipped to [0, 1]). When a
17
21
  * sample has one value, or when the variance estimates are 0 (for example completely separated samples), the
@@ -21,8 +25,10 @@ export interface BrunnerMunzelTestOptions {
21
25
  * ```ts
22
26
  * const r = brunnerMunzelTest([1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1], [3, 3, 4, 3, 1, 2, 3, 1, 1, 5, 4]);
23
27
  * r.statistic; // 3.1374674823029509
24
- * r.pValue; // 0.0057862086661515377
28
+ * r.pValue; // 0.0057862086661514605
25
29
  * r.estimate; // 0.78896103896103909
26
30
  * ```
31
+ *
32
+ * @category Hypothesis tests
27
33
  */
28
34
  export declare function brunnerMunzelTest(x: Sample, y: Sample, options?: BrunnerMunzelTestOptions): HTest;
@@ -16,7 +16,7 @@ import { rank } from "../internal/summary.js";
16
16
  import { checkConfLevel, matchAlternative } from "./types.js";
17
17
  /**
18
18
  * Brunner-Munzel test that two samples have the relative effect P(X < Y) + P(X = Y)/2 = 1/2, without assuming equal
19
- * variances or shapes. Equivalent to `lawstat::brunner.munzel.test()`. `NaN` values are dropped.
19
+ * variances or shapes. Equivalent to `lawstat::brunner.munzel.test()` in R. `NaN` values are dropped.
20
20
  *
21
21
  * `estimate` is the estimated relative effect and `confInt` its two-sided interval (not clipped to [0, 1]). When a
22
22
  * sample has one value, or when the variance estimates are 0 (for example completely separated samples), the
@@ -26,9 +26,11 @@ import { checkConfLevel, matchAlternative } from "./types.js";
26
26
  * ```ts
27
27
  * const r = brunnerMunzelTest([1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1], [3, 3, 4, 3, 1, 2, 3, 1, 1, 5, 4]);
28
28
  * r.statistic; // 3.1374674823029509
29
- * r.pValue; // 0.0057862086661515377
29
+ * r.pValue; // 0.0057862086661514605
30
30
  * r.estimate; // 0.78896103896103909
31
31
  * ```
32
+ *
33
+ * @category Hypothesis tests
32
34
  */
33
35
  export function brunnerMunzelTest(x, y, options = {}) {
34
36
  const xs = Array.from(x).filter((v) => !Number.isNaN(v));
@@ -1,5 +1,9 @@
1
1
  import type { HTest, Counts } from "./types.js";
2
- /** Options for {@link chisqTest}. */
2
+ /**
3
+ * Options for {@link chisqTest}.
4
+ *
5
+ * @category Hypothesis tests
6
+ */
3
7
  export interface ChisqTestOptions {
4
8
  /** Apply Yates' continuity correction (2 x 2 tables only). Default `true`. */
5
9
  correct?: boolean;
@@ -17,6 +21,8 @@ export interface ChisqTestOptions {
17
21
  }
18
22
  /**
19
23
  * Result of {@link chisqTest}. Has no `alternative`, because R's `chisq.test()` does not return one.
24
+ *
25
+ * @category Hypothesis tests
20
26
  */
21
27
  export interface ChisqTestResult extends Omit<HTest, "alternative"> {
22
28
  /** Degrees of freedom (`parameterName` is `"df"`). */
@@ -34,7 +40,11 @@ export interface ChisqTestResult extends Omit<HTest, "alternative"> {
34
40
  */
35
41
  stdres: number[] | number[][];
36
42
  }
37
- /** Result of {@link chisqTest} with two factor vectors: also the levels that label the rows and columns. */
43
+ /**
44
+ * Result of {@link chisqTest} with two factor vectors: also the levels that label the rows and columns.
45
+ *
46
+ * @category Hypothesis tests
47
+ */
38
48
  export interface ChisqTestFactorsResult extends ChisqTestResult {
39
49
  observed: number[][];
40
50
  expected: number[][];
@@ -45,7 +55,11 @@ export interface ChisqTestFactorsResult extends ChisqTestResult {
45
55
  /** Levels of `y` (columns of the table), sorted by code point. */
46
56
  colLevels: string[];
47
57
  }
48
- /** A factor: category labels, with `null` or `undefined` for missing values (R's NA). */
58
+ /**
59
+ * A factor: category labels, with `null` or `undefined` for missing values (R's NA).
60
+ *
61
+ * @category Hypothesis tests
62
+ */
49
63
  export type Factor = readonly (string | null | undefined)[];
50
64
  /**
51
65
  * Pearson's chi-squared test. Equivalent to R's `chisq.test()`.
@@ -82,6 +96,8 @@ export type Factor = readonly (string | null | undefined)[];
82
96
  *
83
97
  * chisqTest(["a", "b", "a", "b"], ["u", "u", "v", "v"]).rowLevels; // ["a", "b"]
84
98
  * ```
99
+ *
100
+ * @category Hypothesis tests
85
101
  */
86
102
  export declare function chisqTest(x: Counts | readonly Counts[], options?: ChisqTestOptions): ChisqTestResult;
87
103
  export declare function chisqTest(x: Factor, y: Factor, options?: ChisqTestOptions): ChisqTestFactorsResult;
@@ -1,13 +1,26 @@
1
1
  import { type DD } from "../special/dd.js";
2
+ import type { DataFrame } from "../models/modelFrame.js";
2
3
  import { type Alternative, type HTest, type Sample } from "./types.js";
3
- /** Correlation coefficient: Pearson's r, Kendall's tau or Spearman's rho. */
4
+ /**
5
+ * Correlation coefficient: Pearson's r, Kendall's tau or Spearman's rho.
6
+ *
7
+ * @category Descriptive statistics
8
+ */
4
9
  export type CorMethod = "pearson" | "kendall" | "spearman";
5
- /** Options for {@link cor}. */
10
+ /**
11
+ * Options for {@link cor}.
12
+ *
13
+ * @category Hypothesis tests
14
+ */
6
15
  export interface CorOptions {
7
16
  /** Correlation coefficient to compute. Default `"pearson"`. Unambiguous abbreviations are accepted. */
8
17
  method?: CorMethod | (string & {});
9
18
  }
10
- /** Options for {@link corTest}. */
19
+ /**
20
+ * Options for {@link corTest}.
21
+ *
22
+ * @category Hypothesis tests
23
+ */
11
24
  export interface CorTestOptions extends CorOptions {
12
25
  /**
13
26
  * Alternative hypothesis: `"two.sided"`, `"less"` or `"greater"`. Default `"two.sided"`.
@@ -28,6 +41,8 @@ export interface CorTestOptions extends CorOptions {
28
41
  /**
29
42
  * Result of {@link corTest}. For Pearson, `statisticName` is `"t"` with `parameter` (df)
30
43
  * and `confInt`; for Kendall `"T"` (exact) or `"z"`; for Spearman `"S"`.
44
+ *
45
+ * @category Hypothesis tests
31
46
  */
32
47
  export interface CorTestResult extends HTest {
33
48
  /** Sample correlation coefficient. */
@@ -90,6 +105,19 @@ export declare function kendall(x: readonly number[], y: readonly number[]): Ken
90
105
  *
91
106
  * corTest([1, 2, 3, 4, 5, 6], [2, 1, 4, 3, 7, 8], { method: "spearman" });
92
107
  * ```
108
+ *
109
+ * There is also a formula form, `corTest("~ x + y", data, options)` (next overload).
110
+ *
111
+ * @category Hypothesis tests
93
112
  */
94
113
  export declare function corTest(x: Sample, y: Sample, options?: CorTestOptions): CorTestResult;
114
+ /**
115
+ * Test for correlation from a formula and a data frame. As R's `cor.test(formula, data)`: the one-sided
116
+ * formula `"~ x + y"` names the two variables. Only they count: the rows where one of them is missing are dropped.
117
+ *
118
+ * @param formula `"~ x + y"` (exactly two variables, no response).
119
+ * @param data The data frame: an object of columns (`null` or `NaN` for a missing value).
120
+ * @param options See {@link CorTestOptions}.
121
+ */
122
+ export declare function corTest(formula: string, data: DataFrame, options?: CorTestOptions): CorTestResult;
95
123
  export {};
package/dist/htest/cor.js CHANGED
@@ -27,6 +27,7 @@ import { pt1 } from "../distributions/t.js";
27
27
  import { pnorm, qnorm } from "../distributions/normal.js";
28
28
  import { ddAdd, ddDiv, ddMul, ddSub, twoProd, twoSum } from "../special/dd.js";
29
29
  import { completePairs, meanDD, rank, tieCounts } from "../internal/summary.js";
30
+ import { correlationData } from "./testFormula.js";
30
31
  import { checkConfLevel, matchAlternative } from "./types.js";
31
32
  const METHODS = ["pearson", "kendall", "spearman"];
32
33
  function matchMethod(m) {
@@ -284,34 +285,15 @@ function spearmanTail(n, q, lower) {
284
285
  return 0;
285
286
  return spearmanEdgeworth(n, q, false);
286
287
  }
287
- // ---- cor.test ----
288
- /**
289
- * Test for correlation between paired samples. Equivalent to R's `cor.test()`.
290
- *
291
- * Supports Pearson's product-moment correlation (t test, with a Fisher-z confidence
292
- * interval), Kendall's tau and Spearman's rho (exact or approximate p-values, chosen by
293
- * the same rules as R). Pairs containing `NaN` are dropped; Pearson needs at least 3
294
- * pairs and the others at least 2. If the correlation is undefined (constant data) the
295
- * statistic, p-value and estimate are `NaN`. Correlations are computed in double-double
296
- * arithmetic, so results can differ from R's when r is very close to ±1, where R's own
297
- * value is less accurate.
298
- *
299
- * @param x First sample.
300
- * @param y Second sample, of the same length as `x`.
301
- * @param options See {@link CorTestOptions}.
302
- * @returns The test result; see {@link CorTestResult}.
303
- *
304
- * @example
305
- * ```ts
306
- * const r = corTest([1, 2, 3, 4, 5, 6], [2, 1, 4, 3, 7, 8]);
307
- * r.estimate; // 0.9014600868406593
308
- * r.statistic; // 4.165113148435108 (t, df = 4)
309
- * r.pValue; // 0.01408675480909387
310
- *
311
- * corTest([1, 2, 3, 4, 5, 6], [2, 1, 4, 3, 7, 8], { method: "spearman" });
312
- * ```
313
- */
314
288
  export function corTest(x, y, options = {}) {
289
+ if (typeof x === "string") {
290
+ const d = correlationData(x, y);
291
+ return corTest(d.x, d.y, options);
292
+ }
293
+ return corTestSamples(x, y, options);
294
+ }
295
+ /** cor.test's default form */
296
+ function corTestSamples(x, y, options) {
315
297
  if (x.length !== y.length)
316
298
  throw new TypeError("x and y must have the same length");
317
299
  const alternative = matchAlternative(options.alternative);
@@ -3,7 +3,11 @@ import type { AovEzResult } from "../models/aovEz.js";
3
3
  import type { AovStrataFit } from "../models/aovStrata.js";
4
4
  import type { LmFormulaResult } from "../models/lm.js";
5
5
  import type { Alternative, Sample } from "./types.js";
6
- /** Options for {@link cohensD} and {@link hedgesG}. */
6
+ /**
7
+ * Options for {@link cohensD} and {@link hedgesG}.
8
+ *
9
+ * @category Effect sizes and power
10
+ */
7
11
  export interface CohensDOptions {
8
12
  /** Two samples: standardize by the pooled standard deviation (default `true`) or by `sqrt((s1² + s2²)/2)`. */
9
13
  pooledSd?: boolean;
@@ -18,35 +22,55 @@ export interface CohensDOptions {
18
22
  /** {@link cohensD} only: apply Hedges' small-sample correction (the result is Hedges' g). Default `false`. */
19
23
  adjust?: boolean;
20
24
  }
21
- /** Result of {@link cohensD} and {@link hedgesG}. */
25
+ /**
26
+ * Result of {@link cohensD} and {@link hedgesG}.
27
+ *
28
+ * @category Effect sizes and power
29
+ */
22
30
  export interface CohensDResult {
23
31
  /** `"Cohens_d"` or `"Hedges_g"`. */
24
32
  name: "Cohens_d" | "Hedges_g";
33
+ /** The effect size. */
25
34
  value: number;
26
35
  /** Confidence level (absent without an interval). */
27
36
  ci?: number;
37
+ /** Lower confidence limit (R's `CI_low`; `-Infinity` for `"less"`). */
28
38
  ciLow?: number;
39
+ /** Upper confidence limit (R's `CI_high`; `Infinity` for `"greater"`). */
29
40
  ciHigh?: number;
30
41
  /** effectsize's warnings. */
31
42
  warnings: string[];
32
43
  }
33
44
  /**
34
45
  * Cohen's d: the standardized difference of means of two samples (pooled or averaged standard deviation), of paired
35
- * samples, or of one sample against `mu`, with a confidence interval from the noncentral t distribution. Equivalent
36
- * to effectsize's `cohens_d()`.
46
+ * samples, or of one sample against `mu`, with a confidence interval from the noncentral t distribution.
47
+ * Equivalent to `effectsize::cohens_d()` in R.
37
48
  *
38
49
  * @example
39
50
  * ```ts
40
51
  * cohensD([5.1, 4.9, 6.2, 5.8], [4.1, 4.5, 3.9, 5.0]).value; // 2.049693834034246
41
52
  * ```
53
+ *
54
+ * @category Effect sizes and power
42
55
  */
43
56
  export declare function cohensD(x: Sample, y?: Sample, options?: CohensDOptions): CohensDResult;
44
57
  /**
45
- * Hedges' g: Cohen's d and its interval multiplied by the small-sample correction J(df). Equivalent to effectsize's
46
- * `hedges_g()`.
58
+ * Hedges' g: Cohen's d and its interval multiplied by the small-sample correction J(df). Equivalent to
59
+ * `effectsize::hedges_g()` in R.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * hedgesG([5.1, 4.9, 6.2, 5.8], [4.1, 4.5, 3.9, 5.0]).value; // 1.7804187661174387
64
+ * ```
65
+ *
66
+ * @category Effect sizes and power
47
67
  */
48
68
  export declare function hedgesG(x: Sample, y?: Sample, options?: Omit<CohensDOptions, "adjust">): CohensDResult;
49
- /** Options for {@link etaSquared}, {@link omegaSquared} and {@link epsilonSquared}. */
69
+ /**
70
+ * Options for {@link etaSquared}, {@link omegaSquared} and {@link epsilonSquared}.
71
+ *
72
+ * @category Effect sizes and power
73
+ */
50
74
  export interface AnovaEffectSizeOptions {
51
75
  /**
52
76
  * Partial effect sizes (default `true`). A table with a single term always gives the non-partial one (not so for
@@ -58,7 +82,11 @@ export interface AnovaEffectSizeOptions {
58
82
  /** `"greater"` (default: the interval is [lower, 1]), `"two.sided"` or `"less"` ([0, upper]). */
59
83
  alternative?: Alternative | (string & {});
60
84
  }
61
- /** Options for {@link etaSquared}. */
85
+ /**
86
+ * Options for {@link etaSquared}.
87
+ *
88
+ * @category Effect sizes and power
89
+ */
62
90
  export interface EtaSquaredOptions extends AnovaEffectSizeOptions {
63
91
  /**
64
92
  * Generalized eta squared: `true` (all factors manipulated) or the names of the observed factors. Default
@@ -66,7 +94,11 @@ export interface EtaSquaredOptions extends AnovaEffectSizeOptions {
66
94
  */
67
95
  generalized?: boolean | readonly string[];
68
96
  }
69
- /** Result of the ANOVA effect sizes: one row per term. */
97
+ /**
98
+ * Result of the ANOVA effect sizes: one row per term.
99
+ *
100
+ * @category Effect sizes and power
101
+ */
70
102
  export interface AnovaEffectSizeTable {
71
103
  /** effectsize's columns: the effect size (`"Eta2_partial"`, `"Omega2"`, ...), then `"CI"`, `"CI_low"`, `"CI_high"`. */
72
104
  colNames: string[];
@@ -82,11 +114,13 @@ export interface AnovaEffectSizeTable {
82
114
  /**
83
115
  * A model of the ANOVA effect sizes: a table of `anova()` or `Anova()`, a fit from `lm()` or `aov()` (also with
84
116
  * `Error()`), the `aovSummary()` of an `aov()` fit with `Error()`, or a result of `aovEz()`.
117
+ *
118
+ * @category Effect sizes and power
85
119
  */
86
120
  export type AnovaEffectSizeModel = AnovaTable | LmFormulaResult | AovStrataFit | AovStrataSummary | AovEzResult;
87
121
  /**
88
122
  * Eta squared of the terms of an analysis-of-variance table (partial by default, or generalized), with confidence
89
- * intervals from the noncentral F distribution. Equivalent to effectsize's `eta_squared()` for a table of
123
+ * intervals from the noncentral F distribution. Equivalent to `effectsize::eta_squared()` in R. It takes a table of
90
124
  * `anova()` or `Anova()`; a fit from `lm()` with a formula is replaced by its `anova()` table.
91
125
  *
92
126
  * Repeated measures: for a fit of `aov()` with an `Error()` term (or its {@link aovSummary}) each term is measured
@@ -95,18 +129,42 @@ export type AnovaEffectSizeModel = AnovaTable | LmFormulaResult | AovStrataFit |
95
129
  *
96
130
  * @example
97
131
  * ```ts
132
+ * const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
98
133
  * etaSquared(anova(lm("y ~ g", data))).colNames; // ["Eta2", "CI", "CI_low", "CI_high"]
134
+ * const long = {
135
+ * y: [5, 7, 8, 4, 6, 9, 6, 8, 8, 5, 5, 7],
136
+ * W: ["a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"],
137
+ * id: ["s1", "s1", "s1", "s2", "s2", "s2", "s3", "s3", "s3", "s4", "s4", "s4"],
138
+ * };
99
139
  * etaSquared(aov("y ~ W + Error(id/W)", long)).groups; // ["id:W"]
100
140
  * ```
141
+ *
142
+ * @category Effect sizes and power
101
143
  */
102
144
  export declare function etaSquared(model: AnovaEffectSizeModel, options?: EtaSquaredOptions): AnovaEffectSizeTable;
103
145
  /**
104
146
  * Omega squared of the terms of an analysis-of-variance table, also of repeated-measures designs (see
105
- * {@link etaSquared}). Equivalent to effectsize's `omega_squared()`.
147
+ * {@link etaSquared}). Equivalent to `effectsize::omega_squared()` in R.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
152
+ * omegaSquared(anova(lm("y ~ g", data))).table; // [[0.8740518865645682, 0.95, 0.0566677410780818, 1]]
153
+ * ```
154
+ *
155
+ * @category Effect sizes and power
106
156
  */
107
157
  export declare function omegaSquared(model: AnovaEffectSizeModel, options?: AnovaEffectSizeOptions): AnovaEffectSizeTable;
108
158
  /**
109
159
  * Epsilon squared of the terms of an analysis-of-variance table, also of repeated-measures designs (see
110
- * {@link etaSquared}). Equivalent to effectsize's `epsilon_squared()`.
160
+ * {@link etaSquared}). Equivalent to `effectsize::epsilon_squared()` in R.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
165
+ * epsilonSquared(anova(lm("y ~ g", data))).table; // [[0.8927928150213428, 0.95, 0.1720126241673212, 1]]
166
+ * ```
167
+ *
168
+ * @category Effect sizes and power
111
169
  */
112
170
  export declare function epsilonSquared(model: AnovaEffectSizeModel, options?: AnovaEffectSizeOptions): AnovaEffectSizeTable;
@@ -93,20 +93,29 @@ function standardizedDifference(x, y, options, adjust) {
93
93
  }
94
94
  /**
95
95
  * Cohen's d: the standardized difference of means of two samples (pooled or averaged standard deviation), of paired
96
- * samples, or of one sample against `mu`, with a confidence interval from the noncentral t distribution. Equivalent
97
- * to effectsize's `cohens_d()`.
96
+ * samples, or of one sample against `mu`, with a confidence interval from the noncentral t distribution.
97
+ * Equivalent to `effectsize::cohens_d()` in R.
98
98
  *
99
99
  * @example
100
100
  * ```ts
101
101
  * cohensD([5.1, 4.9, 6.2, 5.8], [4.1, 4.5, 3.9, 5.0]).value; // 2.049693834034246
102
102
  * ```
103
+ *
104
+ * @category Effect sizes and power
103
105
  */
104
106
  export function cohensD(x, y, options = {}) {
105
107
  return standardizedDifference(x, y, options, options.adjust ?? false);
106
108
  }
107
109
  /**
108
- * Hedges' g: Cohen's d and its interval multiplied by the small-sample correction J(df). Equivalent to effectsize's
109
- * `hedges_g()`.
110
+ * Hedges' g: Cohen's d and its interval multiplied by the small-sample correction J(df). Equivalent to
111
+ * `effectsize::hedges_g()` in R.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * hedgesG([5.1, 4.9, 6.2, 5.8], [4.1, 4.5, 3.9, 5.0]).value; // 1.7804187661174387
116
+ * ```
117
+ *
118
+ * @category Effect sizes and power
110
119
  */
111
120
  export function hedgesG(x, y, options = {}) {
112
121
  return standardizedDifference(x, y, options, true);
@@ -353,7 +362,7 @@ function strataEffectSize(model, kind, options) {
353
362
  }
354
363
  /**
355
364
  * Eta squared of the terms of an analysis-of-variance table (partial by default, or generalized), with confidence
356
- * intervals from the noncentral F distribution. Equivalent to effectsize's `eta_squared()` for a table of
365
+ * intervals from the noncentral F distribution. Equivalent to `effectsize::eta_squared()` in R. It takes a table of
357
366
  * `anova()` or `Anova()`; a fit from `lm()` with a formula is replaced by its `anova()` table.
358
367
  *
359
368
  * Repeated measures: for a fit of `aov()` with an `Error()` term (or its {@link aovSummary}) each term is measured
@@ -362,23 +371,47 @@ function strataEffectSize(model, kind, options) {
362
371
  *
363
372
  * @example
364
373
  * ```ts
374
+ * const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
365
375
  * etaSquared(anova(lm("y ~ g", data))).colNames; // ["Eta2", "CI", "CI_low", "CI_high"]
376
+ * const long = {
377
+ * y: [5, 7, 8, 4, 6, 9, 6, 8, 8, 5, 5, 7],
378
+ * W: ["a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"],
379
+ * id: ["s1", "s1", "s1", "s2", "s2", "s2", "s3", "s3", "s3", "s4", "s4", "s4"],
380
+ * };
366
381
  * etaSquared(aov("y ~ W + Error(id/W)", long)).groups; // ["id:W"]
367
382
  * ```
383
+ *
384
+ * @category Effect sizes and power
368
385
  */
369
386
  export function etaSquared(model, options = {}) {
370
387
  return anovaEffectSize(model, "Eta2", options);
371
388
  }
372
389
  /**
373
390
  * Omega squared of the terms of an analysis-of-variance table, also of repeated-measures designs (see
374
- * {@link etaSquared}). Equivalent to effectsize's `omega_squared()`.
391
+ * {@link etaSquared}). Equivalent to `effectsize::omega_squared()` in R.
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
396
+ * omegaSquared(anova(lm("y ~ g", data))).table; // [[0.8740518865645682, 0.95, 0.0566677410780818, 1]]
397
+ * ```
398
+ *
399
+ * @category Effect sizes and power
375
400
  */
376
401
  export function omegaSquared(model, options = {}) {
377
402
  return anovaEffectSize(model, "Omega2", options);
378
403
  }
379
404
  /**
380
405
  * Epsilon squared of the terms of an analysis-of-variance table, also of repeated-measures designs (see
381
- * {@link etaSquared}). Equivalent to effectsize's `epsilon_squared()`.
406
+ * {@link etaSquared}). Equivalent to `effectsize::epsilon_squared()` in R.
407
+ *
408
+ * @example
409
+ * ```ts
410
+ * const data = { y: [2.1, 3.9, 6.2, 7.8, 10.1, 11.8], g: ["a", "a", "b", "b", "c", "c"] };
411
+ * epsilonSquared(anova(lm("y ~ g", data))).table; // [[0.8927928150213428, 0.95, 0.1720126241673212, 1]]
412
+ * ```
413
+ *
414
+ * @category Effect sizes and power
382
415
  */
383
416
  export function epsilonSquared(model, options = {}) {
384
417
  return anovaEffectSize(model, "Epsilon2", options);