@numero-uno-jpn/rstats 1.1.0 → 1.3.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 +142 -0
- package/README.ja.md +33 -15
- package/README.md +32 -14
- package/dist/chunks/{chunk-4KCSBTR5.js → chunk-2VZW4XPK.js} +2 -2
- package/dist/chunks/chunk-4OOTEXZU.js +2 -0
- package/dist/chunks/{chunk-Z2HGLFZN.js → chunk-6TZVS6WC.js} +2 -2
- package/dist/chunks/{chunk-U7BRXOUS.js → chunk-6X2ZMPF5.js} +2 -2
- package/dist/chunks/{chunk-GJEKNJP7.js → chunk-AJZV2SVY.js} +2 -2
- package/dist/chunks/{chunk-GRUQRNX7.js → chunk-BNTBZ5W3.js} +3 -3
- package/dist/chunks/{chunk-DR4GQ7PW.js → chunk-EBRTF7RM.js} +1 -1
- package/dist/chunks/{chunk-OG7UORIX.js → chunk-FFNHG5SB.js} +1 -1
- package/dist/chunks/{chunk-N5BDSMXS.js → chunk-GUM57VVM.js} +1 -1
- package/dist/chunks/{chunk-GGJA3JRO.js → chunk-HBRSUHSU.js} +2 -2
- package/dist/chunks/{chunk-HRA7PCQT.js → chunk-I5NWGQOQ.js} +2 -2
- package/dist/chunks/chunk-IJV43Y7Q.js +2 -0
- package/dist/chunks/{chunk-YN5MLKDL.js → chunk-IOGQEMDE.js} +2 -2
- package/dist/chunks/{chunk-GYGQUYEP.js → chunk-JJRZ2TTF.js} +2 -2
- package/dist/chunks/{chunk-X4J6UJHN.js → chunk-LA4H6ZSC.js} +2 -2
- package/dist/chunks/{chunk-DTJG2IL2.js → chunk-LMNU4NHZ.js} +2 -2
- package/dist/chunks/{chunk-4VRMAYPY.js → chunk-LNUNKFIH.js} +3 -3
- package/dist/chunks/chunk-MJXETGT2.js +2 -0
- package/dist/chunks/chunk-P7ZHH2SF.js +2 -0
- package/dist/chunks/{chunk-HUWOSLKE.js → chunk-PDHBRDTF.js} +2 -2
- package/dist/chunks/{chunk-7KJ24LYK.js → chunk-RCGW2DCK.js} +2 -2
- package/dist/chunks/{chunk-QUTJEYDX.js → chunk-TZTVDVP4.js} +2 -2
- package/dist/chunks/{chunk-HZLSNJQM.js → chunk-UJYRU37Z.js} +2 -2
- package/dist/chunks/{chunk-EJYCDE4Z.js → chunk-UMDXXT3M.js} +1 -1
- package/dist/chunks/{chunk-7IJCUSA5.js → chunk-UOAFEB64.js} +2 -2
- package/dist/chunks/{chunk-JNWWLNE3.js → chunk-Z74ZOTUN.js} +2 -2
- package/dist/descriptive.js +2 -2
- package/dist/distributions.js +2 -2
- package/dist/entries/tests.d.ts +14 -0
- package/dist/entries/tests.js +14 -0
- package/dist/htest/agreement.d.ts +2 -2
- package/dist/htest/binomCI.d.ts +116 -0
- package/dist/htest/binomCI.js +252 -0
- package/dist/htest/blandAltman.d.ts +100 -0
- package/dist/htest/blandAltman.js +159 -0
- package/dist/htest/boschlooTest.d.ts +65 -0
- package/dist/htest/boschlooTest.js +394 -0
- package/dist/htest/chisqTest.d.ts +19 -0
- package/dist/htest/chisqTest.js +30 -2
- package/dist/htest/core/twoProportions.d.ts +48 -0
- package/dist/htest/core/twoProportions.js +476 -0
- package/dist/htest/diagnosticTests.d.ts +91 -0
- package/dist/htest/diagnosticTests.js +116 -0
- package/dist/htest/equivalence.d.ts +172 -0
- package/dist/htest/equivalence.js +189 -0
- package/dist/htest/fisherTest.d.ts +49 -0
- package/dist/htest/fisherTest.js +136 -13
- package/dist/htest/iccPsych.d.ts +106 -0
- package/dist/htest/iccPsych.js +332 -0
- package/dist/htest/ksTest.d.ts +1 -1
- package/dist/htest/mcreg.d.ts +209 -0
- package/dist/htest/mcreg.js +735 -0
- package/dist/htest/roc.d.ts +287 -0
- package/dist/htest/roc.js +635 -0
- package/dist/htest/rocTest.d.ts +139 -0
- package/dist/htest/rocTest.js +444 -0
- package/dist/htest/tTOST.d.ts +202 -0
- package/dist/htest/tTOST.js +558 -0
- package/dist/htest/tableTests.d.ts +216 -0
- package/dist/htest/tableTests.js +650 -0
- package/dist/htest/trendTests.d.ts +1 -1
- package/dist/htest/trendTests.js +1 -1
- package/dist/htest/twoByTwo.d.ts +203 -0
- package/dist/htest/twoByTwo.js +385 -0
- package/dist/internal/summary.js +5 -0
- package/dist/linalg/qr.d.ts +3 -0
- package/dist/linalg/qr.js +3 -0
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +2 -2
- package/dist/models/coeftest.d.ts +139 -0
- package/dist/models/coeftest.js +237 -0
- package/dist/models/coxph.d.ts +60 -9
- package/dist/models/coxph.js +367 -38
- package/dist/models/glm.d.ts +11 -1
- package/dist/models/glm.js +19 -2
- package/dist/models/inputRows.d.ts +10 -0
- package/dist/models/inputRows.js +23 -0
- package/dist/models/lm.d.ts +8 -0
- package/dist/models/lm.js +14 -2
- package/dist/models/sandwich.d.ts +177 -0
- package/dist/models/sandwich.js +923 -0
- package/dist/numerics.js +2 -2
- package/dist/random/rng.d.ts +8 -1
- package/dist/random/rng.js +14 -1
- package/dist/rstats.js +16 -16
- package/dist/special/igam.js +140 -23
- package/dist/special/loader.js +8 -0
- package/dist/special.js +2 -2
- package/dist/tests.js +13 -13
- package/llms.txt +25 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-NDTJ23A6.js +0 -2
- package/dist/chunks/chunk-UMLMY4XS.js +0 -2
- package/dist/chunks/chunk-Y4YWLSWU.js +0 -2
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
// Score statistics of two independent binomial proportions x1/n1 and x2/n2 under a restriction (a given difference,
|
|
2
|
+
// ratio or odds ratio), and the roots that make their confidence limits. Shared by binomDiffCI, binomRatioCI and
|
|
3
|
+
// oddsRatio (src/htest/twoByTwo.ts); the statistics at a given difference are what a test of equivalence uses.
|
|
4
|
+
//
|
|
5
|
+
// Written for rStats.js from the papers:
|
|
6
|
+
// - Difference: the maximum likelihood estimate under p1 - p2 = delta, the root of the score equation of Farrington
|
|
7
|
+
// and Manning (Statistics in Medicine 9, 1990, 1447-1454) started from the closed (trigonometric) form of their
|
|
8
|
+
// cubic, and the statistic
|
|
9
|
+
// (p1 - p2 - delta)^2 / var(delta) with var = p1~(1 - p1~)/n1 + p2~(1 - p2~)/n2: Miettinen and Nurminen (Statistics
|
|
10
|
+
// in Medicine 4, 1985, 213-226) multiply var by N/(N - 1); Mee (Biometrics 40, 1984) and Farrington-Manning do not.
|
|
11
|
+
// - Ratio: Koopman (Biometrics 40, 1984, 513-517): Pearson's statistic at the MLE under p1 = phi p2, whose p1~ is the
|
|
12
|
+
// smaller root of a quadratic (Nam, Biometrics 51, 1995, gives the same limits in closed form).
|
|
13
|
+
// - Odds ratio: the score statistic at the MLE under (p1/(1 - p1)) / (p2/(1 - p2)) = theta (the root of a quadratic
|
|
14
|
+
// in p2~; Miettinen and Nurminen 1985 without the factor N/(N - 1), i.e. Cornfield's uncorrected chi-squared).
|
|
15
|
+
// The limits are the roots of statistic = bound on either side of the estimate, found by Brent's method to the
|
|
16
|
+
// precision of the doubles (on the log scale for the ratio and the odds ratio); the statistic enters through
|
|
17
|
+
// T/(1 + T), which is finite also where T is infinite (a variance of 0 at the end of the range).
|
|
18
|
+
import { logScaleRoot, uniroot } from "../../internal/uniroot.js";
|
|
19
|
+
import { ddAdd, ddDivNum, ddMul, ddMulNum, ddSub, twoProd, twoSum } from "../../special/dd.js";
|
|
20
|
+
/** T / (1 + T) for T >= 0, 1 for T = Infinity: a bounded, increasing function of a statistic */
|
|
21
|
+
function bounded(t) {
|
|
22
|
+
return t === Infinity ? 1 : t / (1 + t);
|
|
23
|
+
}
|
|
24
|
+
/** a^2 / b where 0 / 0 is 0 (a term of a statistic whose cell is fitted exactly at the end of the range) */
|
|
25
|
+
function term(num, den) {
|
|
26
|
+
if (num === 0)
|
|
27
|
+
return 0;
|
|
28
|
+
return den > 0 ? (num * num) / den : Infinity;
|
|
29
|
+
}
|
|
30
|
+
// ---- difference ----
|
|
31
|
+
/**
|
|
32
|
+
* Whether the counts are taken as failures (x -> n - x, delta -> -delta, each proportion -> 1 - p): where
|
|
33
|
+
* p1 + p2 > 1, so that the proportions worked with are the smaller ones. The statistics are the same in either
|
|
34
|
+
* orientation, but x / n near 1 holds only the absolute precision eps (1 - (1e15 - 1)/1e15 is 1e-15 off by 5%), and so
|
|
35
|
+
* does 1 - p~ formed from a p~ near 1
|
|
36
|
+
*/
|
|
37
|
+
function failures(x1, n1, x2, n2) {
|
|
38
|
+
return x1 / n1 + x2 / n2 > 1;
|
|
39
|
+
}
|
|
40
|
+
/** p1 - p2, rounded once (diffDeviation at 0) */
|
|
41
|
+
export function diffEstimate(x1, n1, x2, n2) {
|
|
42
|
+
return diffDeviation(x1, n1, x2, n2, 0);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The maximum likelihood estimate of two proportions under p1 - p2 = delta (-1 <= delta <= 1) with the complements:
|
|
46
|
+
* [p1~, 1 - p1~, p2~, 1 - p2~], each to nearly the precision of the doubles.
|
|
47
|
+
*
|
|
48
|
+
* The estimate is the root of the score equation (Farrington and Manning 1990). With s the smaller of p1~ and p2~
|
|
49
|
+
* (group s, xs of ns) and D = |delta|, the other is s + D (group l) and
|
|
50
|
+
* f(s) = xs/s - (ns - xs)/(1 - s) + xl/(s + D) - (nl - xl)/(1 - D - s) = 0, 0 <= s <= 1 - D,
|
|
51
|
+
* f decreasing; s = 0 where f(0) <= 0 and s = 1 - D where f(1 - D) >= 0. Solved by Newton's method kept inside the
|
|
52
|
+
* bracket by bisection (geometric where the bracket spans more than a factor 2), from the trigonometric solution of
|
|
53
|
+
* Farrington and Manning's cubic. That closed form alone has only the absolute precision eps: 4.337e-9 for 2.713e-9
|
|
54
|
+
* at 5/1e9 against 2/1e9 and delta = -1e-8, and the upper limit of 1/1e8 against 0/1e8 was 4e-3 relative off. Working
|
|
55
|
+
* with s and D (not p1~ - delta, nor 1 - p near 1: see `failures`) keeps the relative precision of small proportions
|
|
56
|
+
*/
|
|
57
|
+
function restrictedMleDiffFull(x1, n1, x2, n2, delta) {
|
|
58
|
+
if (failures(x1, n1, x2, n2)) {
|
|
59
|
+
const [q1, r1, q2, r2] = restrictedMleDiffFull(n1 - x1, n1, n2 - x2, n2, -delta);
|
|
60
|
+
return [r1, q1, r2, q2];
|
|
61
|
+
}
|
|
62
|
+
// group s has the smaller restricted proportion: group 1 where delta <= 0 (p1~ = p2~ + delta)
|
|
63
|
+
const oneSmaller = delta <= 0;
|
|
64
|
+
const [xs, ns, xl, nl] = oneSmaller ? [x1, n1, x2, n2] : [x2, n2, x1, n1];
|
|
65
|
+
const D = Math.abs(delta);
|
|
66
|
+
// 1 - D: exact for D >= 1/2, within half an ulp of a value above 1/2 otherwise
|
|
67
|
+
const top = 1 - D;
|
|
68
|
+
let s = 0;
|
|
69
|
+
if (top > 0) {
|
|
70
|
+
const f = (v) => {
|
|
71
|
+
let r = 0;
|
|
72
|
+
if (xs > 0)
|
|
73
|
+
r += xs / v;
|
|
74
|
+
if (xs < ns)
|
|
75
|
+
r -= (ns - xs) / (1 - v);
|
|
76
|
+
if (xl > 0)
|
|
77
|
+
r += xl / (v + D);
|
|
78
|
+
if (xl < nl)
|
|
79
|
+
r -= (nl - xl) / (top - v);
|
|
80
|
+
return r;
|
|
81
|
+
};
|
|
82
|
+
const df = (v) => {
|
|
83
|
+
let r = 0;
|
|
84
|
+
if (xs > 0)
|
|
85
|
+
r -= xs / (v * v);
|
|
86
|
+
if (xs < ns)
|
|
87
|
+
r -= (ns - xs) / ((1 - v) * (1 - v));
|
|
88
|
+
if (xl > 0)
|
|
89
|
+
r -= xl / ((v + D) * (v + D));
|
|
90
|
+
if (xl < nl)
|
|
91
|
+
r -= (nl - xl) / ((top - v) * (top - v));
|
|
92
|
+
return r;
|
|
93
|
+
};
|
|
94
|
+
// at the ends f is finite or +Infinity at 0 and -Infinity at 1 - D (only positive terms divide by 0 at 0, and only
|
|
95
|
+
// negative ones at 1 - D)
|
|
96
|
+
const f0 = f(0);
|
|
97
|
+
if (f0 <= 0)
|
|
98
|
+
s = 0;
|
|
99
|
+
else if (f(top) >= 0)
|
|
100
|
+
s = top;
|
|
101
|
+
else {
|
|
102
|
+
let a = 0;
|
|
103
|
+
let b = top;
|
|
104
|
+
const guess = closedFormMleDiff(x1, n1, x2, n2, delta);
|
|
105
|
+
s = oneSmaller ? guess : guess - delta;
|
|
106
|
+
if (!(s > a && s < b))
|
|
107
|
+
s = b / 2;
|
|
108
|
+
for (let i = 0; i < 2000; i++) {
|
|
109
|
+
const fs = f(s);
|
|
110
|
+
if (fs === 0)
|
|
111
|
+
break;
|
|
112
|
+
if (fs > 0)
|
|
113
|
+
a = s;
|
|
114
|
+
else
|
|
115
|
+
b = s;
|
|
116
|
+
let next = s - fs / df(s);
|
|
117
|
+
if (!(next > a && next < b))
|
|
118
|
+
next = a === 0 ? b / 2 : b > 2 * a ? Math.sqrt(a * b) : a + (b - a) / 2;
|
|
119
|
+
if (!(next > a && next < b))
|
|
120
|
+
break;
|
|
121
|
+
const step = Math.abs(next - s);
|
|
122
|
+
s = next;
|
|
123
|
+
if (step <= 2 ** -53 * s)
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const sl = [s, 1 - s, Math.min(1, s + D), Math.max(0, top - s)];
|
|
129
|
+
return oneSmaller ? sl : [sl[2], sl[3], sl[0], sl[1]];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The trigonometric solution of Farrington and Manning's cubic for p1~ under p1 - p2 = delta, with t = n2 / n1:
|
|
133
|
+
* a = 1 + t, b = -(1 + t + p1 + t p2 + delta (t + 2)), c = delta^2 + delta (2 p1 + t + 1) + p1 + t p2,
|
|
134
|
+
* d = -p1 delta (1 + delta); v = (b/(3a))^3 - bc/(6a^2) + d/(2a), u = sign(v) sqrt((b/(3a))^2 - c/(3a)),
|
|
135
|
+
* w = (pi + acos(v/u^3))/3, p1~ = 2u cos(w) - b/(3a). Accurate to about eps absolute: the start of the iteration
|
|
136
|
+
*/
|
|
137
|
+
function closedFormMleDiff(x1, n1, x2, n2, delta) {
|
|
138
|
+
const p1 = x1 / n1;
|
|
139
|
+
const p2 = x2 / n2;
|
|
140
|
+
const t = n2 / n1;
|
|
141
|
+
const a = 1 + t;
|
|
142
|
+
const b = -(1 + t + p1 + t * p2 + delta * (t + 2));
|
|
143
|
+
const c = delta * delta + delta * (2 * p1 + t + 1) + p1 + t * p2;
|
|
144
|
+
const d = -p1 * delta * (1 + delta);
|
|
145
|
+
const b3a = b / (3 * a);
|
|
146
|
+
const v = b3a * b3a * b3a - (b * c) / (6 * a * a) + d / (2 * a);
|
|
147
|
+
const u = Math.sign(v) * Math.sqrt(Math.max(0, b3a * b3a - c / (3 * a)));
|
|
148
|
+
if (u === 0)
|
|
149
|
+
return -b3a;
|
|
150
|
+
const w = (Math.PI + Math.acos(Math.max(-1, Math.min(1, v / (u * u * u))))) / 3;
|
|
151
|
+
return 2 * u * Math.cos(w) - b3a;
|
|
152
|
+
}
|
|
153
|
+
/** The maximum likelihood estimate (p1~, p2~) of two proportions under p1 - p2 = delta (see restrictedMleDiffFull) */
|
|
154
|
+
export function restrictedMleDiff(x1, n1, x2, n2, delta) {
|
|
155
|
+
const [q1, , q2] = restrictedMleDiffFull(x1, n1, x2, n2, delta);
|
|
156
|
+
return [q1, q2];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The variance of p1 - p2 used by the score statistic at the difference delta: at the restricted MLE times N/(N - 1)
|
|
160
|
+
* (Miettinen-Nurminen, "mn"), at the restricted MLE ("mee", Farrington-Manning), or at the observed proportions
|
|
161
|
+
* ("wald"); each 1 - p without cancellation
|
|
162
|
+
*/
|
|
163
|
+
export function diffVariance(x1, n1, x2, n2, delta, kind) {
|
|
164
|
+
if (kind === "wald")
|
|
165
|
+
return ((x1 / n1) * ((n1 - x1) / n1)) / n1 + ((x2 / n2) * ((n2 - x2) / n2)) / n2;
|
|
166
|
+
const [q1, r1, q2, r2] = restrictedMleDiffFull(x1, n1, x2, n2, delta);
|
|
167
|
+
const v = (q1 * r1) / n1 + (q2 * r2) / n2;
|
|
168
|
+
if (kind === "mee")
|
|
169
|
+
return v;
|
|
170
|
+
const N = n1 + n2;
|
|
171
|
+
return (v * N) / (N - 1);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* (p1 - p2 - delta)^2 - bound var(delta) in double-double (the score methods): its sign tells statistic > bound
|
|
175
|
+
* without the roundings of the statistic (a few ulps of it, each moving a limit by about an ulp)
|
|
176
|
+
*/
|
|
177
|
+
function diffExcess(x1, n1, x2, n2, delta, kind, bound) {
|
|
178
|
+
const dev = ddSub(ddSub(ddDivNum([x1, 0], n1), ddDivNum([x2, 0], n2)), [delta, 0]);
|
|
179
|
+
const [q1, r1, q2, r2] = restrictedMleDiffFull(x1, n1, x2, n2, delta);
|
|
180
|
+
let v = ddAdd(ddDivNum(twoProd(q1, r1), n1), ddDivNum(twoProd(q2, r2), n2));
|
|
181
|
+
if (kind === "mn")
|
|
182
|
+
v = ddDivNum(ddMulNum(v, n1 + n2), n1 + n2 - 1);
|
|
183
|
+
return ddSub(ddMul(dev, dev), ddMulNum(v, bound))[0];
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* p1 - p2 - delta from the counts in double-double, rounded once: x1/n1 - x2/n2 in double cancels where the
|
|
187
|
+
* proportions are close (each holds only its absolute precision: 1 - (1e15 - 1)/1e15 is 1e-15 off by 5%, and
|
|
188
|
+
* 0.22 - 0.2 is 1e-17 off, an ulp of the limit 0.1155 of 80/100 against 78/100 at 90%)
|
|
189
|
+
*/
|
|
190
|
+
export function diffDeviation(x1, n1, x2, n2, delta) {
|
|
191
|
+
return ddSub(ddSub(ddDivNum([x1, 0], n1), ddDivNum([x2, 0], n2)), [delta, 0])[0];
|
|
192
|
+
}
|
|
193
|
+
/** The squared score statistic (p1 - p2 - delta)^2 / var(delta); 0 at delta = p1 - p2, Infinity where var is 0 */
|
|
194
|
+
export function diffStatistic(x1, n1, x2, n2, delta, kind) {
|
|
195
|
+
return term(diffDeviation(x1, n1, x2, n2, delta), diffVariance(x1, n1, x2, n2, delta, kind));
|
|
196
|
+
}
|
|
197
|
+
const f64 = new Float64Array(1);
|
|
198
|
+
const i64 = new BigInt64Array(f64.buffer);
|
|
199
|
+
/** An integer key of a finite double that orders as the doubles do (consecutive doubles have consecutive keys) */
|
|
200
|
+
function keyOf(x) {
|
|
201
|
+
f64[0] = Math.abs(x);
|
|
202
|
+
return x < 0 ? -i64[0] : i64[0];
|
|
203
|
+
}
|
|
204
|
+
function fromKey(k) {
|
|
205
|
+
i64[0] = k < 0n ? -k : k;
|
|
206
|
+
return k < 0n ? -f64[0] : f64[0];
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The double at the sign change of g (increasing where `increasing`) within [lo, hi], from a root r found to a few ulps
|
|
210
|
+
* or a few eps |log r|: Brent stops once its bracket is within 4 eps |r|, which left a limit of the difference up to
|
|
211
|
+
* 4 ulps from the change (0.11553638647686573 for 0.11553638647686568), and on the log scale within 4 eps |log r|
|
|
212
|
+
* (13 eps at the ratio 2e-17). Searches from r in steps of 1, 2, 4, ... ulps for the change, bisects the doubles
|
|
213
|
+
* between, and returns the one of the two neighbours at the change with the smaller |g|
|
|
214
|
+
*/
|
|
215
|
+
function polishRoot(g, r, lo, hi, increasing) {
|
|
216
|
+
const gr = g(r);
|
|
217
|
+
if (gr === 0 || Number.isNaN(gr))
|
|
218
|
+
return r;
|
|
219
|
+
// g(r) > 0 on the increasing side means the change lies below r
|
|
220
|
+
const up = (gr < 0) === increasing;
|
|
221
|
+
const end = keyOf(up ? hi : lo);
|
|
222
|
+
let a = keyOf(r);
|
|
223
|
+
let ga = gr;
|
|
224
|
+
let b = a;
|
|
225
|
+
let gb = gr;
|
|
226
|
+
let step = 1n;
|
|
227
|
+
for (;;) {
|
|
228
|
+
b = up ? a + step : a - step;
|
|
229
|
+
if (up ? b >= end : b <= end)
|
|
230
|
+
b = end;
|
|
231
|
+
gb = g(fromKey(b));
|
|
232
|
+
if (gb === 0)
|
|
233
|
+
return fromKey(b);
|
|
234
|
+
if (gb < 0 !== ga < 0 || b === end)
|
|
235
|
+
break;
|
|
236
|
+
a = b;
|
|
237
|
+
ga = gb;
|
|
238
|
+
step *= 2n;
|
|
239
|
+
if (step > 1n << 40n)
|
|
240
|
+
return fromKey(a);
|
|
241
|
+
}
|
|
242
|
+
if (gb < 0 === ga < 0 || Number.isNaN(gb))
|
|
243
|
+
return fromKey(a);
|
|
244
|
+
// a and b on either side of the change: bisect the keys until they are neighbours
|
|
245
|
+
while (b - a > 1n || a - b > 1n) {
|
|
246
|
+
const m = (a + b) / 2n;
|
|
247
|
+
const gm = g(fromKey(m));
|
|
248
|
+
if (gm === 0)
|
|
249
|
+
return fromKey(m);
|
|
250
|
+
if (gm < 0 === ga < 0) {
|
|
251
|
+
a = m;
|
|
252
|
+
ga = gm;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
b = m;
|
|
256
|
+
gb = gm;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return Math.abs(gb) < Math.abs(ga) ? fromKey(b) : fromKey(a);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* The limits [lower, upper] of {delta in [-1, 1] : statistic(delta) <= bound} around est = p1 - p2: the roots of
|
|
263
|
+
* statistic = bound below and above est (-1 or 1 where est is at the end)
|
|
264
|
+
*/
|
|
265
|
+
export function diffScoreLimits(x1, n1, x2, n2, bound, kind) {
|
|
266
|
+
const est = diffEstimate(x1, n1, x2, n2);
|
|
267
|
+
if (bound === 0)
|
|
268
|
+
return [est, est];
|
|
269
|
+
const target = bounded(bound);
|
|
270
|
+
const g = (delta) => (delta === est ? 0 : bounded(diffStatistic(x1, n1, x2, n2, delta, kind))) - target;
|
|
271
|
+
const root = (lo, hi, gLo, gHi) => {
|
|
272
|
+
if (gLo === 0)
|
|
273
|
+
return lo;
|
|
274
|
+
if (gHi === 0)
|
|
275
|
+
return hi;
|
|
276
|
+
const r = uniroot(g, lo, hi, { tol: 1e-300, fLower: gLo, fUpper: gHi });
|
|
277
|
+
return kind === "wald" ? r : polishRoot((d) => diffExcess(x1, n1, x2, n2, d, kind, bound), r, lo, hi, gLo < 0);
|
|
278
|
+
};
|
|
279
|
+
const gm = g(-1);
|
|
280
|
+
const gp = g(1);
|
|
281
|
+
const lower = est <= -1 || gm <= 0 ? -1 : root(-1, est, gm, -target);
|
|
282
|
+
const upper = est >= 1 || gp <= 0 ? 1 : root(est, 1, -target, gp);
|
|
283
|
+
return [lower, upper];
|
|
284
|
+
}
|
|
285
|
+
// ---- roots on the log scale ----
|
|
286
|
+
/**
|
|
287
|
+
* The root of g(u) = h(exp(u)) - target, h increasing in |u - u0| from h(exp(u0)) <= target, on the side of u0 given by
|
|
288
|
+
* dir: the bracket is widened from u0 by steps that double, and the root solved by Brent's method; 0 (dir -1) or
|
|
289
|
+
* Infinity (dir 1) when no root lies within the doubles
|
|
290
|
+
*/
|
|
291
|
+
function logSideRoot(g, u0, dir) {
|
|
292
|
+
let a = u0;
|
|
293
|
+
let ga = g(u0);
|
|
294
|
+
if (ga >= 0)
|
|
295
|
+
return Math.exp(u0);
|
|
296
|
+
let step = 1;
|
|
297
|
+
for (;;) {
|
|
298
|
+
const b = u0 + dir * step;
|
|
299
|
+
if (Math.abs(b) > 745)
|
|
300
|
+
return dir < 0 ? 0 : Infinity;
|
|
301
|
+
const gb = g(b);
|
|
302
|
+
if (gb >= 0) {
|
|
303
|
+
if (gb === 0)
|
|
304
|
+
return Math.exp(b);
|
|
305
|
+
const r = dir > 0 ? uniroot(g, a, b, { tol: 2 ** -60, fLower: ga, fUpper: gb }) : uniroot(g, b, a, { tol: 2 ** -60, fLower: gb, fUpper: ga });
|
|
306
|
+
return Math.exp(r);
|
|
307
|
+
}
|
|
308
|
+
a = b;
|
|
309
|
+
ga = gb;
|
|
310
|
+
step *= 2;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// ---- ratio ----
|
|
314
|
+
/**
|
|
315
|
+
* The MLE p1~ under p1 = phi p2 (Koopman 1984): the smaller root of
|
|
316
|
+
* (n1 + n2) p^2 - (phi (n1 + x2) + x1 + n2) p + phi (x1 + x2) = 0, capped at min(1, phi); p2~ = p1~ / phi. Accurate to
|
|
317
|
+
* about eps absolute (the discriminant cancels where the roots are close): the start of restrictedMleRatioFull
|
|
318
|
+
*/
|
|
319
|
+
export function restrictedMleRatio(x1, n1, x2, n2, phi) {
|
|
320
|
+
const A = n1 + n2;
|
|
321
|
+
const B = phi * (n1 + x2) + x1 + n2;
|
|
322
|
+
const C = phi * (x1 + x2);
|
|
323
|
+
// the smaller root (B - sqrt(B^2 - 4AC)) / (2A), in the form without cancellation
|
|
324
|
+
const disc = Math.sqrt(Math.max(0, B * B - 4 * A * C));
|
|
325
|
+
const q1 = Math.min(1, phi, C === 0 ? 0 : (2 * C) / (B + disc));
|
|
326
|
+
return [q1, Math.min(1, q1 / phi)];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The MLE under p1 = phi p2 with the complements, [p1~, 1 - p1~, p2~, 1 - p2~], each to nearly the precision of the
|
|
330
|
+
* doubles. The closed form (restrictedMleRatio) holds about eps absolute, so 1 - p~ near 0 lost its digits (the upper
|
|
331
|
+
* limit of 1/2^53 against 2^53/2^53 was 4.4409e-16 for 6.2893e-16, the lower of 1e15/1e15 against (1e15 - 1)/1e15
|
|
332
|
+
* was 1). The root of the score in p2~, S = m/p2 - phi (n1 - x1)/(1 - p1) - (n2 - x2)/(1 - p2) (m = x1 + x2,
|
|
333
|
+
* decreasing), is solved by Newton's method kept in its bracket, in p2~, 1 - p2~ or 1 - p1~ (chosen at the closed
|
|
334
|
+
* form's estimate), from which the others are formed in double-double
|
|
335
|
+
*/
|
|
336
|
+
function restrictedMleRatioFull(x1, n1, x2, n2, phi) {
|
|
337
|
+
const [c1, c2] = restrictedMleRatio(x1, n1, x2, n2, phi);
|
|
338
|
+
if (!(phi > 0 && phi < Infinity))
|
|
339
|
+
return [c1, 1 - c1, c2, 1 - c2];
|
|
340
|
+
// the variable: 0 = p2~, 2 = 1 - p2~, 3 = 1 - p1~; p2~ as a function of it, in double-double. The rounding of v
|
|
341
|
+
// (eps v) moves each other quantity by at most about eps times itself: v = p2~ where both are at most 1/2 (1 - p1~
|
|
342
|
+
// moves by eps p1~), otherwise v = 1 - p2~ where phi (1 - p2~) <= 1 - p1~ (1 - p1~ = 1 - phi + phi v moves by
|
|
343
|
+
// eps phi v) and v = 1 - p1~ elsewhere. (With v = p1~, 3/1e15 against (1e15 - 1)/1e15 failed: 1 - p2~ = 1 - v/phi
|
|
344
|
+
// moves by eps p2~, 10% of its 1e-15)
|
|
345
|
+
const mode = c1 <= 0.5 && c2 <= 0.5 ? 0 : phi * (1 - c2) <= 1 - c1 ? 2 : 3;
|
|
346
|
+
const start = mode === 0 ? c2 : mode === 2 ? 1 - c2 : 1 - c1;
|
|
347
|
+
const p2Of = (v) => (mode === 0 ? [v, 0] : mode === 2 ? twoSum(1, -v) : ddDivNum(twoSum(1, -v), phi));
|
|
348
|
+
// |d p2~ / dv| and the range of v (p2~ in [0, min(1, 1/phi)], p1~ = phi p2~ in [0, min(1, phi)])
|
|
349
|
+
const slope = mode === 3 ? 1 / phi : 1;
|
|
350
|
+
const vMax = mode === 0 ? Math.min(1, 1 / phi) : 1;
|
|
351
|
+
const vMin = mode === 2 ? (phi > 1 ? ddDivNum(twoSum(phi, -1), phi)[0] : 0) : mode === 3 ? (phi < 1 ? twoSum(1, -phi)[0] : 0) : 0;
|
|
352
|
+
const parts = (v) => {
|
|
353
|
+
const p2 = p2Of(v);
|
|
354
|
+
const p1 = ddMulNum(p2, phi);
|
|
355
|
+
return [p1[0], ddSub([1, 0], p1)[0], p2[0], ddSub([1, 0], p2)[0]];
|
|
356
|
+
};
|
|
357
|
+
const m = x1 + x2;
|
|
358
|
+
// h(v) = S as a function of v, made decreasing (p2~ decreases in v for modes 2 and 3), and h'(v)
|
|
359
|
+
const sign = mode < 2 ? 1 : -1;
|
|
360
|
+
// (a count over a value that has rounded to 0 or below at the end of the range counts as infinite)
|
|
361
|
+
const h = (v) => {
|
|
362
|
+
const [, r1, q2, r2] = parts(v);
|
|
363
|
+
let s = 0;
|
|
364
|
+
let ds = 0;
|
|
365
|
+
if (m > 0) {
|
|
366
|
+
s += q2 > 0 ? m / q2 : Infinity;
|
|
367
|
+
ds -= m / (q2 * q2);
|
|
368
|
+
}
|
|
369
|
+
if (x1 < n1) {
|
|
370
|
+
s -= r1 > 0 ? (phi * (n1 - x1)) / r1 : Infinity;
|
|
371
|
+
ds -= ((phi * (n1 - x1)) / r1) * (phi / r1);
|
|
372
|
+
}
|
|
373
|
+
if (x2 < n2) {
|
|
374
|
+
s -= r2 > 0 ? (n2 - x2) / r2 : Infinity;
|
|
375
|
+
ds -= (n2 - x2) / (r2 * r2);
|
|
376
|
+
}
|
|
377
|
+
return [sign * s, ds * slope];
|
|
378
|
+
};
|
|
379
|
+
let v;
|
|
380
|
+
if (!(vMax > vMin))
|
|
381
|
+
v = vMin;
|
|
382
|
+
else if (!(h(vMin)[0] > 0))
|
|
383
|
+
v = vMin;
|
|
384
|
+
else if (!(h(vMax)[0] < 0))
|
|
385
|
+
v = vMax;
|
|
386
|
+
else {
|
|
387
|
+
let a = vMin;
|
|
388
|
+
let b = vMax;
|
|
389
|
+
v = start;
|
|
390
|
+
if (!(v > a && v < b))
|
|
391
|
+
v = a + (b - a) / 2;
|
|
392
|
+
for (let i = 0; i < 2000; i++) {
|
|
393
|
+
const [hv, dh] = h(v);
|
|
394
|
+
if (hv === 0)
|
|
395
|
+
break;
|
|
396
|
+
if (hv > 0)
|
|
397
|
+
a = v;
|
|
398
|
+
else
|
|
399
|
+
b = v;
|
|
400
|
+
let next = v - hv / dh;
|
|
401
|
+
if (!(next > a && next < b))
|
|
402
|
+
next = a <= 0 ? b / 2 : b > 2 * a ? Math.sqrt(a * b) : a + (b - a) / 2;
|
|
403
|
+
if (!(next > a && next < b))
|
|
404
|
+
break;
|
|
405
|
+
const step = Math.abs(next - v);
|
|
406
|
+
v = next;
|
|
407
|
+
if (step <= 2 ** -53 * v)
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
const [q1, r1, q2, r2] = parts(v);
|
|
412
|
+
return [Math.min(1, Math.max(0, q1)), Math.min(1, Math.max(0, r1)), Math.min(1, Math.max(0, q2)), Math.min(1, Math.max(0, r2))];
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Koopman's statistic: Pearson's chi-squared of the two groups at the MLE under p1 = phi p2 (a 0/0 term counts 0);
|
|
416
|
+
* x - n p~ is formed as n (1 - p~) - (n - x) where p~ > 1/2, with 1 - p~ from restrictedMleRatioFull
|
|
417
|
+
*/
|
|
418
|
+
export function ratioStatistic(x1, n1, x2, n2, phi) {
|
|
419
|
+
const [q1, r1, q2, r2] = restrictedMleRatioFull(x1, n1, x2, n2, phi);
|
|
420
|
+
const dev = (x, n, q, r) => (q > 0.5 ? n * r - (n - x) : x - n * q);
|
|
421
|
+
return term(dev(x1, n1, q1, r1), n1 * q1 * r1) + term(dev(x2, n2, q2, r2), n2 * q2 * r2);
|
|
422
|
+
}
|
|
423
|
+
/** Koopman's interval {phi : statistic(phi) <= bound} around est = p1 / p2 (not both counts 0) */
|
|
424
|
+
export function ratioScoreLimits(x1, n1, x2, n2, bound) {
|
|
425
|
+
const est = x1 / n1 / (x2 / n2);
|
|
426
|
+
return logScoreLimits(est, bound, (phi) => ratioStatistic(x1, n1, x2, n2, phi));
|
|
427
|
+
}
|
|
428
|
+
// ---- odds ratio ----
|
|
429
|
+
/**
|
|
430
|
+
* The MLE (p1~, p2~) under (p1/(1 - p1)) / (p2/(1 - p2)) = theta: p2~ is the root in [0, 1] of A p^2 + B p + C = 0 with
|
|
431
|
+
* A = n2 (theta - 1), B = n1 theta + n2 - (x1 + x2)(theta - 1), C = -(x1 + x2), written 2(x1 + x2) / (B + sqrt(B^2 - 4AC))
|
|
432
|
+
* (no cancellation, and (x1 + x2) / (n1 + n2) at theta = 1); p1~ = p2~ theta / (1 + p2~ (theta - 1))
|
|
433
|
+
*/
|
|
434
|
+
export function restrictedMleOddsRatio(x1, n1, x2, n2, theta) {
|
|
435
|
+
const m = x1 + x2;
|
|
436
|
+
const A = n2 * (theta - 1);
|
|
437
|
+
const B = n1 * theta + n2 - m * (theta - 1);
|
|
438
|
+
const q2 = m === 0 ? 0 : Math.min(1, (2 * m) / (B + Math.sqrt(Math.max(0, B * B + 4 * A * m))));
|
|
439
|
+
const q1 = theta === Infinity ? (q2 > 0 ? 1 : 0) : Math.min(1, (q2 * theta) / (1 + q2 * (theta - 1)));
|
|
440
|
+
return [q1, q2];
|
|
441
|
+
}
|
|
442
|
+
/** The score statistic of the odds ratio at theta: (x1 - n1 p1~)^2 (1/(n1 p1~ q1~) + 1/(n2 p2~ q2~)) */
|
|
443
|
+
export function oddsRatioStatistic(x1, n1, x2, n2, theta) {
|
|
444
|
+
const [q1, q2] = restrictedMleOddsRatio(x1, n1, x2, n2, theta);
|
|
445
|
+
const dev = x1 - n1 * q1;
|
|
446
|
+
return term(dev, n1 * q1 * (1 - q1)) + term(dev, n2 * q2 * (1 - q2));
|
|
447
|
+
}
|
|
448
|
+
/** The score interval of the odds ratio around est = x1 (n2 - x2) / ((n1 - x1) x2) (est 0 or Infinity, not NaN) */
|
|
449
|
+
export function oddsRatioScoreLimits(x1, n1, x2, n2, bound) {
|
|
450
|
+
const est = (x1 * (n2 - x2)) / ((n1 - x1) * x2);
|
|
451
|
+
return logScoreLimits(est, bound, (theta) => oddsRatioStatistic(x1, n1, x2, n2, theta));
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* The roots of stat = bound on both sides of est (where stat is 0), solved on the log scale. Where est is 0 or
|
|
455
|
+
* Infinity (a zero count), that limit is est and the other is solved from a bracket around 1 (logScaleRoot). The roots
|
|
456
|
+
* are then moved to the sign change of stat - bound among the doubles (polishRoot)
|
|
457
|
+
*/
|
|
458
|
+
function logScoreLimits(est, bound, stat) {
|
|
459
|
+
if (bound === 0)
|
|
460
|
+
return [est, est];
|
|
461
|
+
const target = bounded(bound);
|
|
462
|
+
// the raw comparison for the polish (stat increases away from est)
|
|
463
|
+
const h = (v) => stat(v) - bound;
|
|
464
|
+
const below = (r) => (r > 0 && r < est ? polishRoot(h, r, Number.MIN_VALUE, est, false) : r);
|
|
465
|
+
const above = (r) => (r > est && r < Infinity ? polishRoot(h, r, est, Number.MAX_VALUE, true) : r);
|
|
466
|
+
if (est === 0 || est === Infinity) {
|
|
467
|
+
// stat increases in v from est = 0, and decreases in v towards est = Infinity
|
|
468
|
+
const f = (v) => bounded(stat(v)) - target;
|
|
469
|
+
const f1 = f(1);
|
|
470
|
+
const root = f1 === 0 ? 1 : logScaleRoot(f, est === 0 ? f1 > 0 : f1 < 0);
|
|
471
|
+
return est === 0 ? [0, above(root)] : [below(root), Infinity];
|
|
472
|
+
}
|
|
473
|
+
const u0 = Math.log(est);
|
|
474
|
+
const g = (u) => (u === u0 ? 0 : bounded(stat(Math.exp(u)))) - target;
|
|
475
|
+
return [below(logSideRoot(g, u0, -1)), above(logSideRoot(g, u0, 1))];
|
|
476
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@link diagnosticTests}.
|
|
3
|
+
*
|
|
4
|
+
* @category Hypothesis tests
|
|
5
|
+
*/
|
|
6
|
+
export interface DiagnosticTestsOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The interval of the proportions: `"exact"` (default; Clopper-Pearson), `"wilson"` or `"jeffreys"`;
|
|
9
|
+
* abbreviations are accepted.
|
|
10
|
+
*/
|
|
11
|
+
method?: "exact" | "wilson" | "jeffreys" | (string & {});
|
|
12
|
+
/** Confidence level, in (0, 1). Default `0.95`. */
|
|
13
|
+
confLevel?: number;
|
|
14
|
+
/** A prevalence in (0, 1) at which to give the predictive values as well (`ppvAtPrevalence`, `npvAtPrevalence`). */
|
|
15
|
+
prevalence?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An estimate with its confidence interval.
|
|
19
|
+
*
|
|
20
|
+
* @category Hypothesis tests
|
|
21
|
+
*/
|
|
22
|
+
export interface DiagnosticMeasure {
|
|
23
|
+
/** The estimate. */
|
|
24
|
+
estimate: number;
|
|
25
|
+
/** The interval `[lower, upper]`. */
|
|
26
|
+
confInt: [number, number];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Result of {@link diagnosticTests}.
|
|
30
|
+
*
|
|
31
|
+
* @category Hypothesis tests
|
|
32
|
+
*/
|
|
33
|
+
export interface DiagnosticTestsResult {
|
|
34
|
+
/** Sensitivity a/(a + c). */
|
|
35
|
+
sensitivity: DiagnosticMeasure;
|
|
36
|
+
/** Specificity d/(b + d). */
|
|
37
|
+
specificity: DiagnosticMeasure;
|
|
38
|
+
/** Positive predictive value a/(a + b). */
|
|
39
|
+
ppv: DiagnosticMeasure;
|
|
40
|
+
/** Negative predictive value d/(c + d). */
|
|
41
|
+
npv: DiagnosticMeasure;
|
|
42
|
+
/** Positive likelihood ratio se/(1 − sp), with the log interval. */
|
|
43
|
+
lrPos: DiagnosticMeasure;
|
|
44
|
+
/** Negative likelihood ratio (1 − se)/sp, with the log interval. */
|
|
45
|
+
lrNeg: DiagnosticMeasure;
|
|
46
|
+
/** Diagnostic accuracy (a + d)/total. */
|
|
47
|
+
accuracy: DiagnosticMeasure;
|
|
48
|
+
/** Diagnostic odds ratio ad/(bc), with Woolf's interval. */
|
|
49
|
+
diagnosticOR: DiagnosticMeasure;
|
|
50
|
+
/** True prevalence (a + c)/total (epiR's "tp"). */
|
|
51
|
+
prevalence: DiagnosticMeasure;
|
|
52
|
+
/** Apparent prevalence (a + b)/total (epiR's "ap"). */
|
|
53
|
+
apparentPrevalence: DiagnosticMeasure;
|
|
54
|
+
/** The positive predictive value at the prevalence given in the options (absent without it). */
|
|
55
|
+
ppvAtPrevalence?: number;
|
|
56
|
+
/** The negative predictive value at the prevalence given in the options (absent without it). */
|
|
57
|
+
npvAtPrevalence?: number;
|
|
58
|
+
/** The method of the proportions' intervals, in full. */
|
|
59
|
+
method: "exact" | "wilson" | "jeffreys";
|
|
60
|
+
/** The confidence level. */
|
|
61
|
+
confLevel: number;
|
|
62
|
+
/** R's warnings, each once, in R's order (an empty array when there are none). */
|
|
63
|
+
warnings: string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sensitivity, specificity, predictive values, likelihood ratios, accuracy, the diagnostic odds ratio and the true and
|
|
67
|
+
* apparent prevalence of a binary test, each with a confidence interval, from its 2 × 2 table. Equivalent to
|
|
68
|
+
* `epiR::epi.tests()` in R.
|
|
69
|
+
*
|
|
70
|
+
* The table is epiR's: rows test positive and negative, columns disease present and absent, `[[a, b], [c, d]]` with
|
|
71
|
+
* a the true positives, b the false positives, c the false negatives and d the true negatives. The proportions'
|
|
72
|
+
* intervals are those of {@link binomCI}: `"exact"` is Clopper-Pearson's, computed directly (epiR computes it as 1 −
|
|
73
|
+
* qbeta(...), which loses digits for small limits); `"jeffreys"` gives 0 and 1 at the ends, as binomCI (epiR the
|
|
74
|
+
* beta quantiles). The likelihood ratios have the log interval (Simel, Samsa and Matchar 1991) and the odds ratio
|
|
75
|
+
* Woolf's. Zero cells give infinite ratios and NaN limits, as epiR; a zero row or column total is an error.
|
|
76
|
+
*
|
|
77
|
+
* @param table The 2 × 2 table of counts (an array of two rows).
|
|
78
|
+
* @param options See {@link DiagnosticTestsOptions}.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const r = diagnosticTests([[670, 202], [74, 640]]);
|
|
83
|
+
* r.sensitivity.estimate; // 0.9005376344086021
|
|
84
|
+
* r.sensitivity.confInt; // [0.8767461767957109, 0.9210922995836943]
|
|
85
|
+
* r.lrPos.estimate; // 3.7537261790695196
|
|
86
|
+
* diagnosticTests([[670, 202], [74, 640]], { prevalence: 0.1 }).ppvAtPrevalence; // 0.2943238804381625
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @category Hypothesis tests
|
|
90
|
+
*/
|
|
91
|
+
export declare function diagnosticTests(table: readonly (readonly number[])[], options?: DiagnosticTestsOptions): DiagnosticTestsResult;
|