@numero-uno-jpn/rstats 1.18.0 → 1.20.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 +52 -0
- package/README.ja.md +7 -7
- package/README.md +7 -7
- package/dist/causal.js +2 -2
- package/dist/chunks/chunk-33ODAPMR.js +2 -0
- package/dist/chunks/chunk-3ST6RZXG.js +2 -0
- package/dist/chunks/{chunk-JF4PXFJE.js → chunk-4EQN74JN.js} +2 -2
- package/dist/chunks/chunk-5RRFO4NU.js +2 -0
- package/dist/chunks/{chunk-3JFRDXN7.js → chunk-64DDDGJU.js} +2 -2
- package/dist/chunks/chunk-66TEOHPF.js +2 -0
- package/dist/chunks/chunk-6ISDROPG.js +2 -0
- package/dist/chunks/{chunk-EC77KAAM.js → chunk-6LAKI2QG.js} +2 -2
- package/dist/chunks/{chunk-5CTWYFMB.js → chunk-6QCH4LAL.js} +2 -2
- package/dist/chunks/{chunk-H6Z7JVSD.js → chunk-6RA73LXX.js} +2 -2
- package/dist/chunks/{chunk-KJMLQHCY.js → chunk-7C2ECGT6.js} +1 -1
- package/dist/chunks/{chunk-SCFFHEDZ.js → chunk-7KPFNJBE.js} +2 -2
- package/dist/chunks/chunk-ARPXG2PG.js +2 -0
- package/dist/chunks/chunk-AWXW4WSX.js +2 -0
- package/dist/chunks/{chunk-XQCHC3SH.js → chunk-B5GSH3AK.js} +1 -1
- package/dist/chunks/{chunk-2JB7F646.js → chunk-BLDLJHUG.js} +2 -2
- package/dist/chunks/{chunk-IKMW63BE.js → chunk-BU4I544S.js} +2 -2
- package/dist/chunks/{chunk-LCIX76FR.js → chunk-CAUNJ7S6.js} +2 -2
- package/dist/chunks/chunk-DFGW4QWU.js +2 -0
- package/dist/chunks/{chunk-WYVUCQO3.js → chunk-DPCCSFCG.js} +1 -1
- package/dist/chunks/chunk-EXS5QD7V.js +2 -0
- package/dist/chunks/chunk-FOCHNNP3.js +2 -0
- package/dist/chunks/{chunk-MXZ64QME.js → chunk-HEPGGURG.js} +2 -2
- package/dist/chunks/chunk-INNFAVT3.js +2 -0
- package/dist/chunks/chunk-JEELIABM.js +2 -0
- package/dist/chunks/chunk-KNF2GPJV.js +2 -0
- package/dist/chunks/chunk-L4ZS7MAX.js +2 -0
- package/dist/chunks/{chunk-RXYZQ3UX.js → chunk-LZAB4M7P.js} +2 -2
- package/dist/chunks/chunk-LZTDYQRS.js +3 -0
- package/dist/chunks/{chunk-N7BUE54L.js → chunk-MTSU2QHB.js} +2 -2
- package/dist/chunks/{chunk-GIK34P23.js → chunk-MXRN2G7O.js} +2 -2
- package/dist/chunks/chunk-OFDD4GTZ.js +2 -0
- package/dist/chunks/chunk-OOHFFLMY.js +2 -0
- package/dist/chunks/chunk-OOO5AAM7.js +2 -0
- package/dist/chunks/chunk-PJJJR3H6.js +2 -0
- package/dist/chunks/chunk-PVRNAOO7.js +2 -0
- package/dist/chunks/chunk-Q2JLU5YD.js +2 -0
- package/dist/chunks/{chunk-Z33Q545U.js → chunk-QCQBK5AC.js} +2 -2
- package/dist/chunks/chunk-RXK4KSKH.js +2 -0
- package/dist/chunks/chunk-UC3YYJHM.js +4 -0
- package/dist/chunks/chunk-UPACHZ4F.js +2 -0
- package/dist/chunks/{chunk-VATAUY7N.js → chunk-VCXPGCA4.js} +2 -2
- package/dist/chunks/chunk-VFL4GGYT.js +2 -0
- package/dist/chunks/chunk-VL72MQOQ.js +2 -0
- package/dist/chunks/chunk-VSV5QGXX.js +2 -0
- package/dist/chunks/{chunk-CTZUYKVL.js → chunk-WMEF5XWO.js} +2 -2
- package/dist/chunks/chunk-X6JS6ZZB.js +2 -0
- package/dist/chunks/chunk-YEDVOX5V.js +2 -0
- package/dist/chunks/chunk-ZCTB4N5J.js +3 -0
- package/dist/descriptive.js +2 -2
- package/dist/distributions/normal.d.ts +4 -0
- package/dist/distributions/normal.js +4 -2
- package/dist/distributions.js +2 -2
- package/dist/entries/tests.d.ts +6 -0
- package/dist/entries/tests.js +6 -0
- package/dist/entries/timeseries.d.ts +11 -0
- package/dist/entries/timeseries.js +11 -0
- package/dist/htest/timeROC.d.ts +564 -0
- package/dist/htest/timeROC.js +1106 -0
- package/dist/linalg.js +2 -2
- package/dist/meta/metabin.d.ts +32 -0
- package/dist/meta/metabin.js +137 -0
- package/dist/meta/metaextra.d.ts +153 -0
- package/dist/meta/metaextra.js +290 -0
- package/dist/meta/metagen.d.ts +124 -0
- package/dist/meta/metagen.js +263 -0
- package/dist/meta/metaother.d.ts +87 -0
- package/dist/meta/metaother.js +342 -0
- package/dist/meta/netmeta.d.ts +256 -0
- package/dist/meta/netmeta.js +547 -0
- package/dist/mixed.js +3 -4
- package/dist/models/glmFamily.js +4 -1
- package/dist/models/metaAnalysis.d.ts +4 -0
- package/dist/models/metaAnalysis.js +100 -18
- package/dist/multivariate.js +2 -2
- package/dist/numerics.js +2 -2
- package/dist/regression.js +2 -2
- package/dist/rstats.js +20 -18
- package/dist/special.js +2 -2
- package/dist/tests.js +15 -15
- package/dist/timeseries/acf.js +5 -2
- package/dist/timeseries/arima.d.ts +154 -0
- package/dist/timeseries/arima.js +1007 -0
- package/dist/timeseries/autoArima.d.ts +70 -0
- package/dist/timeseries/autoArima.js +191 -0
- package/dist/timeseries/ets.d.ts +158 -0
- package/dist/timeseries/ets.js +883 -0
- package/dist/timeseries/forecastArima.d.ts +136 -0
- package/dist/timeseries/forecastArima.js +432 -0
- package/dist/timeseries/forecastDispatch.d.ts +83 -0
- package/dist/timeseries/forecastDispatch.js +130 -0
- package/dist/timeseries/forecastSimple.d.ts +177 -0
- package/dist/timeseries/forecastSimple.js +371 -0
- package/dist/timeseries/forecastUtils.d.ts +260 -0
- package/dist/timeseries/forecastUtils.js +619 -0
- package/dist/timeseries/holtWinters.d.ts +65 -0
- package/dist/timeseries/holtWinters.js +193 -0
- package/dist/timeseries/input.d.ts +8 -0
- package/dist/timeseries/input.js +27 -0
- package/dist/timeseries/ocsbCritical.d.ts +2 -0
- package/dist/timeseries/ocsbCritical.js +6 -0
- package/dist/timeseries/scale.d.ts +16 -0
- package/dist/timeseries/scale.js +48 -0
- package/dist/timeseries/statsTs.d.ts +128 -0
- package/dist/timeseries/statsTs.js +456 -0
- package/dist/timeseries/stl.d.ts +131 -0
- package/dist/timeseries/stl.js +489 -0
- package/dist/timeseries/tseries.d.ts +110 -0
- package/dist/timeseries/tseries.js +369 -0
- package/dist/timeseries.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/chunk-53WQDB3C.js +0 -2
- package/dist/chunks/chunk-6I23C2YJ.js +0 -2
- package/dist/chunks/chunk-FLFNMSHI.js +0 -3
- package/dist/chunks/chunk-GEHMND3C.js +0 -2
- package/dist/chunks/chunk-HG4LJBNV.js +0 -2
- package/dist/chunks/chunk-HGAEVPVS.js +0 -2
- package/dist/chunks/chunk-HMLYEFQN.js +0 -2
- package/dist/chunks/chunk-HRRCC2BD.js +0 -2
- package/dist/chunks/chunk-IBHMM2SL.js +0 -2
- package/dist/chunks/chunk-ICDW3I2F.js +0 -2
- package/dist/chunks/chunk-IOJVFYHW.js +0 -2
- package/dist/chunks/chunk-IW4S634O.js +0 -2
- package/dist/chunks/chunk-JPWYGTUN.js +0 -2
- package/dist/chunks/chunk-KVJBCT3D.js +0 -2
- package/dist/chunks/chunk-LY5XGFPU.js +0 -2
- package/dist/chunks/chunk-MKZH65DK.js +0 -2
- package/dist/chunks/chunk-MVPHISOV.js +0 -2
- package/dist/chunks/chunk-NDZVVNBB.js +0 -2
- package/dist/chunks/chunk-NOTJ45G3.js +0 -4
- package/dist/chunks/chunk-QUD3374N.js +0 -2
- package/dist/chunks/chunk-V6FMGGUV.js +0 -2
- package/dist/chunks/chunk-W5M3R4NH.js +0 -2
- package/dist/chunks/chunk-XUMVTGMM.js +0 -2
- package/dist/chunks/chunk-YXMHWS5R.js +0 -2
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
// Time series analysis (rStats.js/timeseries).
|
|
2
2
|
export { acf, pacf, ccf } from "../timeseries/acf.js";
|
|
3
|
+
export { arima, predictArima, minRootModulus } from "../timeseries/arima.js";
|
|
4
|
+
export { boxCox, invBoxCox, boxCoxLambda, forecastArima, forecastFromArima, ndiffs, kpssStatistic, kpssPValue } from "../timeseries/forecastArima.js";
|
|
5
|
+
export { stl, supsmu, mstl, seasadj, nsdiffs, ocsbTest, ocsbCritical } from "../timeseries/stl.js";
|
|
6
|
+
export { autoArima } from "../timeseries/autoArima.js";
|
|
7
|
+
export { ets, forecastEts } from "../timeseries/ets.js";
|
|
8
|
+
export { tsFilter, boxTest, diffinv, decompose, ar, predictAr, arima0 } from "../timeseries/statsTs.js";
|
|
9
|
+
export { holtWinters, predictHoltWinters } from "../timeseries/holtWinters.js";
|
|
10
|
+
export { meanf, rwf, naive, snaive, ses, holt, hw, thetaf, croston, stlf, tslm } from "../timeseries/forecastSimple.js";
|
|
11
|
+
export { accuracy, ma, fourier, seasonaldummy, monthdays, easter, easterSunday, bizdays, dmTest, cvLm, checkresiduals, tsCV, arimaorder, specAr, findfrequency, naInterp, tsoutliers, tsclean, seasonalComponent, trendcycle, remainder } from "../timeseries/forecastUtils.js";
|
|
12
|
+
export { stlm, forecastStlm, forecast } from "../timeseries/forecastDispatch.js";
|
|
13
|
+
export { adfTest, kpssTest, ppTest, poTest, jarqueBeraTest, runsTest, terasvirtaTest, whiteTest } from "../timeseries/tseries.js";
|
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The censoring weights of {@link timeROC}: marginal (Kaplan-Meier), Cox or Aalen.
|
|
3
|
+
*
|
|
4
|
+
* @category Survival analysis
|
|
5
|
+
*/
|
|
6
|
+
export type TimeROCWeighting = "marginal" | "cox" | "aalen";
|
|
7
|
+
/**
|
|
8
|
+
* Options for {@link timeROC}.
|
|
9
|
+
*
|
|
10
|
+
* @category Survival analysis
|
|
11
|
+
*/
|
|
12
|
+
export interface TimeROCOptions {
|
|
13
|
+
/** Evaluation times (required; used as given: R adds 0 to a single time). */
|
|
14
|
+
times: readonly number[];
|
|
15
|
+
/** The event of interest among the values of `delta`. Default 1. */
|
|
16
|
+
cause?: number;
|
|
17
|
+
/** Censoring weights: `"marginal"` (default, Kaplan-Meier), `"cox"` or `"aalen"` (models of the censoring with the
|
|
18
|
+
* marker and `otherMarkers` as covariates). */
|
|
19
|
+
weighting?: TimeROCWeighting;
|
|
20
|
+
/** Further covariates of the censoring model (one row per subject), for `"cox"` and `"aalen"`. */
|
|
21
|
+
otherMarkers?: readonly (readonly number[])[];
|
|
22
|
+
/** Compute the iid representation and the standard errors (marginal weights only). Default false. */
|
|
23
|
+
iid?: boolean;
|
|
24
|
+
/** Return the TP and FP curves. Default true. */
|
|
25
|
+
roc?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Counts per evaluation time: cases (T < t, the cause), survivors (T > t), other events before t (competing risks
|
|
28
|
+
* only) and the rest ("censored at t": censored by t, or with an event at t).
|
|
29
|
+
*
|
|
30
|
+
* @category Survival analysis
|
|
31
|
+
*/
|
|
32
|
+
export interface TimeROCStats {
|
|
33
|
+
/** Subjects with the cause before t (T < t). */
|
|
34
|
+
cases: number;
|
|
35
|
+
/** Subjects still without an event after t (T > t). */
|
|
36
|
+
survivors: number;
|
|
37
|
+
/** Subjects with another event before t (competing risks only). */
|
|
38
|
+
otherEvents?: number;
|
|
39
|
+
/** The rest: censored by t, or with an event at exactly t. */
|
|
40
|
+
censored: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The weights of a {@link timeROC} fit, subjects in the order of the sorted times.
|
|
44
|
+
*
|
|
45
|
+
* @category Survival analysis
|
|
46
|
+
*/
|
|
47
|
+
export type TimeROCWeights = {
|
|
48
|
+
/** Kaplan-Meier of the censoring. */
|
|
49
|
+
method: "marginal";
|
|
50
|
+
/** G(t), the censoring survival at each time. */
|
|
51
|
+
ipcwTimes: number[];
|
|
52
|
+
/** G(T_i−), at each subject's time (left limit). */
|
|
53
|
+
ipcwSubjectTimes: number[];
|
|
54
|
+
} | {
|
|
55
|
+
/** A Cox or an Aalen model of the censoring. */
|
|
56
|
+
method: "cox" | "aalen";
|
|
57
|
+
/** G(t | Z_i) per time and subject. */
|
|
58
|
+
ipcwTimes: number[][];
|
|
59
|
+
/** G(T_i− | Z_i) per subject. */
|
|
60
|
+
ipcwSubjectTimes: number[];
|
|
61
|
+
};
|
|
62
|
+
interface TimeROCCommon {
|
|
63
|
+
/** The evaluation times. */
|
|
64
|
+
times: number[];
|
|
65
|
+
/** Number of subjects. */
|
|
66
|
+
n: number;
|
|
67
|
+
/** Cumulative incidence of the cause at each time (the cases' weights over n). */
|
|
68
|
+
cumulativeIncidence: number[];
|
|
69
|
+
/** Probability of no event of any kind at each time: the survivors' weighted mass (with the marginal weights exactly
|
|
70
|
+
* the Kaplan-Meier, as R). */
|
|
71
|
+
survProb: number[];
|
|
72
|
+
/** Counts per time. */
|
|
73
|
+
stats: TimeROCStats[];
|
|
74
|
+
/** The censoring weights. */
|
|
75
|
+
weights: TimeROCWeights;
|
|
76
|
+
/** True positive rates per time, one per distinct marker value from the largest ("marker > value") and a last 1. */
|
|
77
|
+
tp?: number[][];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Result of {@link timeROC} without competing risks.
|
|
81
|
+
*
|
|
82
|
+
* @category Survival analysis
|
|
83
|
+
*/
|
|
84
|
+
export interface TimeROCSingleResult extends TimeROCCommon {
|
|
85
|
+
/** No event other than the cause in `delta`. */
|
|
86
|
+
competingRisks: false;
|
|
87
|
+
/** The cumulative/dynamic AUC at each time. */
|
|
88
|
+
auc: number[];
|
|
89
|
+
/** False positive rates per time (controls: T > t). */
|
|
90
|
+
fp?: number[][];
|
|
91
|
+
/** With `iid`: the iid representation (per time, subjects in the order of the sorted times) and the standard errors. */
|
|
92
|
+
inference?: {
|
|
93
|
+
/** The AUC's iid representation per time (its influence function at each subject). */
|
|
94
|
+
iid: number[][];
|
|
95
|
+
/** Standard error of the AUC per time: sd(iid) / √n. */
|
|
96
|
+
sd: number[];
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Result of {@link timeROC} with competing risks: definition (i) has the controls T > t, definition (ii) also the
|
|
101
|
+
* subjects with another event before t.
|
|
102
|
+
*
|
|
103
|
+
* @category Survival analysis
|
|
104
|
+
*/
|
|
105
|
+
export interface TimeROCCompetingResult extends TimeROCCommon {
|
|
106
|
+
/** Other events than the cause occur in `delta`. */
|
|
107
|
+
competingRisks: true;
|
|
108
|
+
/** AUC with definition (i) of the controls at each time. */
|
|
109
|
+
auc1: number[];
|
|
110
|
+
/** AUC with definition (ii) of the controls at each time. */
|
|
111
|
+
auc2: number[];
|
|
112
|
+
/** False positive rates per time, definition (i). */
|
|
113
|
+
fp1?: number[][];
|
|
114
|
+
/** False positive rates per time, definition (ii). */
|
|
115
|
+
fp2?: number[][];
|
|
116
|
+
/** With `iid`: the iid representations and standard errors of both AUCs, as in {@link TimeROCSingleResult}. */
|
|
117
|
+
inference?: {
|
|
118
|
+
/** iid representation of AUC (i) per time. */
|
|
119
|
+
iid1: number[][];
|
|
120
|
+
/** Standard error of AUC (i) per time. */
|
|
121
|
+
sd1: number[];
|
|
122
|
+
/** iid representation of AUC (ii) per time. */
|
|
123
|
+
iid2: number[][];
|
|
124
|
+
/** Standard error of AUC (ii) per time. */
|
|
125
|
+
sd2: number[];
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Result of {@link timeROC}.
|
|
130
|
+
*
|
|
131
|
+
* @category Survival analysis
|
|
132
|
+
*/
|
|
133
|
+
export type TimeROCResult = TimeROCSingleResult | TimeROCCompetingResult;
|
|
134
|
+
/** @internal */
|
|
135
|
+
export interface Data {
|
|
136
|
+
n: number;
|
|
137
|
+
time: number[];
|
|
138
|
+
delta: number[];
|
|
139
|
+
marker: number[];
|
|
140
|
+
/** Subjects in the order of the sorted times (ties in the data order). */
|
|
141
|
+
order: number[];
|
|
142
|
+
/** Distinct times, increasing. */
|
|
143
|
+
u: number[];
|
|
144
|
+
/** Each subject's index in u. */
|
|
145
|
+
ti: number[];
|
|
146
|
+
/** Censoring risk set at u: T > u, or censored at u (the events at u are left out). */
|
|
147
|
+
R: number[];
|
|
148
|
+
/** Number censored at u. */
|
|
149
|
+
C: number[];
|
|
150
|
+
/** Censoring KM after each u: G(u). */
|
|
151
|
+
G: number[];
|
|
152
|
+
}
|
|
153
|
+
declare function prepare(time: readonly number[], delta: readonly number[], marker: readonly number[]): Data;
|
|
154
|
+
/** @internal */
|
|
155
|
+
export interface AtTime {
|
|
156
|
+
t: number;
|
|
157
|
+
/** Weight of each subject (0 for those with none). */
|
|
158
|
+
w: number[];
|
|
159
|
+
/** The weight is 1 / G(T_i-) (true) or 1 / G(t) (false); only meaningful where w > 0. */
|
|
160
|
+
left: boolean[];
|
|
161
|
+
/** Roles: 1 case, 2 control (T > t), 3 other event before t, 4 an event at exactly t, 0 none. */
|
|
162
|
+
role: number[];
|
|
163
|
+
}
|
|
164
|
+
declare function weightsAt(data: Data, t: number, cause: number, gLeft: (i: number) => number, gAt: (i: number) => number): AtTime;
|
|
165
|
+
/** The marginal weights' left and at-t censoring probabilities. */
|
|
166
|
+
declare function marginalG(data: Data, t: number): {
|
|
167
|
+
gLeft: (i: number) => number;
|
|
168
|
+
gAt: (i: number) => number;
|
|
169
|
+
Gt: number;
|
|
170
|
+
};
|
|
171
|
+
/** A weighted total and its influence (marginal weights): value sum w f / n and w_k f_k - W + Q_k. */
|
|
172
|
+
/** @internal */
|
|
173
|
+
export interface Total {
|
|
174
|
+
value: number;
|
|
175
|
+
inf: number[];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The influence of W(f) = sum_i w_i f_i / n. `exact` takes the derivative of the weighted Kaplan-Meier itself
|
|
179
|
+
* (1 / (R - C) in place of 1 / R; used by the tests' infinitesimal jackknife), the default the usual asymptotic form.
|
|
180
|
+
*/
|
|
181
|
+
declare function total(data: Data, at: AtTime, f: readonly number[], exact?: boolean): Total;
|
|
182
|
+
/** The AUC's influence: definition "i" (controls T > t) or "ii" (with the other events before t). @internal */
|
|
183
|
+
export declare function aucInfluence(data: Data, at: AtTime, definition: "i" | "ii", exact?: boolean): {
|
|
184
|
+
auc: number;
|
|
185
|
+
inf: number[];
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Time-dependent ROC curves and AUC for censored event times, with a single event or competing risks: the
|
|
189
|
+
* cumulative/dynamic definition (cases T < t with the cause, controls T > t, and for competing risks definition (ii)
|
|
190
|
+
* also the subjects with another event before t), inverse probability of censoring weights from the Kaplan-Meier of
|
|
191
|
+
* the censoring (`"marginal"`), a Cox model (`"cox"`, Efron ties) or Aalen's additive model (`"aalen"`) with the marker
|
|
192
|
+
* and `otherMarkers`; ties in the marker count 1/2. With `iid` (marginal weights), the iid representation of the AUC and
|
|
193
|
+
* its standard error.
|
|
194
|
+
*
|
|
195
|
+
* Differences from R: the times are used as given (R adds 0 to a single time); the iid handles tied times correctly
|
|
196
|
+
* (independent of the data order; equal to R's without ties) and definition (ii)'s is centred on the reported AUC_2;
|
|
197
|
+
* the Cox weights use the maximum of the partial likelihood (R's cph stops about 5e-7 short); Aalen's increments take
|
|
198
|
+
* tied censorings together (R breaks ties at random); a time with a single survivor works (R's competing-risks iid
|
|
199
|
+
* fails there).
|
|
200
|
+
*
|
|
201
|
+
* Equivalent to `timeROC::timeROC()` in R.
|
|
202
|
+
*
|
|
203
|
+
* @param time observed times
|
|
204
|
+
* @param delta 0 censored, otherwise the kind of event
|
|
205
|
+
* @param marker the marker (larger values: the event sooner)
|
|
206
|
+
* @param options `times` (required) and the options of timeROC
|
|
207
|
+
* @category Survival analysis
|
|
208
|
+
*/
|
|
209
|
+
export declare function timeROC(time: readonly number[], delta: readonly number[], marker: readonly number[], options: TimeROCOptions): TimeROCResult;
|
|
210
|
+
/**
|
|
211
|
+
* Options for {@link timeROCConfint}.
|
|
212
|
+
*
|
|
213
|
+
* @category Survival analysis
|
|
214
|
+
*/
|
|
215
|
+
export interface TimeROCConfintOptions {
|
|
216
|
+
/** Confidence level. Default 0.95. */
|
|
217
|
+
level?: number;
|
|
218
|
+
/** Number of simulations of the simultaneous band. Default 2000. */
|
|
219
|
+
nSim?: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Pointwise intervals and the simultaneous band of one AUC, in percent.
|
|
223
|
+
*
|
|
224
|
+
* @category Survival analysis
|
|
225
|
+
*/
|
|
226
|
+
export interface TimeROCInterval {
|
|
227
|
+
/** Lower and upper pointwise limits per time (percent, not rounded). */
|
|
228
|
+
ci: [number, number][];
|
|
229
|
+
/** Lower and upper limits of the simultaneous band per time (percent). */
|
|
230
|
+
band: [number, number][];
|
|
231
|
+
/** The band's multiplier (the `level` quantile of the maximum standardized deviation). */
|
|
232
|
+
cAlpha: number;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Result of {@link timeROCConfint}: `auc` without competing risks, `auc1` and `auc2` with them.
|
|
236
|
+
*
|
|
237
|
+
* @category Survival analysis
|
|
238
|
+
*/
|
|
239
|
+
export interface TimeROCConfintResult {
|
|
240
|
+
/** The evaluation times. */
|
|
241
|
+
times: number[];
|
|
242
|
+
/** The confidence level. */
|
|
243
|
+
level: number;
|
|
244
|
+
/** Without competing risks: the AUC's intervals. */
|
|
245
|
+
auc?: TimeROCInterval;
|
|
246
|
+
/** With competing risks: AUC (i)'s intervals. */
|
|
247
|
+
auc1?: TimeROCInterval;
|
|
248
|
+
/** With competing risks: AUC (ii)'s intervals (the same draws as AUC (i)'s band, as R). */
|
|
249
|
+
auc2?: TimeROCInterval;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Pointwise confidence intervals of the time-dependent AUC and a simultaneous confidence band over the times, from the
|
|
253
|
+
* iid representation: the band's multiplier is the `level` quantile of the maximum over the times of the
|
|
254
|
+
* standardized multiplier-bootstrap process (`nSim` draws of n standard normals, from rStats.js's generator: set it
|
|
255
|
+
* with `setSeed`; the same seed as R's `set.seed` gives R's band). Percent, not rounded (R rounds to 2 decimals).
|
|
256
|
+
*
|
|
257
|
+
* Equivalent to `timeROC::confint.ipcwsurvivalROC()` in R.
|
|
258
|
+
*
|
|
259
|
+
* @param fit a result of {@link timeROC} with `iid: true`
|
|
260
|
+
* @param options `level` and `nSim`
|
|
261
|
+
* @category Survival analysis
|
|
262
|
+
*/
|
|
263
|
+
export declare function timeROCConfint(fit: TimeROCResult, options?: TimeROCConfintOptions): TimeROCConfintResult;
|
|
264
|
+
/**
|
|
265
|
+
* Options for {@link timeROCCompare}.
|
|
266
|
+
*
|
|
267
|
+
* @category Survival analysis
|
|
268
|
+
*/
|
|
269
|
+
export interface TimeROCCompareOptions {
|
|
270
|
+
/** Also the p-values adjusted for the several times (the maximum of the correlated statistics). Default false. */
|
|
271
|
+
adjusted?: boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The comparison of one AUC definition.
|
|
275
|
+
*
|
|
276
|
+
* @category Survival analysis
|
|
277
|
+
*/
|
|
278
|
+
export interface TimeROCComparison {
|
|
279
|
+
/** p-values per time. */
|
|
280
|
+
pValues: number[];
|
|
281
|
+
/** With `adjusted`: the p-values adjusted for the several times. */
|
|
282
|
+
adjusted?: number[];
|
|
283
|
+
/** With `adjusted`: the correlation of the statistics across the times. */
|
|
284
|
+
cor?: number[][];
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Result of {@link timeROCCompare}.
|
|
288
|
+
*
|
|
289
|
+
* @category Survival analysis
|
|
290
|
+
*/
|
|
291
|
+
export interface TimeROCCompareResult {
|
|
292
|
+
/** The evaluation times. */
|
|
293
|
+
times: number[];
|
|
294
|
+
/** Without competing risks: the comparison of the AUCs. */
|
|
295
|
+
auc?: TimeROCComparison;
|
|
296
|
+
/** With competing risks: the comparison of AUC (i). */
|
|
297
|
+
auc1?: TimeROCComparison;
|
|
298
|
+
/** With competing risks: the comparison of AUC (ii). */
|
|
299
|
+
auc2?: TimeROCComparison;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Compares the time-dependent AUCs of two markers measured on the same subjects at each time, by the z statistic of
|
|
303
|
+
* the difference with the standard error from the difference of the iid representations; with `adjusted`, also the
|
|
304
|
+
* p-values adjusted for the several times, P(max_t |Z_t| >= |z_t|) for Z normal with the correlation of the
|
|
305
|
+
* statistics (computed deterministically as a sum of positive terms, so that small p-values keep their relative
|
|
306
|
+
* accuracy: to rounding up to three times, to about 1e-6 relative from four on; R integrates 1 − P at random with
|
|
307
|
+
* mvtnorm's default absolute tolerance of 1e-3, so the two differ by up to about 1e-4).
|
|
308
|
+
*
|
|
309
|
+
* Equivalent to `timeROC::compare()` in R.
|
|
310
|
+
*
|
|
311
|
+
* @param x a result of {@link timeROC} with `iid: true`
|
|
312
|
+
* @param y another, on the same subjects and times
|
|
313
|
+
* @param options `adjusted`
|
|
314
|
+
* @category Survival analysis
|
|
315
|
+
*/
|
|
316
|
+
export declare function timeROCCompare(x: TimeROCResult, y: TimeROCResult, options?: TimeROCCompareOptions): TimeROCCompareResult;
|
|
317
|
+
/**
|
|
318
|
+
* P(max_j |Z_j| >= b) for Z ~ N(0, cor), computed directly (not as 1 − P(all |Z_j| < b), which loses the small values
|
|
319
|
+
* to cancellation) by the first exceedance: Q = 2 Σ_i P(|Z_j| < b for j < i, Z_i >= b), a sum of positive terms (the
|
|
320
|
+
* factor 2 by the symmetry Z → −Z). The i-th term is a probability of the leading i variables: pnorm for i = 1,
|
|
321
|
+
* pbvnorm for i = 2, adaptive Gauss-Legendre over Z_3 >= b of the conditional bivariate probability (pbvnorm) for
|
|
322
|
+
* i = 3, and Genz's separation of variables (Genz 1992) with a Richtmyer lattice for i >= 4 or a correlation within
|
|
323
|
+
* 1e-9 of ±1 (a Richtmyer lattice periodized by the baker's transform, fixed shifts from a private generator: no use of
|
|
324
|
+
* the user's random numbers; points doubled until two standard errors fall below 1e-6 of the term). Each term
|
|
325
|
+
* keeps its relative accuracy, so small adjusted p-values do too.
|
|
326
|
+
*
|
|
327
|
+
* @internal
|
|
328
|
+
*/
|
|
329
|
+
export declare function pmaxAbsExceed(b: number, cor: readonly (readonly number[])[]): number;
|
|
330
|
+
/** P(all |Z_j| <= b) = 1 − {@link pmaxAbsExceed} (for moderate b; the tests). @internal */
|
|
331
|
+
export declare function pmvnormSymmetric(b: number, cor: readonly (readonly number[])[]): number;
|
|
332
|
+
/**
|
|
333
|
+
* Options for {@link seSpPPVNPV}.
|
|
334
|
+
*
|
|
335
|
+
* @category Survival analysis
|
|
336
|
+
*/
|
|
337
|
+
export interface SeSpPPVNPVOptions extends Omit<TimeROCOptions, "roc"> {
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Standard errors of {@link seSpPPVNPV} (with `iid`), per time.
|
|
341
|
+
*
|
|
342
|
+
* @category Survival analysis
|
|
343
|
+
*/
|
|
344
|
+
export interface SeSpPPVNPVInference {
|
|
345
|
+
/** Standard errors, sd(iid) / √n, per time. */
|
|
346
|
+
se: {
|
|
347
|
+
/** Of the sensitivity. */
|
|
348
|
+
se: number[];
|
|
349
|
+
/** Of the specificity with definition (i). */
|
|
350
|
+
sp1: number[];
|
|
351
|
+
/** Of the specificity with definition (ii). */
|
|
352
|
+
sp2: number[];
|
|
353
|
+
/** Of the positive predictive value. */
|
|
354
|
+
ppv: number[];
|
|
355
|
+
/** Of the negative predictive value (i). */
|
|
356
|
+
npv1: number[];
|
|
357
|
+
/** Of the negative predictive value (ii). */
|
|
358
|
+
npv2: number[];
|
|
359
|
+
};
|
|
360
|
+
/** The iid representations, per time, subjects in the order of the sorted times. */
|
|
361
|
+
iid: {
|
|
362
|
+
/** Of the sensitivity. */
|
|
363
|
+
se: number[][];
|
|
364
|
+
/** Of the specificity with definition (i). */
|
|
365
|
+
sp1: number[][];
|
|
366
|
+
/** Of the specificity with definition (ii). */
|
|
367
|
+
sp2: number[][];
|
|
368
|
+
/** Of the positive predictive value. */
|
|
369
|
+
ppv: number[][];
|
|
370
|
+
/** Of the negative predictive value (i). */
|
|
371
|
+
npv1: number[][];
|
|
372
|
+
/** Of the negative predictive value (ii). */
|
|
373
|
+
npv2: number[][];
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Result of {@link seSpPPVNPV}: `fp` and `npv` without competing risks, `fp1`, `fp2`, `npv1` and `npv2` with them.
|
|
378
|
+
*
|
|
379
|
+
* @category Survival analysis
|
|
380
|
+
*/
|
|
381
|
+
export interface SeSpPPVNPVResult {
|
|
382
|
+
/** The threshold: positive means marker > cutpoint. */
|
|
383
|
+
cutpoint: number;
|
|
384
|
+
/** The evaluation times. */
|
|
385
|
+
times: number[];
|
|
386
|
+
/** Number of subjects (without NA). */
|
|
387
|
+
n: number;
|
|
388
|
+
/** Whether other events than the cause occur. */
|
|
389
|
+
competingRisks: boolean;
|
|
390
|
+
/** Sensitivity (true positive rate) per time. */
|
|
391
|
+
tp: number[];
|
|
392
|
+
/** Without competing risks: false positive rate per time. */
|
|
393
|
+
fp?: number[];
|
|
394
|
+
/** With competing risks: false positive rate, definition (i). */
|
|
395
|
+
fp1?: number[];
|
|
396
|
+
/** With competing risks: false positive rate, definition (ii). */
|
|
397
|
+
fp2?: number[];
|
|
398
|
+
/** Positive predictive value per time. */
|
|
399
|
+
ppv: number[];
|
|
400
|
+
/** Without competing risks: negative predictive value per time. */
|
|
401
|
+
npv?: number[];
|
|
402
|
+
/** With competing risks: negative predictive value (i). */
|
|
403
|
+
npv1?: number[];
|
|
404
|
+
/** With competing risks: negative predictive value (ii). */
|
|
405
|
+
npv2?: number[];
|
|
406
|
+
/** Counts per time, with the positives (marker > cutpoint) and negatives. */
|
|
407
|
+
stats: (TimeROCStats & {
|
|
408
|
+
/** Subjects with marker > cutpoint. */
|
|
409
|
+
positive: number;
|
|
410
|
+
/** Subjects with marker <= cutpoint. */
|
|
411
|
+
negative: number;
|
|
412
|
+
})[];
|
|
413
|
+
/** The censoring weights. */
|
|
414
|
+
weights: TimeROCWeights;
|
|
415
|
+
/** With `iid`: standard errors and iid representations. */
|
|
416
|
+
inference?: SeSpPPVNPVInference;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Time-dependent sensitivity, specificity and predictive values of the rule "marker > cutpoint", with the weights of
|
|
420
|
+
* {@link timeROC}: PPV = TP F / (TP F + FP S) and NPV = (1 − FP) S / ((1 − FP) S + (1 − TP) F) (F the cumulative
|
|
421
|
+
* incidence, S its complement); with competing risks PPV and NPV_2 with definition (ii) and NPV_1 = (1 − FP_1) S_1 /
|
|
422
|
+
* ((1 − FP_2) S_2 + (1 − TP) F). With `iid` (marginal weights), the iid representations and standard errors of Se,
|
|
423
|
+
* Sp (both definitions), PPV and the NPVs.
|
|
424
|
+
*
|
|
425
|
+
* Differences from R: as {@link timeROC}; Sp2's denominator is the weighted mass of the definition (ii) controls (R's
|
|
426
|
+
* 1 − F, the same unless events fall at t).
|
|
427
|
+
*
|
|
428
|
+
* Equivalent to `timeROC::SeSpPPVNPV()` in R.
|
|
429
|
+
*
|
|
430
|
+
* @param cutpoint the marker's threshold
|
|
431
|
+
* @param time observed times
|
|
432
|
+
* @param delta 0 censored, otherwise the kind of event
|
|
433
|
+
* @param marker the marker
|
|
434
|
+
* @param options `times` (required) and the options of timeROC
|
|
435
|
+
* @category Survival analysis
|
|
436
|
+
*/
|
|
437
|
+
export declare function seSpPPVNPV(cutpoint: number, time: readonly number[], delta: readonly number[], marker: readonly number[], options: SeSpPPVNPVOptions): SeSpPPVNPVResult;
|
|
438
|
+
/**
|
|
439
|
+
* Options for {@link timeROCAucCurve} and {@link timeROCAucDiff}.
|
|
440
|
+
*
|
|
441
|
+
* @category Survival analysis
|
|
442
|
+
*/
|
|
443
|
+
export interface TimeROCAucCurveOptions extends TimeROCConfintOptions {
|
|
444
|
+
/** With competing risks, the definition of the controls: 1 (default) or 2. */
|
|
445
|
+
fp?: 1 | 2;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Result of {@link timeROCAucCurve}: the AUC per time with its pointwise interval and simultaneous band (as
|
|
449
|
+
* proportions).
|
|
450
|
+
*
|
|
451
|
+
* @category Survival analysis
|
|
452
|
+
*/
|
|
453
|
+
export interface TimeROCAucCurveResult {
|
|
454
|
+
/** The evaluation times. */
|
|
455
|
+
times: number[];
|
|
456
|
+
/** AUC per time. */
|
|
457
|
+
auc: number[];
|
|
458
|
+
/** Lower pointwise confidence limit per time. */
|
|
459
|
+
lower: number[];
|
|
460
|
+
/** Upper pointwise confidence limit per time. */
|
|
461
|
+
upper: number[];
|
|
462
|
+
/** Lower limit of the simultaneous band per time. */
|
|
463
|
+
bandLower: number[];
|
|
464
|
+
/** Upper limit of the simultaneous band per time. */
|
|
465
|
+
bandUpper: number[];
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* The values that R's `plotAUCcurve` draws: the AUC over the times with the pointwise confidence interval and the
|
|
469
|
+
* simultaneous band of {@link timeROCConfint} (as proportions). No plot.
|
|
470
|
+
*
|
|
471
|
+
* Equivalent to `timeROC::plotAUCcurve()` in R.
|
|
472
|
+
*
|
|
473
|
+
* @param fit a result of {@link timeROC} with `iid: true`
|
|
474
|
+
* @param options `level`, `nSim` and `fp`
|
|
475
|
+
* @category Survival analysis
|
|
476
|
+
*/
|
|
477
|
+
export declare function timeROCAucCurve(fit: TimeROCResult, options?: TimeROCAucCurveOptions): TimeROCAucCurveResult;
|
|
478
|
+
/**
|
|
479
|
+
* Result of {@link timeROCAucDiff}.
|
|
480
|
+
*
|
|
481
|
+
* @category Survival analysis
|
|
482
|
+
*/
|
|
483
|
+
export interface TimeROCAucDiffResult {
|
|
484
|
+
/** The evaluation times. */
|
|
485
|
+
times: number[];
|
|
486
|
+
/** AUC of x minus AUC of y. */
|
|
487
|
+
diff: number[];
|
|
488
|
+
/** Lower pointwise confidence limit of the difference. */
|
|
489
|
+
lower: number[];
|
|
490
|
+
/** Upper pointwise confidence limit of the difference. */
|
|
491
|
+
upper: number[];
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* The values behind R's `plotAUCcurveDiff`: the difference of two time-dependent AUCs over the times with the
|
|
495
|
+
* pointwise confidence interval from the difference of the iid representations (as {@link timeROCCompare}). R also
|
|
496
|
+
* draws a simultaneous band, whose simulation cannot be checked (R returns nothing); it is not offered. No plot.
|
|
497
|
+
*
|
|
498
|
+
* Not an R function.
|
|
499
|
+
*
|
|
500
|
+
* @param x a result of {@link timeROC} with `iid: true`
|
|
501
|
+
* @param y another, on the same subjects and times
|
|
502
|
+
* @param options `level` and `fp`
|
|
503
|
+
* @category Survival analysis
|
|
504
|
+
*/
|
|
505
|
+
export declare function timeROCAucDiff(x: TimeROCResult, y: TimeROCResult, options?: Omit<TimeROCAucCurveOptions, "nSim">): TimeROCAucDiffResult;
|
|
506
|
+
/**
|
|
507
|
+
* Options for {@link survivalROC}.
|
|
508
|
+
*
|
|
509
|
+
* @category Survival analysis
|
|
510
|
+
*/
|
|
511
|
+
export interface SurvivalROCOptions {
|
|
512
|
+
/** The time of the prediction (required). */
|
|
513
|
+
predictTime: number;
|
|
514
|
+
/** Thresholds of the marker, sorted (R prepends −Inf; from two thresholds on, the last one's point is (0, 0), as R).
|
|
515
|
+
* Default: the sorted distinct marker values. */
|
|
516
|
+
cutValues?: readonly number[];
|
|
517
|
+
/** The estimator: only `"KM"` (R's default, the nearest-neighbour estimator `"NNE"`, is not offered). Default "KM". */
|
|
518
|
+
method?: "KM";
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Result of {@link survivalROC}.
|
|
522
|
+
*
|
|
523
|
+
* @category Survival analysis
|
|
524
|
+
*/
|
|
525
|
+
export interface SurvivalROCResult {
|
|
526
|
+
/** −Inf, then the thresholds. */
|
|
527
|
+
cutValues: number[];
|
|
528
|
+
/** True positive rate at each threshold. */
|
|
529
|
+
tp: number[];
|
|
530
|
+
/** False positive rate at each threshold. */
|
|
531
|
+
fp: number[];
|
|
532
|
+
/** The prediction time. */
|
|
533
|
+
predictTime: number;
|
|
534
|
+
/** Kaplan-Meier survival at the prediction time. */
|
|
535
|
+
survival: number;
|
|
536
|
+
/** Trapezoid over the points in the order of the thresholds (not bounded by 1, as R). */
|
|
537
|
+
auc: number;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Time-dependent ROC curve at a prediction time by Heagerty, Lumley and Pepe's Kaplan-Meier estimator: S(c, t) =
|
|
541
|
+
* KM_{marker > c}(t) P(marker > c), TP(c) = (P(marker > c) − S(c, t)) / (1 − S(t)), FP(c) = S(c, t) / S(t) (neither
|
|
542
|
+
* is forced to be monotone or below 1, as R), and the AUC by the trapezoid over the thresholds in order.
|
|
543
|
+
*
|
|
544
|
+
* Differences from R: only the Kaplan-Meier estimator (`method = "KM"`); R's default, the nearest-neighbour estimator,
|
|
545
|
+
* is not offered.
|
|
546
|
+
*
|
|
547
|
+
* Equivalent to `survivalROC::survivalROC()` in R.
|
|
548
|
+
*
|
|
549
|
+
* @param time observed times
|
|
550
|
+
* @param status 1 event, 0 censored
|
|
551
|
+
* @param marker the marker
|
|
552
|
+
* @param options `predictTime` (required), `cutValues` and `method`
|
|
553
|
+
* @category Survival analysis
|
|
554
|
+
*/
|
|
555
|
+
export declare function survivalROC(time: readonly number[], status: readonly number[], marker: readonly number[], options: SurvivalROCOptions): SurvivalROCResult;
|
|
556
|
+
/** The pieces used by the tests' infinitesimal jackknife. @internal */
|
|
557
|
+
export declare const timeROCInternals: {
|
|
558
|
+
prepare: typeof prepare;
|
|
559
|
+
weightsAt: typeof weightsAt;
|
|
560
|
+
marginalG: typeof marginalG;
|
|
561
|
+
total: typeof total;
|
|
562
|
+
aucInfluence: typeof aucInfluence;
|
|
563
|
+
};
|
|
564
|
+
export {};
|