@numero-uno-jpn/rstats 0.8.0 → 0.10.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.
- package/CHANGELOG.md +88 -0
- package/README.ja.md +89 -13
- package/README.md +90 -13
- package/THIRD_PARTY_NOTICES.md +12 -2
- package/dist/chunks/{chunk-OHPHNE3O.js → chunk-2XKG3DX4.js} +1 -1
- package/dist/chunks/{chunk-3I6EKGB6.js → chunk-4NM37MGA.js} +2 -2
- package/dist/chunks/chunk-7HPVUVZB.js +2 -0
- package/dist/chunks/{chunk-I3LAZE6C.js → chunk-AECGWZHD.js} +2 -2
- package/dist/chunks/chunk-ENL43FNO.js +2 -0
- package/dist/chunks/chunk-EWC6I75B.js +2 -0
- package/dist/chunks/chunk-IT354SHV.js +3 -0
- package/dist/chunks/{chunk-VIPSPG3Y.js → chunk-LIMZKONM.js} +2 -2
- package/dist/chunks/chunk-O6PT7IVU.js +2 -0
- package/dist/chunks/{chunk-YGWPU67I.js → chunk-QFULZNHL.js} +1 -1
- package/dist/chunks/{chunk-XU4BGFZ6.js → chunk-QJJWGNJP.js} +2 -2
- package/dist/chunks/{chunk-32PRRONF.js → chunk-QULPY6YM.js} +1 -1
- package/dist/chunks/chunk-XWTZ4RTR.js +2 -0
- package/dist/chunks/chunk-ZRIM4R4A.js +2 -0
- package/dist/descriptive/factanal.d.ts +56 -0
- package/dist/descriptive/factanal.js +186 -0
- package/dist/descriptive/omega.d.ts +56 -0
- package/dist/descriptive/omega.js +323 -0
- package/dist/descriptive.js +2 -2
- package/dist/distributions/bvnorm.d.ts +15 -0
- package/dist/distributions/bvnorm.js +131 -0
- package/dist/distributions/nbeta.js +34 -1
- package/dist/distributions/nchisq.d.ts +10 -0
- package/dist/distributions/nchisq.js +46 -0
- package/dist/distributions.js +2 -2
- package/dist/entries/distributions.d.ts +1 -0
- package/dist/entries/distributions.js +1 -0
- package/dist/entries/linalg.d.ts +2 -0
- package/dist/entries/linalg.js +2 -0
- package/dist/entries/numerics.d.ts +2 -0
- package/dist/entries/numerics.js +1 -0
- package/dist/entries/tests.d.ts +25 -1
- package/dist/entries/tests.js +22 -1
- package/dist/htest/agreement.d.ts +141 -0
- package/dist/htest/agreement.js +274 -0
- package/dist/htest/aov.d.ts +19 -0
- package/dist/htest/aov.js +22 -15
- package/dist/htest/core/simulate.d.ts +2 -0
- package/dist/htest/core/simulate.js +1 -1
- package/dist/htest/dunnett.d.ts +5 -0
- package/dist/htest/dunnett.js +89 -0
- package/dist/htest/effectSize.d.ts +112 -0
- package/dist/htest/effectSize.js +385 -0
- package/dist/htest/leveneTest.d.ts +30 -0
- package/dist/htest/leveneTest.js +41 -0
- package/dist/htest/multipleComparisons.d.ts +147 -0
- package/dist/htest/multipleComparisons.js +369 -0
- package/dist/htest/normalityTests.d.ts +44 -0
- package/dist/htest/normalityTests.js +164 -0
- package/dist/htest/polycor.d.ts +117 -0
- package/dist/htest/polycor.js +468 -0
- package/dist/htest/power.d.ts +132 -0
- package/dist/htest/power.js +227 -0
- package/dist/htest/pwr.d.ts +263 -0
- package/dist/htest/pwr.js +440 -0
- package/dist/htest/rankTests.d.ts +7 -0
- package/dist/htest/rankTests.js +11 -1
- package/dist/htest/trendTests.d.ts +57 -0
- package/dist/htest/trendTests.js +167 -0
- package/dist/linalg/eigen.d.ts +8 -0
- package/dist/linalg/eigen.js +5 -4
- package/dist/linalg/expm.d.ts +48 -0
- package/dist/linalg/expm.js +472 -0
- package/dist/linalg/schur.d.ts +48 -0
- package/dist/linalg/schur.js +225 -0
- package/dist/linalg.js +2 -2
- package/dist/models/anovaSequential.d.ts +58 -0
- package/dist/models/anovaSequential.js +138 -0
- package/dist/models/aovEz.d.ts +64 -0
- package/dist/models/aovEz.js +332 -0
- package/dist/models/aovStrata.d.ts +32 -0
- package/dist/models/aovStrata.js +104 -0
- package/dist/models/carAnova.d.ts +30 -0
- package/dist/models/carAnova.js +121 -0
- package/dist/models/coxph.d.ts +101 -0
- package/dist/models/coxph.js +502 -0
- package/dist/models/ddLeastSquares.d.ts +30 -0
- package/dist/models/ddLeastSquares.js +90 -0
- package/dist/models/ddMatrix.d.ts +10 -0
- package/dist/models/ddMatrix.js +91 -0
- package/dist/models/formula.d.ts +83 -0
- package/dist/models/formula.js +333 -0
- package/dist/models/glm.d.ts +226 -0
- package/dist/models/glm.js +546 -0
- package/dist/models/glmAnova.d.ts +31 -0
- package/dist/models/glmAnova.js +146 -0
- package/dist/models/glmConfint.d.ts +25 -0
- package/dist/models/glmConfint.js +139 -0
- package/dist/models/glmFamily.d.ts +66 -0
- package/dist/models/glmFamily.js +359 -0
- package/dist/models/lm.d.ts +84 -3
- package/dist/models/lm.js +141 -44
- package/dist/models/mauchly.d.ts +48 -0
- package/dist/models/mauchly.js +123 -0
- package/dist/models/modelFrame.d.ts +40 -0
- package/dist/models/modelFrame.js +131 -0
- package/dist/models/modelMatrix.d.ts +88 -0
- package/dist/models/modelMatrix.js +170 -0
- package/dist/models/survival.d.ts +87 -0
- package/dist/models/survival.js +238 -0
- package/dist/numerics.js +2 -2
- package/dist/optim/lbfgsb.d.ts +20 -0
- package/dist/optim/lbfgsb.js +1240 -0
- package/dist/optim/optim.d.ts +85 -0
- package/dist/optim/optim.js +610 -0
- package/dist/rstats.js +19 -3
- package/dist/special.js +2 -2
- package/dist/tests.js +18 -3
- package/llms.txt +102 -0
- package/package.json +3 -2
- package/dist/chunks/chunk-EJRCDJ76.js +0 -2
- package/dist/chunks/chunk-JERGQKZM.js +0 -2
- package/dist/chunks/chunk-JVYV4633.js +0 -2
- package/dist/chunks/chunk-LXMMKO26.js +0 -2
- package/dist/chunks/chunk-MJQLKEO5.js +0 -2
- package/dist/chunks/chunk-RZ7SBJEG.js +0 -2
- package/dist/chunks/chunk-SPQC445Q.js +0 -2
- package/dist/chunks/chunk-U633VFH3.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,94 @@ While the version is 0.x, a minor release (0.y.0) may contain breaking changes;
|
|
|
7
7
|
they are listed under **Breaking** for each release. From 1.0.0 the project follows
|
|
8
8
|
[Semantic Versioning](https://semver.org/).
|
|
9
9
|
|
|
10
|
+
## 0.10.0 - 2026-10-26
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Model formulas: `lm(formula, data)` and `aov(formula, data)` take an R formula string and a data frame (an
|
|
15
|
+
object of columns; strings and booleans are factors), besides the existing matrix and group forms. Formulas
|
|
16
|
+
support `+`, `-`, `*`, `/`, `:`, `%in%`, `^`, `.`, `0`/`1` and parentheses, with R's term order, labels and
|
|
17
|
+
coding (contrasts or indicators by R's rule, the first factor coded by indicators without an intercept), the
|
|
18
|
+
contrasts `contr.treatment`, `contr.sum` and `contr.helmert`, a `levels` option and weights. `modelMatrix`
|
|
19
|
+
returns R's `model.matrix` with the attributes of `terms()`.
|
|
20
|
+
- `anova` (`anova.lm`): the sequential table of a fit and the comparison of several fits; `aovSummary`
|
|
21
|
+
(`summary(aov(...))`).
|
|
22
|
+
- `aov` with an `Error()` term: the error strata and their tables, as R's multistratum `aov`.
|
|
23
|
+
- `Anova` (`car::Anova` for linear models): type II and type III tests.
|
|
24
|
+
- `aovEz` (`afex::aov_ez`): repeated-measures, between-subjects and mixed designs from long data, with car's
|
|
25
|
+
univariate tests, the Greenhouse-Geisser and Huynh-Feldt corrections, Mauchly's tests, generalized and partial
|
|
26
|
+
eta squared (`es`, `observed`), types II and III, and afex's aggregation and checks.
|
|
27
|
+
- `mauchlyTest` (`mauchly.test`) for the responses of several measurements per subject, with `group`, `M`, `X`
|
|
28
|
+
and `idata`.
|
|
29
|
+
- The fits are computed in double-double where R's QR decomposition loses digits (a mean of 1e6: R's
|
|
30
|
+
coefficients are off by up to 1.5e-11); every table agrees with R to 1e-12 or with exact rational values.
|
|
31
|
+
- Effect sizes (effectsize): `cohensD` and `hedgesG` (one sample, two samples pooled or not, paired), and
|
|
32
|
+
`etaSquared` (partial, non-partial, generalized), `omegaSquared` and `epsilonSquared` of `anova` and `Anova`
|
|
33
|
+
tables, with confidence intervals. The limits are the exact solutions; effectsize's optimiser leaves them about
|
|
34
|
+
1e-9 (up to 3e-3) off.
|
|
35
|
+
- Power calculations: `powerTTest`, `powerPropTest`, `powerAnovaTest` (R's `power.*.test`) and pwr's `pwrTTest`,
|
|
36
|
+
`pwrT2nTest`, `pwr2pTest`, `pwr2p2nTest`, `pwrPTest`, `pwrNormTest`, `pwrRTest`, `pwrChisqTest`, `pwrAnovaTest`,
|
|
37
|
+
`pwrF2Test` with `esH`, `esW1`, `esW2` and `cohenES`. Give the quantity to solve for as `null`; it is found with R's
|
|
38
|
+
own `uniroot` calls, with accurate noncentral distributions (R's noncentral t and F are not: computed powers
|
|
39
|
+
differ from R's by up to 3e-8).
|
|
40
|
+
|
|
41
|
+
- More tests: `leveneTest` (car), `propTrendTest` (`prop.trend.test`), `jonckheereTest` (DescTools' and clinfun's
|
|
42
|
+
variants), `cochranQTest` (DescTools), and nortest's `adTest`, `lillieTest`, `cvmTest`, `sfTest`, `pearsonTest`.
|
|
43
|
+
- Effect sizes of repeated-measures designs: `etaSquared`, `omegaSquared`, `epsilonSquared` of `aov` fits with
|
|
44
|
+
`Error()` and of `aovEz` results, with exact intervals.
|
|
45
|
+
- Multiple comparisons: PMCMRplus's `dscfAllPairsTest` (Steel-Dwass), `kwAllPairsDunnTest`, `kwManyOneDunnTest`, `manyOneUTest` (Steel's many-one rank test),
|
|
46
|
+
`dunnettTest`, `gamesHowellTest`, `tukeyTest` and `steelTest` (its errors); dunn.test's `dunnTest`; multcomp's
|
|
47
|
+
Dunnett comparisons (`glhtDunnett`). Dunnett-type probabilities are computed exactly by a one-dimensional integral
|
|
48
|
+
(R's mvtnorm integration is randomised and about 1e-3 accurate); studentized-range p-values are R's to full
|
|
49
|
+
precision (R's `ptukey` has about 8 digits).
|
|
50
|
+
- Survival analysis: `survdiff` (log-rank, G-rho family) and `survfit` (Kaplan-Meier with its intervals and median).
|
|
51
|
+
- `coxph` (Cox regression, survival's `coxph` for right-censored data with a covariate matrix): Efron and Breslow
|
|
52
|
+
ties, case weights, strata, starting values, R's Newton-Raphson iterations and warnings, and the summary's
|
|
53
|
+
coefficient table, intervals and the likelihood-ratio, score and Wald tests.
|
|
54
|
+
- Agreement and reliability: `kappa2`, `kappamFleiss`, `icc` (irr), `cronbachAlpha`, `partialR` (psych).
|
|
55
|
+
- `schur` (real Schur decomposition, `Matrix::Schur`) and `expm` (the matrix exponential, expm's `Higham08.b`,
|
|
56
|
+
`Higham08`, `Pade`, `Taylor`, `PadeO` and `TaylorO` with `order`).
|
|
57
|
+
- `factanal` (maximum-likelihood factor analysis with varimax and promax rotations), on `optim`'s L-BFGS-B.
|
|
58
|
+
- `omega` (McDonald's ω, psych's `omega`): minres factor analysis, varimax and oblimin rotations, the
|
|
59
|
+
Schmid-Leiman transformation, ω_h, ω_t, ω_lim, α, G6, ECV and the group omegas.
|
|
60
|
+
- `polychor` and `polyserial` (polycor's two-step estimates) and `pbvnorm` (bivariate normal rectangle
|
|
61
|
+
probabilities, Genz's method). With `{ ML, stdErr }`, the maximum-likelihood estimates (correlation and
|
|
62
|
+
thresholds) and the standard errors with polycor's chi-squared statistics, at the exact maximum of the likelihood
|
|
63
|
+
(R's optimisers stop up to 1e-3 short of it, and fail on some strongly associated tables).
|
|
64
|
+
- `optim` with Nelder-Mead, BFGS, CG, L-BFGS-B (a port of the Netlib code), SANN and Brent, following R's iterations
|
|
65
|
+
(the same evaluation counts), and `optimHess`.
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
- `pchisq` and `pf` with a huge noncentrality (above about 1e12) far from the quantile returned wrong values or NaN;
|
|
70
|
+
a Chernoff bound now returns 0 and 1 there.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## 0.9.0 - 2026-10-25
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
|
|
77
|
+
- `glm` (R's `glm` with a matrix interface): generalized linear models fitted by iteratively
|
|
78
|
+
reweighted least squares, with every family of R's `stats` (`gaussian`, `binomial`,
|
|
79
|
+
`quasibinomial`, `poisson`, `quasipoisson`, `Gamma`, `inverse.gaussian`, `quasi` with its five
|
|
80
|
+
variance functions) and every link each accepts, power links (`{ power: lambda }`), prior weights,
|
|
81
|
+
an offset, starting values, `epsilon`, `maxit` and a model without intercept. A binomial response
|
|
82
|
+
can be rows of (successes, failures). The result has the coefficients (NaN for aliased columns),
|
|
83
|
+
fitted values, deviance, null deviance, AIC, degrees of freedom, iterations, `converged`,
|
|
84
|
+
`boundary`, and R's warnings as strings in `warnings`.
|
|
85
|
+
- `glmSummary` (`summary.glm`): dispersion, coefficient table with z or t tests, unscaled and scaled
|
|
86
|
+
covariance; `glmResiduals` (deviance, Pearson, working, response); `glmHatvalues`,
|
|
87
|
+
`glmRstandard`, `glmCooksDistance`; `glmPredict` on the link or response scale with standard
|
|
88
|
+
errors, for the data or new rows (with their offset).
|
|
89
|
+
- `glmConfint`: profile likelihood confidence intervals (likelihood ratio or Rao score), with the
|
|
90
|
+
exact limits where R's `confint` interpolates a spline (R is up to 4.5e-4 standard errors from
|
|
91
|
+
them); see [docs/differences-from-r.md](docs/differences-from-r.md#generalized-linear-models).
|
|
92
|
+
- `glmAnova` (`anova.glm`): the sequential analysis of deviance of one fit (each column of `x` a
|
|
93
|
+
term) and the comparison of several fits, with the `"Chisq"`/`"LRT"`, `"Rao"`, `"F"` and `"Cp"`
|
|
94
|
+
tests and R 4.4's default test.
|
|
95
|
+
- Together they add 7.8 KB gzipped to everything (122.2 → 130.0 KB); `glm` with `glmSummary` alone
|
|
96
|
+
is 27.2 KB, with all its methods 39.2 KB.
|
|
97
|
+
|
|
10
98
|
## 0.8.0 - 2026-10-25
|
|
11
99
|
|
|
12
100
|
### Added
|
package/README.ja.md
CHANGED
|
@@ -16,7 +16,7 @@ JavaScript とブラウザで使える、R と互換の統計関数のライブ
|
|
|
16
16
|
- **どこでも動きます。** ESM のみで、依存パッケージはなく、Node 専用の API も使っていません。
|
|
17
17
|
tree-shaking が効きます (`pnorm` だけなら gzip で 1.2 KB)。
|
|
18
18
|
|
|
19
|
-
状態: **0.
|
|
19
|
+
状態: **0.10.0。** R の stats パッケージの数値計算の中心
|
|
20
20
|
(分布・記述統計・検定・線形モデル・特殊関数・数値計算・線形代数の基本) を、R と同じ結果でカバーすることを目指しています。残っている作業は
|
|
21
21
|
[ROADMAP.ja.md](ROADMAP.ja.md)、変更履歴は [CHANGELOG.md](CHANGELOG.md) (英語) にあります。
|
|
22
22
|
|
|
@@ -79,6 +79,63 @@ pAdjust([0.01, 0.02, 0.03, 0.04], { method: "BH" }); // ≈ [0.04, 0.04, 0.04
|
|
|
79
79
|
|
|
80
80
|
`tTest` の既定は、R と同じ Welch の検定です。
|
|
81
81
|
|
|
82
|
+
### 一般化線形モデル
|
|
83
|
+
|
|
84
|
+
説明変数は `lm` と同じく行列 (行の配列) かベクトルで渡します。二項分布の応答は (成功数, 失敗数) の行でも渡せます。
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { glm, glmSummary, glmPredict, glmConfint, glmAnova } from "@numero-uno-jpn/rstats";
|
|
88
|
+
|
|
89
|
+
const dose = [1, 2, 3, 4, 5, 6];
|
|
90
|
+
const counts = [[1, 19], [4, 16], [9, 11], [13, 7], [18, 2], [19, 1]];
|
|
91
|
+
const fit = glm(dose, counts, { family: "binomial" }); // R: glm(cbind(s, f) ~ dose, binomial)
|
|
92
|
+
fit.coefficients; // ≈ [-3.77413, 1.14807]
|
|
93
|
+
glmSummary(fit).pValue; // ≈ [5.357e-8, 3.579e-9] (z tests)
|
|
94
|
+
glmPredict(fit, { newdata: [3.5], type: "response" }); // { fit: ≈ [0.56073], seFit: ≈ [0.06140] }
|
|
95
|
+
glmConfint(fit).lower; // ≈ [-5.27166, 0.80033] (profile likelihood)
|
|
96
|
+
glmAnova(fit).table[1]; // ≈ [1, 62.978, 4, 0.5196, 2.09e-15]
|
|
97
|
+
fit.warnings; // [] (R's warnings, such as non-convergence)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### formula による分散分析
|
|
101
|
+
|
|
102
|
+
`lm` と `aov` は、R の formula とデータフレーム (列のオブジェクト。文字列の列は因子) でも呼べます。`anova` は R の
|
|
103
|
+
逐次の表、`Anova` は car の Type II と III の検定、`aovEz` は afex の反復測定の分散分析 (Greenhouse-Geisser の補正と
|
|
104
|
+
一般化 η² つき) です。
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { lm, anova, Anova, aovEz } from "@numero-uno-jpn/rstats";
|
|
108
|
+
|
|
109
|
+
const d = { y: [12.1, 14.3, 13.8, 17.2, 19.5, 22.4, 11.6, 13.9, 15.7, 18.8, 21.1, 25.3],
|
|
110
|
+
A: ["a", "a", "b", "b", "c", "c", "a", "a", "b", "b", "c", "c"],
|
|
111
|
+
B: ["p", "q", "p", "q", "p", "q", "p", "q", "p", "q", "p", "q"] };
|
|
112
|
+
const fit = lm("y ~ A * B", d, { contrasts: { A: "contr.sum", B: "contr.sum" } });
|
|
113
|
+
anova(fit).rowNames; // ["A", "B", "A:B", "Residuals"]
|
|
114
|
+
anova(fit).table[0]; // ≈ [2, 169.147, 84.573, 57.828, 0.00011997] (Df, Sum Sq, Mean Sq, F, p)
|
|
115
|
+
Anova(fit, { type: 3 }).table[1]; // ≈ [169.147, 2, 57.828, 0.00011997] (car::Anova(fit, type = 3))
|
|
116
|
+
|
|
117
|
+
// 反復測定 (R: afex::aov_ez("id", "y", long, within = "W"))
|
|
118
|
+
const long = { id: ["s1", "s1", "s1", "s2", "s2", "s2", "s3", "s3", "s3", "s4", "s4", "s4", "s5", "s5", "s5"],
|
|
119
|
+
W: ["pre", "mid", "post", "pre", "mid", "post", "pre", "mid", "post", "pre", "mid", "post", "pre", "mid", "post"],
|
|
120
|
+
y: [5.1, 6.3, 7.2, 4.8, 5.9, 7.5, 6.0, 6.1, 8.3, 5.5, 6.8, 7.1, 4.9, 6.6, 7.8] };
|
|
121
|
+
aovEz(long, { id: "id", dv: "y", within: "W" }).anova.table[0];
|
|
122
|
+
// ≈ [1.735, 6.940, 0.21653, 35.876, 0.84607, 0.00026363] (num Df, den Df, MSE, F, ges, p。GG で補正)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 効果量と検出力
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { cohensD, etaSquared, Anova, powerTTest, pwrAnovaTest } from "@numero-uno-jpn/rstats";
|
|
129
|
+
|
|
130
|
+
cohensD([5.1, 4.9, 6.2, 5.8, 6.0, 5.5], [4.1, 4.5, 5.0, 4.8, 4.3]);
|
|
131
|
+
// ≈ { name: "Cohens_d", value: 2.30726, ci: 0.95, ciLow: 0.68824, ciHigh: 3.85666 } (effectsize::cohens_d)
|
|
132
|
+
etaSquared(Anova(fit, { type: 3 })).table[0]; // ≈ [0.95068, 0.95, 0.82023, 1] (fit は上の例のもの。偏 η²、片側の信頼区間)
|
|
133
|
+
powerTTest({ delta: 0.5, power: 0.8 }).n; // ≈ 63.766 (1 群あたり、power.t.test)
|
|
134
|
+
pwrAnovaTest({ k: 3, f: 0.25, power: 0.8 }).n; // ≈ 52.397 (pwr::pwr.anova.test)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
信頼区間の限界は厳密な解です。effectsize は最適化で求めるので、1e-9 程度 (ときに 3e-3) ずれます。
|
|
138
|
+
|
|
82
139
|
### 線形代数
|
|
83
140
|
|
|
84
141
|
行列は行の配列で表します。
|
|
@@ -101,15 +158,25 @@ eigen([[2, 1], [1, 3]]).values; // [3.618033988749895, 1.381966011250105]
|
|
|
101
158
|
| 分布 (d/p/q) | 正規、t、カイ二乗、F、ベータ、ガンマ、二項、ポアソン、一様、指数、対数正規、ロジスティック、コーシー、ワイブル、幾何、負の二項、超幾何、Wilcoxon の符号付き順位と順位和、スチューデント化された範囲 (`ptukey`, `qtukey`)、非心カイ二乗・t・F・ベータ (`ncp`)。多項分布の確率 (`dmultinom`)。逆ガンマ、Kumaraswamy、Pareto、三角、Laplace (extraDistr) と逆正弦。`distSummary` (平均・分散・標準偏差・中央値・最頻値・歪度・尖度) |
|
|
102
159
|
| 乱数 | `setSeed` (`set.seed`), `RNGkind` (Mersenne-Twister と L'Ecuyer-CMRG、`sample.kind` の Rejection と Rounding), `getRandomSeed`/`setRandomSeed` (`.Random.seed`), `nextRNGStream`/`nextRNGSubStream` (`parallel`), 26 個の `r*` 関数, `sample`, `sampleInt` (`sample.int`), `r2dtable` |
|
|
103
160
|
| 記述統計 | `sum`, `prod`, `mean`, `weightedMean` (`weighted.mean`), `variance` (`var`), `sd`, `median`, `range`, `cumsum`, `cumprod`, `cummax`, `cummin`, `diff`, `quantile`, `IQR`, `fivenum`, `mad`, `rank`, `cov`, `cor`, `tabulate`, `table`, `unique`, `cut`, `findInterval`, `pretty`, `hist`, `ecdf`, `scale`, `skewness`, `kurtosis`, `geometricMean`, `modes`, `meanAD`, `cv` |
|
|
104
|
-
| 検定 | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
161
|
+
| 検定 | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov` (一元配置), `TukeyHSD`, `zTest`, `brunnerMunzelTest`, `pAdjust` (`p.adjust`) |
|
|
162
|
+
| 分散分析 | formula で呼ぶ `aov` と `aovSummary` (多元、交互作用、共変量、`Error()` の層), `anova` (`anova.lm`。逐次の表とモデルの比較), `Anova` (car の Type II と III), `aovEz` (afex。反復測定と混合計画、Greenhouse-Geisser と Huynh-Feldt の補正、一般化 η² と偏 η²), `mauchlyTest` (`mauchly.test`) |
|
|
163
|
+
| 効果量と検出力 | `cohensD`, `hedgesG` (effectsize。信頼区間は厳密な限界), `etaSquared`, `omegaSquared`, `epsilonSquared` (偏・一般化。`anova` と `Anova` の表から), `powerTTest`, `powerPropTest`, `powerAnovaTest` (`power.*.test`), `pwrTTest`, `pwrT2nTest`, `pwr2pTest`, `pwr2p2nTest`, `pwrPTest`, `pwrNormTest`, `pwrRTest`, `pwrChisqTest`, `pwrAnovaTest`, `pwrF2Test`, `esH`, `esW1`, `esW2`, `cohenES` (pwr) |
|
|
164
|
+
| 線形モデル | `lm` (formula とデータフレーム、または行列で渡す。`summary` の値も返す), `modelMatrix` (`model.matrix`), `confint`, `predict`。`glm` (行列で渡す形。R の `stats` のすべての族とリンク) と `glmSummary` (`summary.glm`)、`glmResiduals` (4 種類)、`glmHatvalues`、`glmRstandard`、`glmCooksDistance`、`glmPredict` (標準誤差つき)、`glmConfint` (プロファイル尤度、厳密な限界)、`glmAnova` (`anova.glm`) |
|
|
165
|
+
| ほかの検定 | `leveneTest`、`propTrendTest` (`prop.trend.test`)、`jonckheereTest`、`cochranQTest`、`adTest`、`lillieTest`、`cvmTest`、`sfTest`、`pearsonTest` (car、DescTools、clinfun、nortest) |
|
|
166
|
+
| 多重比較 | `dscfAllPairsTest` (Steel-Dwass)、`kwAllPairsDunnTest`、`kwManyOneDunnTest`、`manyOneUTest` (Steel の多対一の順位検定)、`dunnettTest`、`gamesHowellTest`、`tukeyTest` (PMCMRplus)、`dunnTest` (dunn.test)、`glhtDunnett` (multcomp) |
|
|
167
|
+
| 生存時間解析 | `survdiff` (log-rank)、`survfit` (Kaplan-Meier。信頼区間と中央値)、`coxph` (Cox 回帰。Efron と Breslow のタイの扱い、ケースの重み、層、Wald・尤度比・スコア検定) |
|
|
168
|
+
| 一致度と信頼性 | `kappa2`、`kappamFleiss`、`icc` (irr)、`cronbachAlpha`、`partialR` (psych)、`polychor`、`polyserial` (polycor)、`pbvnorm`、`factanal`、`omega` (McDonald の ω。psych) |
|
|
169
|
+
| 線形代数 | `matMul` (`%*%`), `add`, `subtract`, `multiply`, `divide`, `outer`, `t`, `diag`, `cbind`, `rbind`, `matrix`, `kronecker`, `seq`, `crossprod`, `tcrossprod`, `norm`, `backsolve`, `forwardsolve`, `chol`, `chol2inv`, `qr` と `qrQ`, `qrR`, `qrX`, `qrCoef`, `qrQy`, `qrQty`, `qrResid`, `qrFitted`, `qrSolve` (`qr.Q` …), `solve`, `det`, `determinant`, `rcond`, `kappa`, `svd`, `eigen`, `lu`, `prcomp`, `ginv` (MASS)、`schur`、`expm` |
|
|
170
|
+
| 数値計算 | `integrate`, `optimize`, `optim`, `optimHess`, `uniroot`, `approx`, `spline`, `splinefun`, `splinefunH`, `barylag`, `hermiteInterp`, `ode`, `grad`, `jacobian`, `hessian` |
|
|
108
171
|
|
|
109
172
|
jStat から移るときは [docs/ja/migrating-from-jstat.md](docs/ja/migrating-from-jstat.md) に jStat の全関数の置き換えがあります。
|
|
110
173
|
|
|
111
174
|
API リファレンスは `npm run docs` (TypeDoc) で作れます (英語)。
|
|
112
175
|
|
|
176
|
+
AI のコーディング支援向けに、R のコードを rStats.js の呼び出しに書き換える方法を [llms.txt](llms.txt)
|
|
177
|
+
にまとめています (英語。npm のパッケージにも入っていて、<https://numero-uno-jpn.github.io/rStats.js/llms.txt>
|
|
178
|
+
でも読めます)。
|
|
179
|
+
|
|
113
180
|
## 精度
|
|
114
181
|
|
|
115
182
|
正解の値は [`oracle/`](oracle) の R のスクリプトで作り、[`test/fixtures/`](test/fixtures) に
|
|
@@ -127,7 +194,8 @@ double-double 演算で計算しているためです。詳しくは [docs/ja/ac
|
|
|
127
194
|
- 添字は 0 から始まります。`sampleInt(n)` は `0..n-1` を返します (R の `sample.int()` から 1 を
|
|
128
195
|
引いた値で、乱数の列は同じ)。`qr` と `chol` のピボットも 0 から始まります。
|
|
129
196
|
- 固有ベクトルと特異ベクトルの符号が R と違うことがあります (どちらも正しい答えです)。
|
|
130
|
-
- 検定は R
|
|
197
|
+
- 検定は R の警告を出しません。数値の欄と手法の名前はすべて一致します。`glm` は R の警告を結果の
|
|
198
|
+
`warnings` で返します。
|
|
131
199
|
- 分布の母数は、ベクトルとして使い回されません (リサイクルしない)。
|
|
132
200
|
|
|
133
201
|
すべての違いは [docs/ja/differences-from-r.md](docs/ja/differences-from-r.md) にあります。
|
|
@@ -144,34 +212,42 @@ double-double 演算で計算しているためです。詳しくは [docs/ja/ac
|
|
|
144
212
|
| `solve` / `svd` / `eigen` | 1.7 / 2.0 / 3.7 KB |
|
|
145
213
|
| `wilcoxTest` / `fisherTest` / `tTest` | 8.6 / 15.6 / 21.4 KB |
|
|
146
214
|
| `qbeta` / `pt` と `qt` | 23.2 / 30.3 KB |
|
|
147
|
-
|
|
|
215
|
+
| `glm` と `glmSummary` / `glm` とそのすべての関数 | 27.2 / 39.2 KB |
|
|
216
|
+
| すべて | 177.9 KB |
|
|
148
217
|
|
|
149
218
|
(`npm run size` で測れます。)
|
|
150
219
|
|
|
151
220
|
分野ごとにサブパスからも export しているので、1 つの分野だけを import することもできます。
|
|
152
|
-
`@numero-uno-jpn/rstats/distributions`、`/tests` (
|
|
221
|
+
`@numero-uno-jpn/rstats/distributions`、`/tests` (検定、`lm`・`confint`・`predict`、`glm` とその関数)、`/linalg`、
|
|
153
222
|
`/descriptive`、`/numerics`、`/special` です。
|
|
154
223
|
|
|
155
224
|
バンドラを使わない場合は、1 ファイルにまとめたビルド `dist/rstats.js` (すべての関数を含む minify 済みの
|
|
156
|
-
ES モジュール、gzip で
|
|
225
|
+
ES モジュール、gzip で 178 KB) を jsDelivr から読み込めます。jsDelivr は、このリポジトリのリリースの
|
|
157
226
|
タグをそのまま配信します。
|
|
158
227
|
|
|
159
228
|
```html
|
|
160
229
|
<script type="module">
|
|
161
|
-
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.
|
|
230
|
+
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.10.0/dist/rstats.js";
|
|
162
231
|
console.log(pnorm(1.96)); // 0.9750021048517795
|
|
163
232
|
</script>
|
|
164
233
|
```
|
|
165
234
|
|
|
235
|
+
関数は R と同じ名前の named export で、`jStat.` や `_.` のような接頭辞はありません。他の名前と区別
|
|
236
|
+
したいときは、名前空間として import してください (上の URL から `import * as rs from` で読み込む)。
|
|
237
|
+
`rs.pnorm(1.96)`、`rs.tTest(x, y)` のように呼べます。バンドラを使う場合
|
|
238
|
+
(`import * as rs from "@numero-uno-jpn/rstats"`) も、使わない関数は取り除かれます。CDN から読み込む
|
|
239
|
+
場合は、どちらの書き方でもファイル全体が読み込まれます。`window` には何も追加しません。他のスクリプトや
|
|
240
|
+
ブラウザのコンソールから使うときは、自分で `window.rs = rs` としてください。
|
|
241
|
+
|
|
166
242
|
一部の分野だけを使うページでは、代わりに分野ごとのバンドルを読み込めます。`dist/distributions.js`、
|
|
167
243
|
`dist/tests.js`、`dist/linalg.js`、`dist/descriptive.js`、`dist/numerics.js`、`dist/special.js` は
|
|
168
244
|
上のサブパスと同じ関数を export し、共通のコードを `dist/chunks/` で共有します。そのため、2 つの分野を
|
|
169
|
-
読み込んでも共通部分は 1 回しか読み込まれません。chunk を含めた 1 分野の転送量は、gzip で
|
|
170
|
-
(`
|
|
245
|
+
読み込んでも共通部分は 1 回しか読み込まれません。chunk を含めた 1 分野の転送量は、gzip で 27 KB
|
|
246
|
+
(`linalg`) から 151 KB (`tests`) です。
|
|
171
247
|
|
|
172
248
|
ビルド結果 (`dist/`) は main ブランチにはなく、リリースのタグにだけ入っています。npm を元にした CDN も
|
|
173
249
|
使えます。たとえば
|
|
174
|
-
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.
|
|
250
|
+
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.10.0/dist/rstats.js` や
|
|
175
251
|
`https://esm.sh/@numero-uno-jpn/rstats` です。
|
|
176
252
|
|
|
177
253
|
ブラウザ向けのビルドは、headless Chromium でテストしています。バンドラでまとめた場合と、
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ R-compatible statistical functions for JavaScript and the browser, written in Ty
|
|
|
14
14
|
- **Runs anywhere.** ESM only, no dependencies, no Node-specific APIs, tree-shakable
|
|
15
15
|
(`pnorm` alone is 1.2 KB gzipped).
|
|
16
16
|
|
|
17
|
-
Status: **0.
|
|
17
|
+
Status: **0.10.0.** The goal is to cover the numerical core of R's
|
|
18
18
|
`stats` package (distributions, descriptive statistics, hypothesis tests, linear models, special
|
|
19
19
|
functions, numerical methods and the basics of linear algebra) with R-compatible results; see [ROADMAP.md](ROADMAP.md) for what remains. See [CHANGELOG.md](CHANGELOG.md).
|
|
20
20
|
|
|
@@ -74,6 +74,65 @@ fisherTest([[3, 1], [1, 3]]).pValue; // 0.4857142857142857
|
|
|
74
74
|
pAdjust([0.01, 0.02, 0.03, 0.04], { method: "BH" }); // ≈ [0.04, 0.04, 0.04, 0.04]
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
### Generalized linear models
|
|
78
|
+
|
|
79
|
+
The predictors are a matrix (array of rows) or a vector, as for `lm`; a binomial response can be
|
|
80
|
+
rows of (successes, failures).
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { glm, glmSummary, glmPredict, glmConfint, glmAnova } from "@numero-uno-jpn/rstats";
|
|
84
|
+
|
|
85
|
+
const dose = [1, 2, 3, 4, 5, 6];
|
|
86
|
+
const counts = [[1, 19], [4, 16], [9, 11], [13, 7], [18, 2], [19, 1]];
|
|
87
|
+
const fit = glm(dose, counts, { family: "binomial" }); // R: glm(cbind(s, f) ~ dose, binomial)
|
|
88
|
+
fit.coefficients; // ≈ [-3.77413, 1.14807]
|
|
89
|
+
glmSummary(fit).pValue; // ≈ [5.357e-8, 3.579e-9] (z tests)
|
|
90
|
+
glmPredict(fit, { newdata: [3.5], type: "response" }); // { fit: ≈ [0.56073], seFit: ≈ [0.06140] }
|
|
91
|
+
glmConfint(fit).lower; // ≈ [-5.27166, 0.80033] (profile likelihood)
|
|
92
|
+
glmAnova(fit).table[1]; // ≈ [1, 62.978, 4, 0.5196, 2.09e-15]
|
|
93
|
+
fit.warnings; // [] (R's warnings, such as non-convergence)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Analysis of variance with formulas
|
|
97
|
+
|
|
98
|
+
`lm` and `aov` also take an R formula and a data frame (an object of columns; strings are factors). `anova` gives
|
|
99
|
+
R's sequential table, `Anova` car's type II and III tests, `aovEz` afex's repeated-measures ANOVA with the
|
|
100
|
+
Greenhouse-Geisser correction and generalized eta squared.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { lm, anova, Anova, aovEz } from "@numero-uno-jpn/rstats";
|
|
104
|
+
|
|
105
|
+
const d = { y: [12.1, 14.3, 13.8, 17.2, 19.5, 22.4, 11.6, 13.9, 15.7, 18.8, 21.1, 25.3],
|
|
106
|
+
A: ["a", "a", "b", "b", "c", "c", "a", "a", "b", "b", "c", "c"],
|
|
107
|
+
B: ["p", "q", "p", "q", "p", "q", "p", "q", "p", "q", "p", "q"] };
|
|
108
|
+
const fit = lm("y ~ A * B", d, { contrasts: { A: "contr.sum", B: "contr.sum" } });
|
|
109
|
+
anova(fit).rowNames; // ["A", "B", "A:B", "Residuals"]
|
|
110
|
+
anova(fit).table[0]; // ≈ [2, 169.147, 84.573, 57.828, 0.00011997] (Df, Sum Sq, Mean Sq, F, p)
|
|
111
|
+
Anova(fit, { type: 3 }).table[1]; // ≈ [169.147, 2, 57.828, 0.00011997] (car::Anova(fit, type = 3))
|
|
112
|
+
|
|
113
|
+
// repeated measures (R: afex::aov_ez("id", "y", long, within = "W"))
|
|
114
|
+
const long = { id: ["s1", "s1", "s1", "s2", "s2", "s2", "s3", "s3", "s3", "s4", "s4", "s4", "s5", "s5", "s5"],
|
|
115
|
+
W: ["pre", "mid", "post", "pre", "mid", "post", "pre", "mid", "post", "pre", "mid", "post", "pre", "mid", "post"],
|
|
116
|
+
y: [5.1, 6.3, 7.2, 4.8, 5.9, 7.5, 6.0, 6.1, 8.3, 5.5, 6.8, 7.1, 4.9, 6.6, 7.8] };
|
|
117
|
+
aovEz(long, { id: "id", dv: "y", within: "W" }).anova.table[0];
|
|
118
|
+
// ≈ [1.735, 6.940, 0.21653, 35.876, 0.84607, 0.00026363] (num Df, den Df, MSE, F, ges, p; GG-corrected)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Effect sizes and power
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { cohensD, etaSquared, Anova, powerTTest, pwrAnovaTest } from "@numero-uno-jpn/rstats";
|
|
125
|
+
|
|
126
|
+
cohensD([5.1, 4.9, 6.2, 5.8, 6.0, 5.5], [4.1, 4.5, 5.0, 4.8, 4.3]);
|
|
127
|
+
// ≈ { name: "Cohens_d", value: 2.30726, ci: 0.95, ciLow: 0.68824, ciHigh: 3.85666 } (effectsize::cohens_d)
|
|
128
|
+
etaSquared(Anova(fit, { type: 3 })).table[0]; // ≈ [0.95068, 0.95, 0.82023, 1] (fit from the example above; partial eta², one-sided CI)
|
|
129
|
+
powerTTest({ delta: 0.5, power: 0.8 }).n; // ≈ 63.766 per group (power.t.test)
|
|
130
|
+
pwrAnovaTest({ k: 3, f: 0.25, power: 0.8 }).n; // ≈ 52.397 (pwr::pwr.anova.test)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The confidence limits are the exact solutions; effectsize finds them with an optimiser and is up to
|
|
134
|
+
about 1e-9 (sometimes 3e-3) off.
|
|
135
|
+
|
|
77
136
|
### Linear algebra
|
|
78
137
|
|
|
79
138
|
Matrices are arrays of rows.
|
|
@@ -96,15 +155,24 @@ eigen([[2, 1], [1, 3]]).values; // [3.618033988749895, 1.381966011250105]
|
|
|
96
155
|
| Distributions (d/p/q) | normal, t, chi-squared, F, beta, gamma, binomial, Poisson, uniform, exponential, log-normal, logistic, Cauchy, Weibull, geometric, negative binomial, hypergeometric, Wilcoxon signed rank and rank sum, studentized range (`ptukey`, `qtukey`), non-central chi-squared, t, F and beta (`ncp`); the multinomial probability (`dmultinom`); inverse gamma, Kumaraswamy, Pareto, triangular, Laplace (extraDistr) and arcsine; `distSummary` (mean, variance, sd, median, mode, skewness, kurtosis) |
|
|
97
156
|
| Random numbers | `setSeed` (`set.seed`), `RNGkind` (Mersenne-Twister and L'Ecuyer-CMRG, `sample.kind` Rejection and Rounding), `getRandomSeed`/`setRandomSeed` (`.Random.seed`), `nextRNGStream`/`nextRNGSubStream` (`parallel`), 26 `r*` functions, `sample`, `sampleInt` (`sample.int`), `r2dtable` |
|
|
98
157
|
| Descriptive statistics | `sum`, `prod`, `mean`, `weightedMean` (`weighted.mean`), `variance` (`var`), `sd`, `median`, `range`, `cumsum`, `cumprod`, `cummax`, `cummin`, `diff`, `quantile`, `IQR`, `fivenum`, `mad`, `rank`, `cov`, `cor`, `tabulate`, `table`, `unique`, `cut`, `findInterval`, `pretty`, `hist`, `ecdf`, `scale`, `skewness`, `kurtosis`, `geometricMean`, `modes`, `meanAD`, `cv` |
|
|
99
|
-
| Hypothesis tests | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
158
|
+
| Hypothesis tests | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov` (one way), `TukeyHSD`, `zTest`, `brunnerMunzelTest`, `pAdjust` (`p.adjust`) |
|
|
159
|
+
| Analysis of variance | `aov` and `aovSummary` with a formula (several factors, interactions, covariates, `Error()` strata), `anova` (`anova.lm`, sequential and model comparison), `Anova` (car: types II and III), `aovEz` (afex: repeated-measures and mixed designs, Greenhouse-Geisser and Huynh-Feldt corrections, generalized and partial eta squared), `mauchlyTest` (`mauchly.test`) |
|
|
160
|
+
| Effect sizes and power | `cohensD`, `hedgesG` (effectsize, with exact confidence limits), `etaSquared`, `omegaSquared`, `epsilonSquared` (partial, generalized, from `anova` and `Anova` tables); `powerTTest`, `powerPropTest`, `powerAnovaTest` (`power.*.test`); `pwrTTest`, `pwrT2nTest`, `pwr2pTest`, `pwr2p2nTest`, `pwrPTest`, `pwrNormTest`, `pwrRTest`, `pwrChisqTest`, `pwrAnovaTest`, `pwrF2Test`, `esH`, `esW1`, `esW2`, `cohenES` (pwr) |
|
|
161
|
+
| Linear models | `lm` (a formula and a data frame, or a matrix, with the `summary` quantities), `modelMatrix` (`model.matrix`), `confint`, `predict`; `glm` (matrix interface, every family and link of R's `stats`) with `glmSummary` (`summary.glm`), `glmResiduals` (the four kinds), `glmHatvalues`, `glmRstandard`, `glmCooksDistance`, `glmPredict` (with standard errors), `glmConfint` (profile likelihood, exact limits), `glmAnova` (`anova.glm`) |
|
|
162
|
+
| More tests | `leveneTest`, `propTrendTest` (`prop.trend.test`), `jonckheereTest`, `cochranQTest`, `adTest`, `lillieTest`, `cvmTest`, `sfTest`, `pearsonTest` (car, DescTools, clinfun, nortest) |
|
|
163
|
+
| Multiple comparisons | `dscfAllPairsTest` (Steel-Dwass), `kwAllPairsDunnTest`, `kwManyOneDunnTest`, `manyOneUTest` (Steel's many-one rank test), `dunnettTest`, `gamesHowellTest`, `tukeyTest` (PMCMRplus), `dunnTest` (dunn.test), `glhtDunnett` (multcomp) |
|
|
164
|
+
| Survival analysis | `survdiff` (log-rank), `survfit` (Kaplan-Meier with intervals and median), `coxph` (Cox regression: Efron and Breslow ties, case weights, strata, the Wald, likelihood-ratio and score tests) |
|
|
165
|
+
| Agreement and reliability | `kappa2`, `kappamFleiss`, `icc` (irr), `cronbachAlpha`, `partialR` (psych), `polychor`, `polyserial` (polycor), `pbvnorm`, `factanal`, `omega` (McDonald's ω, psych) |
|
|
166
|
+
| Linear algebra | `matMul` (`%*%`), `add`, `subtract`, `multiply`, `divide`, `outer`, `t`, `diag`, `cbind`, `rbind`, `matrix`, `kronecker`, `seq`, `crossprod`, `tcrossprod`, `norm`, `backsolve`, `forwardsolve`, `chol`, `chol2inv`, `qr` with `qrQ`, `qrR`, `qrX`, `qrCoef`, `qrQy`, `qrQty`, `qrResid`, `qrFitted`, `qrSolve` (`qr.Q` …), `solve`, `det`, `determinant`, `rcond`, `kappa`, `svd`, `eigen`, `lu`, `prcomp`, `ginv` (MASS), `schur`, `expm` |
|
|
167
|
+
| Numerical methods | `integrate`, `optimize`, `optim`, `optimHess`, `uniroot`, `approx`, `spline`, `splinefun`, `splinefunH`, `barylag`, `hermiteInterp`, `ode`, `grad`, `jacobian`, `hessian` |
|
|
103
168
|
|
|
104
169
|
Coming from jStat? [docs/migrating-from-jstat.md](docs/migrating-from-jstat.md) lists the replacement for every jStat function.
|
|
105
170
|
|
|
106
171
|
An API reference can be generated with `npm run docs` (TypeDoc).
|
|
107
172
|
|
|
173
|
+
For AI coding assistants, [llms.txt](llms.txt) summarises how R code translates to rStats.js
|
|
174
|
+
calls (also in the npm package and at <https://numero-uno-jpn.github.io/rStats.js/llms.txt>).
|
|
175
|
+
|
|
108
176
|
## Accuracy
|
|
109
177
|
|
|
110
178
|
Expected values are produced by R scripts in [`oracle/`](oracle) and stored in
|
|
@@ -121,7 +189,8 @@ everyday use:
|
|
|
121
189
|
- Indices are 0-based: `sampleInt(n)` returns `0..n-1` (R's `sample.int()` minus 1, from the
|
|
122
190
|
same random stream), and pivots of `qr` and `chol` are 0-based.
|
|
123
191
|
- Signs of eigenvectors and singular vectors may differ from R (both are correct).
|
|
124
|
-
- Hypothesis tests do not emit R's warnings; all numeric fields and method names match.
|
|
192
|
+
- Hypothesis tests do not emit R's warnings; all numeric fields and method names match. `glm` returns
|
|
193
|
+
R's warnings in its result (`warnings`).
|
|
125
194
|
- Distribution parameters are not recycled as vectors.
|
|
126
195
|
|
|
127
196
|
Full list: [docs/differences-from-r.md](docs/differences-from-r.md).
|
|
@@ -138,33 +207,41 @@ removed. Approximate sizes after minification and gzip:
|
|
|
138
207
|
| `solve` / `svd` / `eigen` | 1.7 / 2.0 / 3.7 KB |
|
|
139
208
|
| `wilcoxTest` / `fisherTest` / `tTest` | 8.6 / 15.6 / 21.4 KB |
|
|
140
209
|
| `qbeta` / `pt` and `qt` | 23.2 / 30.3 KB |
|
|
141
|
-
|
|
|
210
|
+
| `glm` and `glmSummary` / `glm` with all its methods | 27.2 / 39.2 KB |
|
|
211
|
+
| everything | 177.9 KB |
|
|
142
212
|
|
|
143
213
|
(`npm run size` measures these.)
|
|
144
214
|
|
|
145
215
|
Each area is also a subpath export, for importing one area without the rest:
|
|
146
|
-
`@numero-uno-jpn/rstats/distributions`, `/tests` (hypothesis tests,
|
|
147
|
-
`predict`), `/linalg`, `/descriptive`, `/numerics` and `/special`.
|
|
216
|
+
`@numero-uno-jpn/rstats/distributions`, `/tests` (hypothesis tests, `lm`, `confint` and
|
|
217
|
+
`predict`, and `glm` with its methods), `/linalg`, `/descriptive`, `/numerics` and `/special`.
|
|
148
218
|
|
|
149
219
|
Without a bundler, load the single-file build `dist/rstats.js` (one minified ES module with every
|
|
150
|
-
function,
|
|
220
|
+
function, 178 KB gzipped) from jsDelivr, which serves each release tag of this repository:
|
|
151
221
|
|
|
152
222
|
```html
|
|
153
223
|
<script type="module">
|
|
154
|
-
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.
|
|
224
|
+
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.10.0/dist/rstats.js";
|
|
155
225
|
console.log(pnorm(1.96)); // 0.9750021048517795
|
|
156
226
|
</script>
|
|
157
227
|
```
|
|
158
228
|
|
|
229
|
+
The functions are named exports with R's names, without a prefix such as `jStat.` or `_.`. To
|
|
230
|
+
keep them apart from other names, import the module as a namespace (`import * as rs from` the
|
|
231
|
+
URL above) and call `rs.pnorm(1.96)`, `rs.tTest(x, y)`. With a bundler, unused functions are
|
|
232
|
+
still removed (`import * as rs from "@numero-uno-jpn/rstats"`); from a CDN the whole file is
|
|
233
|
+
loaded either way. Nothing is added to `window`: to use the functions from other scripts or the
|
|
234
|
+
browser console, assign `window.rs = rs` yourself.
|
|
235
|
+
|
|
159
236
|
A page that needs only some areas can load the per-area bundles instead: `dist/distributions.js`,
|
|
160
237
|
`dist/tests.js`, `dist/linalg.js`, `dist/descriptive.js`, `dist/numerics.js` and `dist/special.js`
|
|
161
238
|
export the same functions as the subpaths above, and share their common code through
|
|
162
239
|
`dist/chunks/`, so loading two areas does not load that code twice. With its chunks, one area
|
|
163
|
-
transfers
|
|
240
|
+
transfers 27 KB (`linalg`) to 151 KB (`tests`) gzipped.
|
|
164
241
|
|
|
165
242
|
Release tags contain the build output (`dist/`), which is not on the main branch. npm-based CDNs
|
|
166
243
|
work as well, for example
|
|
167
|
-
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.
|
|
244
|
+
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.10.0/dist/rstats.js` or
|
|
168
245
|
`https://esm.sh/@numero-uno-jpn/rstats`.
|
|
169
246
|
|
|
170
247
|
The browser build is tested in headless Chromium, both bundled and as `dist/rstats.js` loaded as
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -240,8 +240,8 @@ DAMAGE.
|
|
|
240
240
|
- Source: https://github.com/Reference-LAPACK/lapack (tag v3.12.0)
|
|
241
241
|
- `BLAS/SRC/dtrsm.f`, `SRC/dlange.f`, `SRC/dpotf2.f`, `SRC/dpstf2.f`, `SRC/dpotri.f` (`dtrti2.f`, `dlauu2.f`),
|
|
242
242
|
`SRC/dgeqp3.f` (`dlaqp2.f`, `dlarfg.f`, `dlarf.f`), `SRC/dorm2r.f`, `SRC/dgetf2.f`, `SRC/dgetrs.f`,
|
|
243
|
-
`SRC/dgecon.f`, `SRC/dtrcon.f`, `SRC/dlacn2.f`
|
|
244
|
-
- Used in: `src/linalg/basic.ts`, `src/linalg/norm.ts`, `src/linalg/chol.ts`, `src/linalg/qr.ts`, `src/linalg/solve.ts`, `src/linalg/svd.ts`
|
|
243
|
+
`SRC/dgecon.f`, `SRC/dtrcon.f`, `SRC/dlacn2.f`, `SRC/dgebal.f`, `SRC/dlanv2.f`
|
|
244
|
+
- Used in: `src/linalg/basic.ts`, `src/linalg/norm.ts`, `src/linalg/chol.ts`, `src/linalg/qr.ts`, `src/linalg/solve.ts`, `src/linalg/svd.ts`, `src/linalg/expm.ts`, `src/linalg/schur.ts`
|
|
245
245
|
- License: modified BSD
|
|
246
246
|
|
|
247
247
|
```
|
|
@@ -316,6 +316,11 @@ they are listed so that readers can find the originals.
|
|
|
316
316
|
- netlib fmm (https://netlib.org/fmm/fmin.f; Brent, "Algorithms for Minimization without Derivatives",
|
|
317
317
|
1973, chapter 5): `fmin` (Brent's localmin, golden-section search with parabolic interpolation),
|
|
318
318
|
the minimiser of `optimize` — `src/optim/localmin.ts`
|
|
319
|
+
- L-BFGS-B version 2.1 (C. Zhu, R. H. Byrd, P. Lu-Chen and J. Nocedal; netlib
|
|
320
|
+
https://www.netlib.org/opt/lbfgs_bcm.shar, `routines.f`, distributed without a copyright notice): `setulb`/`mainlb`
|
|
321
|
+
and their subroutines (generalized Cauchy point, subspace minimisation, limited-memory BFGS matrices), with the
|
|
322
|
+
MINPACK-2 line search `dcsrch`/`dcstep` (Moré and Thuente) and the LINPACK/BLAS routines it ships with, the method
|
|
323
|
+
"L-BFGS-B" of `optim` — `src/optim/lbfgsb.ts`
|
|
319
324
|
- QUADPACK (Piessens, de Doncker-Kapenga, Überhuber, Kahaner 1983): `dqagse` and `dqagie` (adaptive
|
|
320
325
|
Gauss–Kronrod quadrature with extrapolation), behind `integrate` — `src/integrate/quadpack.ts`,
|
|
321
326
|
ported from SciPy's C translation (see SciPy above)
|
|
@@ -335,6 +340,11 @@ Listed for attribution; no license terms apply to the methods themselves.
|
|
|
335
340
|
- E. Brunner and U. Munzel, "The nonparametric Behrens-Fisher problem: asymptotic theory and a small-sample
|
|
336
341
|
approximation", Biometrical Journal 42 (2000) 17–25: the Brunner-Munzel test (lawstat's
|
|
337
342
|
`brunner.munzel.test`) — `src/htest/brunnerMunzelTest.ts`
|
|
343
|
+
- P. McCullagh and J. A. Nelder, "Generalized Linear Models", 2nd ed. (Chapman and Hall, 1989): the
|
|
344
|
+
variance functions and deviances of the families (table 2.1), iteratively reweighted least squares
|
|
345
|
+
(section 2.5), the likelihood ratio and score statistics of the intervals and analysis of deviance, with
|
|
346
|
+
R's behaviour taken from oracle/glm-behaviour.md and R's help pages (no R code was read or used) —
|
|
347
|
+
`src/models/glmFamily.ts`, `src/models/glm.ts`, `src/models/glmConfint.ts`, `src/models/glmAnova.ts`
|
|
338
348
|
|
|
339
349
|
- N. M. Temme, "Incomplete Laplace integrals: uniform asymptotic expansion with application to the
|
|
340
350
|
incomplete beta function", SIAM J. Math. Anal. 18 (1987) 1638–1663, and Temme, "Special Functions: An
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rStats.js 0.
|
|
1
|
+
/*! rStats.js 0.10.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
|
|
2
2
|
var _=!0;function xt(){return _}function qt(t,s){if(!_)return[t+s,0];let n=t+s,o=n-t,u=t-(n-o)+(s-o);return[n,u]}function Mt(t,s){if(!_)return[t*s,0];let n=t*s,o=134217729*t,u=o-(o-t),T=t-u;o=134217729*s;let c=o-(o-s),e=s-c,l=u*c-n+u*e+T*c+T*e;return[n,l]}function Dt(t,s){if(!_)return[t[0]+s[0],0];let n=t[0]+s[0],o=n-t[0],u=t[0]-(n-o)+(s[0]-o),T=t[1]+s[1],c=T-t[1],e=t[1]-(T-c)+(s[1]-c),l=u+T,E=n+l,S=l-(E-n)+e,P=E+S,i=S-(P-E);return[P,i]}function mt(t){return[-t[0],-t[1]]}function gt(t,s){if(!_)return[t[0]-s[0],0];let n=-s[0],o=-s[1],u=t[0]+n,T=u-t[0],c=t[0]-(u-T)+(n-T),e=t[1]+o,l=e-t[1],E=t[1]-(e-l)+(o-l),L=c+e,S=u+L,i=L-(S-u)+E,m=S+i,j=i-(m-S);return[m,j]}function At(t,s){if(!_)return[t[0]*s[0],0];let n=t[0]*s[0],o=134217729*t[0],u=o-(o-t[0]),T=t[0]-u,c=134217729*s[0],e=c-(c-s[0]),l=s[0]-e,L=u*e-n+u*l+T*e+T*l+(t[0]*s[1]+t[1]*s[0]),S=n+L,P=L-(S-n);return[S,P]}function Nt(t,s){if(!_)return[t[0]*s,0];let n=t[0]*s,o=134217729*t[0],u=o-(o-t[0]),T=t[0]-u,c=134217729*s,e=c-(c-s),l=s-e,L=u*e-n+u*l+T*e+T*l+t[1]*s,S=n+L,P=L-(S-n);return[S,P]}function vt(t,s){if(!_)return[t[0]/s[0],0];let n=t[0]/s[0],o=s[0]*n,u=134217729*s[0],T=u-(u-s[0]),c=s[0]-T,e=134217729*n,l=e-(e-n),E=n-l,S=T*l-o+T*E+c*l+c*E+s[1]*n,P=o+S,i=S-(P-o),m=-P,j=-i,f=t[0]+m,Y=f-t[0],P1=t[0]-(f-Y)+(m-Y),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=x-(A-D)+e1,n1=A+X,l1=X-(n1-A);return[n1,l1]}var f1=[.6931471805599453,23190468138462996e-33],g2=Math.SQRT2,r=[[1,0],[.3333333333333333,1850371707708594e-32],[.2,-11102230246251566e-33],[.14285714285714285,793016446160826e-32],[.1111111111111111,61679056923619804e-34],[.09090909090909091,-2523234146875356e-33]],tt=89,nt=[[-.3633938941874773,-2106844752226605e-32],[-.3522205935893521,-57233316949182485e-34],[-.34117075740276714,19366790062602867e-33],[-.33024168687057687,10828321637483858e-33],[-.3194307707663612,-1354256857264811e-33],[-.3087354816496133,16199186085148102e-33],[-.29815337231907635,1720695867445866e-32],[-.2876820724517809,-2607160616442564e-32],[-.27731928541623435,744528405583513e-32],[-.26706278524904525,732891532732017e-32],[-.2569104137850272,-2502843296152504e-32],[-.24686007793152578,-1361743371748368e-32],[-.2369097470783577,-19682402978398164e-34],[-.22705745063534608,-9551415762738488e-33],[-.2173012756899814,-16168452453763015e-34],[-.2076393647782445,-12053243216686129e-33],[-.1980699137620938,-3742843482461439e-33],[-.18859116980755003,7432164219196925e-33],[-.179201429457711,10785017454858423e-33],[-.16989903679539747,4868008764439071e-34],[-.16068238169047347,3650183553047837e-33],[-.15154989812720093,-51669593684615594e-34],[-.14250006260728304,9926388234225749e-33],[-.13353139262452263,3664457663660085e-33],[-.1246424452072766,5808912678940971e-33],[-.1158318155251217,-4338484369808096e-33],[-.1070981355563671,173705104015906e-32],[-.09844007281325252,4439009633675136e-33],[-.08985632912186105,6273760163689594e-34],[-.0813456394539524,-507707635593117e-32],[-.07290677080808779,6306860257532778e-33],[-.06453852113757118,6470486661692933e-33],[-.05623971832287608,32835149805605613e-34],[-.048009219186360606,-14390903347292205e-34],[-.039845908547199674,3129547680315208e-33],[-.0317486983145803,-30382263084680858e-34],[-.023716526617316044,15774243488668215e-34],[-.015748356968139168,-10021578630528974e-34],[-.007843177461025893,-2764708154124904e-34],[0,0],[.007782140442054949,-12819179123343845e-36],[.015504186535965254,-3278321022892429e-34],[.02316705928153438,-11769544932063305e-34],[.030771658666753687,10431732029005968e-34],[.0383188643021366,-2357996157351286e-33],[.0458095360312942,1902959866474257e-33],[.053244514518812285,-1665575816973663e-33],[.06062462181643484,26424025938726934e-34],[.06795066190850775,-12802141240611733e-34],[.07522342123758753,-5930604196293241e-33],[.08244366921107459,5700437773813987e-33],[.08961215868968714,-54268129336647135e-34],[.09672962645855111,-5597397486289965e-34],[.10379679368164356,547772415726659e-32],[.11081436634029011,1183748342825649e-33],[.11778303565638346,-11971685747593677e-34],[.12470347850095724,-46522609636496624e-34],[.13157635778871926,11123000879729588e-33],[.13840232285911913,4447777301357527e-33],[.1451820098444979,8242418783022475e-33],[.15191604202584197,64838631244022194e-34],[.15860503017663857,11257003872182592e-33],[.16524957289530717,-10094935622322628e-33],[.17185025692665923,-60224538210113705e-34],[.1784076574728183,-12432553788701131e-33],[.184922338494012,30236614153574064e-34],[.19139485299962947,-12129496905792884e-33],[.19782574332991987,12821194372980142e-33],[.2042155414286909,27338281018722773e-34],[.21056476910734964,-4249405314729895e-33],[.21687393830061436,4551026193234283e-33],[.22314355131420976,-9091270597324799e-33],[.22937410106484582,9927671823978025e-33],[.2355660713127669,-23943371495187355e-34],[.24171993688714516,8900990022166643e-33],[.24783616390458127,-12432209578702523e-33],[.25391520998096345,-8048097394424201e-33],[.25995752443692605,2069806938978935e-32],[.26596354849713794,53393802761314314e-34],[.27193371548364176,783319637697442e-33],[.2778684510034563,-916018294909263e-33],[.2837681731306446,-2032665581126656e-32],[.28963329258304266,20535953219858174e-33],[.2954642128938359,-216461086040599e-31],[.3012613305781618,-9048511144048564e-33],[.3070250352949119,-12319916200101964e-33],[.3127557100038969,-1451808353098951e-32],[.3184537311185346,27114779367326236e-33],[.324119468654212,-7958214381893813e-33],[.329753286372468,2122020616196946e-33],[.3353555419211378,1834564437059473e-32],[.3409265869705932,17467136443544747e-33],[.34646676734620857,1028583585496265e-32],[.3519764231571782,-12953893030191963e-33],[.3574558889218038,-25136910072413547e-33]];function Gt(t){if(!_)return[Math.log(t[0]),0];let s=t[0],n=t[1],o=0;s<22250738585072014e-324&&(s*=2**600,n*=2**600,o=-600);let u=Math.floor(Math.log2(s));o+=u;let T=2**-u,c=s*T,e=n*T;c>=g2?(c=c/2,e=e/2,o+=1):c<g2/2&&(c=c*2,e=e*2,o-=1);let l=Math.round(c*128),E=l/128,L=nt[l-tt],S=-E,P=-0,i=c+S,m=i-c,j=c-(i-m)+(S-m),f=e+P,Y=f-e,P1=e-(f-Y)+(P-Y),N=j+f,y=i+N,Z=N-(y-i)+P1,d=y+Z,I1=Z-(d-y),v=c+E,p=v-c,z=c-(v-p)+(E-p),h=e+0,B=h-e,o1=e-(h-B)+(0-B),G=z+h,F=v+G,O=G-(F-v)+o1,R=F+O,w1=O-(R-F),w=d/R,H=R*w,T1=134217729*R,J=T1-(T1-R),$=R-J,q=134217729*w,K=q-(q-w),b1=w-K,s1=J*K-H+J*b1+$*K+$*b1+w1*w,r1=H+s1,c1=s1-(r1-H),Q=-r1,x1=-c1,k=d+Q,t1=k-d,F1=d-(k-t1)+(Q-t1),U=I1+x1,M=U-I1,V=I1-(U-M)+(x1-M),D=F1+U,W=k+D,C=D-(W-k)+V,g=W+C,e1=C-(g-W),x=g/R,A=R*x,M1=134217729*R,X=M1-(M1-R),n1=R-X,l1=134217729*x,H1=l1-(l1-x),K0=x-H1,U0=X*H1-A+X*K0+n1*H1+n1*K0+w1*x,V0=A+U0,A2=U0-(V0-A),W0=-V0,X0=-A2,D1=g+W0,Y0=D1-g,N2=g-(D1-Y0)+(W0-Y0),J1=e1+X0,Z0=J1-e1,v2=e1-(J1-Z0)+(X0-Z0),$0=N2+J1,K1=D1+$0,a0=$0-(K1-D1)+v2,ss=K1+a0,et=a0-(ss-K1),ts=ss/R,m1=w+x,U1=x-(m1-w),g1=m1+ts,ns=g1-m1,B2=m1-(g1-ns)+(ts-ns),V1=U1+0,os=V1-U1,G2=U1-(V1-os)+(0-os),cs=B2+V1,W1=g1+cs,es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