@numero-uno-jpn/rstats 1.3.0 → 1.5.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 +85 -0
- package/README.ja.md +9 -7
- package/README.md +9 -7
- package/dist/chunks/chunk-2IYY74LX.js +2 -0
- package/dist/chunks/{chunk-LA4H6ZSC.js → chunk-2MYUAEYE.js} +2 -2
- package/dist/chunks/{chunk-GUM57VVM.js → chunk-3BEE6BHN.js} +1 -1
- package/dist/chunks/{chunk-2VZW4XPK.js → chunk-73QCE2CI.js} +2 -2
- package/dist/chunks/{chunk-AJZV2SVY.js → chunk-AIXJAVDS.js} +2 -2
- package/dist/chunks/{chunk-6X2ZMPF5.js → chunk-BJOZZ5J6.js} +2 -2
- package/dist/chunks/{chunk-P7ZHH2SF.js → chunk-CX4XK7WC.js} +2 -2
- package/dist/chunks/{chunk-PDHBRDTF.js → chunk-DYCWYHYV.js} +1 -1
- package/dist/chunks/{chunk-6TZVS6WC.js → chunk-E5M5RAVB.js} +2 -2
- package/dist/chunks/{chunk-IJV43Y7Q.js → chunk-F2MURX2Y.js} +2 -2
- package/dist/chunks/{chunk-HBRSUHSU.js → chunk-F7SQG6BV.js} +2 -2
- package/dist/chunks/{chunk-UOAFEB64.js → chunk-FCF6FBJP.js} +2 -2
- package/dist/chunks/{chunk-TZTVDVP4.js → chunk-FMLFYM7N.js} +2 -2
- package/dist/chunks/{chunk-EBRTF7RM.js → chunk-GDMNF4P3.js} +1 -1
- package/dist/chunks/{chunk-RCGW2DCK.js → chunk-JBJTXMRJ.js} +2 -2
- package/dist/chunks/{chunk-Z74ZOTUN.js → chunk-L7PDJNJ3.js} +2 -2
- package/dist/chunks/{chunk-I5NWGQOQ.js → chunk-LVB22NKV.js} +2 -2
- package/dist/chunks/{chunk-UJYRU37Z.js → chunk-MJV5G7FG.js} +2 -2
- package/dist/chunks/{chunk-JJRZ2TTF.js → chunk-MXOGMN4P.js} +2 -2
- package/dist/chunks/{chunk-UMDXXT3M.js → chunk-MYRCEQ2R.js} +1 -1
- package/dist/chunks/{chunk-IOGQEMDE.js → chunk-Q32WODL4.js} +2 -2
- package/dist/chunks/{chunk-BNTBZ5W3.js → chunk-RZBX6VYO.js} +2 -2
- package/dist/chunks/chunk-TP4PRPVQ.js +2 -0
- package/dist/chunks/{chunk-FFNHG5SB.js → chunk-UJM7AJII.js} +1 -1
- package/dist/chunks/chunk-VAWD57ZB.js +2 -0
- package/dist/chunks/{chunk-LNUNKFIH.js → chunk-WBEYJ5W5.js} +2 -2
- package/dist/chunks/{chunk-LMNU4NHZ.js → chunk-YK2EJU6T.js} +2 -2
- package/dist/descriptive.js +2 -2
- package/dist/distributions.js +2 -2
- package/dist/entries/tests.d.ts +6 -0
- package/dist/entries/tests.js +6 -0
- package/dist/htest/sampleSize.d.ts +290 -0
- package/dist/htest/sampleSize.js +625 -0
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +2 -2
- package/dist/models/competingRisks.d.ts +188 -0
- package/dist/models/competingRisks.js +685 -0
- package/dist/models/coxZph.d.ts +67 -0
- package/dist/models/coxZph.js +479 -0
- package/dist/models/coxph.d.ts +61 -21
- package/dist/models/coxph.js +305 -65
- package/dist/models/metaAnalysis.d.ts +207 -0
- package/dist/models/metaAnalysis.js +696 -0
- package/dist/models/rmst2.d.ts +126 -0
- package/dist/models/rmst2.js +365 -0
- package/dist/models/survival.d.ts +65 -24
- package/dist/models/survival.js +407 -72
- package/dist/models/survreg.d.ts +160 -0
- package/dist/models/survreg.js +809 -0
- package/dist/numerics.js +2 -2
- package/dist/rstats.js +19 -16
- package/dist/special.js +2 -2
- package/dist/tests.js +16 -13
- package/llms.txt +13 -2
- package/package.json +1 -1
- package/dist/chunks/chunk-4OOTEXZU.js +0 -2
- package/dist/chunks/chunk-MJXETGT2.js +0 -2
package/dist/models/coxph.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface CoxphControl {
|
|
|
13
13
|
tolerChol?: number;
|
|
14
14
|
/** Tolerance of the check for infinite coefficients. Default sqrt(`eps`). */
|
|
15
15
|
tolerInf?: number;
|
|
16
|
+
/** Whether to merge event times (and start/stop times for counting-process data) within the tolerance of aeqSurv. Default true. */
|
|
17
|
+
timefix?: boolean;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Options for {@link coxph}.
|
|
@@ -20,6 +22,10 @@ export interface CoxphControl {
|
|
|
20
22
|
* @category Survival analysis
|
|
21
23
|
*/
|
|
22
24
|
export interface CoxphOptions {
|
|
25
|
+
/** Start times for counting-process data; when present, time is the stop time. */
|
|
26
|
+
start?: readonly number[];
|
|
27
|
+
/** Subject identifiers for counting-process data; missing identifiers drop their rows. */
|
|
28
|
+
id?: readonly (GroupLabel | null)[];
|
|
23
29
|
/** Handling of tied event times. Default `"efron"`. */
|
|
24
30
|
ties?: "efron" | "breslow";
|
|
25
31
|
/** Case weights (positive). A weight that is not an integer switches the robust variance on (see `robust`). */
|
|
@@ -35,14 +41,16 @@ export interface CoxphOptions {
|
|
|
35
41
|
/** Confidence level of the intervals of exp(coef). Default 0.95. */
|
|
36
42
|
confLevel?: number;
|
|
37
43
|
/**
|
|
38
|
-
* Whether to use the robust (Lin-Wei sandwich) variance. Default as R: `true` when `cluster` is given
|
|
39
|
-
* weight is not an integer, else `false`. With `false` a
|
|
44
|
+
* Whether to use the robust (Lin-Wei sandwich) variance. Default as R: `true` when `cluster` is given, a counting
|
|
45
|
+
* process `id` has repeated event rows, or some case weight is not an integer, else `false`. With `false` a
|
|
46
|
+
* `cluster` is ignored (with R's warning).
|
|
40
47
|
*/
|
|
41
48
|
robust?: boolean;
|
|
42
49
|
/**
|
|
43
50
|
* Cluster labels, one per observation, for the robust variance (R's `cluster`): the observations of a cluster are
|
|
44
51
|
* treated as correlated. Rows with a missing label (`null` or NaN) are dropped, like rows with a missing stratum.
|
|
45
|
-
*
|
|
52
|
+
* For counting-process data, `id` supplies the subject clusters when `cluster` is absent. Without either, each row
|
|
53
|
+
* is its own cluster for the default robust variance of non-integer weights. At least two clusters are needed.
|
|
46
54
|
*/
|
|
47
55
|
cluster?: readonly (GroupLabel | null)[];
|
|
48
56
|
}
|
|
@@ -59,12 +67,40 @@ export interface CoxphTest {
|
|
|
59
67
|
/** Upper chi-squared tail (R's `pvalue`). */
|
|
60
68
|
pValue: number;
|
|
61
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Processed coxph data retained privately for coxZph; all row arrays are in the fit's used-input order unless named sorted.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
* @category Survival analysis
|
|
75
|
+
*/
|
|
76
|
+
export interface CoxphZphData {
|
|
77
|
+
time: number[];
|
|
78
|
+
start?: number[];
|
|
79
|
+
status: boolean[];
|
|
80
|
+
weights: number[];
|
|
81
|
+
strata?: GroupLabel[];
|
|
82
|
+
x: number[][];
|
|
83
|
+
sortedToInput: number[];
|
|
84
|
+
sortedTime: number[];
|
|
85
|
+
sortedStart?: number[];
|
|
86
|
+
sortedEvent: boolean[];
|
|
87
|
+
sortedWeight: number[];
|
|
88
|
+
sortedX: number[][];
|
|
89
|
+
stratumIndex: number[];
|
|
90
|
+
stratumEnd: boolean[];
|
|
91
|
+
betaScaled: number[];
|
|
92
|
+
inverseCovariateScale: number[];
|
|
93
|
+
weightExp: number;
|
|
94
|
+
ties: "efron" | "breslow";
|
|
95
|
+
}
|
|
62
96
|
/**
|
|
63
97
|
* Result of {@link coxph}.
|
|
64
98
|
*
|
|
65
99
|
* @category Survival analysis
|
|
66
100
|
*/
|
|
67
101
|
export interface CoxphResult {
|
|
102
|
+
/** @internal Non-enumerable fit data used by coxZph; not part of the serialized result. */
|
|
103
|
+
coxZphData?: CoxphZphData;
|
|
68
104
|
/** Coefficients (NaN for R's NA: an aliased column or one whose information fell below the tolerance) */
|
|
69
105
|
coefficients: number[];
|
|
70
106
|
/**
|
|
@@ -78,7 +114,7 @@ export interface CoxphResult {
|
|
|
78
114
|
score: number;
|
|
79
115
|
/** The Wald statistic of the non-NA coefficients (against `init` when given) */
|
|
80
116
|
wald: number;
|
|
81
|
-
/** Number of iterations (`iterMax + 1` when they ran out) */
|
|
117
|
+
/** Number of iterations (`iterMax + 1` for right-censored fits, `iterMax` for counting-process fits when they ran out). */
|
|
82
118
|
iter: number;
|
|
83
119
|
/** The means used to centre the covariates (0 for the columns not centred) */
|
|
84
120
|
means: number[];
|
|
@@ -86,6 +122,8 @@ export interface CoxphResult {
|
|
|
86
122
|
n: number;
|
|
87
123
|
/** Number of events */
|
|
88
124
|
nevent: number;
|
|
125
|
+
/** Number of distinct subjects, only when id was supplied. */
|
|
126
|
+
nId?: number;
|
|
89
127
|
/** Linear predictors (centred by the means), one per observation used, in input order */
|
|
90
128
|
linearPredictors: number[];
|
|
91
129
|
/**
|
|
@@ -138,27 +176,27 @@ export interface CoxphResult {
|
|
|
138
176
|
}
|
|
139
177
|
/**
|
|
140
178
|
* Cox proportional hazards regression. Equivalent to R's `survival::coxph()`. As
|
|
141
|
-
* `coxph(Surv(time, status) ~ x
|
|
142
|
-
* data, with the values of `summary(fit)`.
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
179
|
+
* `coxph(Surv(time, status) ~ x ...)` for right-censored data and `coxph(Surv(start, stop, status) ~ x ...)` for
|
|
180
|
+
* counting-process data (with the option `start`), with the values of `summary(fit)`.
|
|
181
|
+
* With `robust` (by default when `cluster` is given, a counting-process `id` has repeated event rows, or a case
|
|
182
|
+
* weight is not an integer) the variance is the robust (Lin-Wei sandwich) one, summed over the clusters (each
|
|
183
|
+
* observation its own cluster without `cluster` or `id`), as R:
|
|
146
184
|
* `var` is the robust variance and `naiveVar` the model-based one; `se` (and `stdError`) stay the model-based standard
|
|
147
185
|
* errors (R's `se(coef)`), while `z`, `p`, the intervals `lower`/`upper`, `wald` and `waldtest` use the robust ones
|
|
148
186
|
* (`robustSe`); `robscore` is the robust score test at `init`. The likelihood ratio and score tests and the R^2 ignore
|
|
149
187
|
* the clustering.
|
|
150
188
|
*
|
|
151
|
-
* Rows with a missing time, status, covariate, weight or
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
189
|
+
* Rows with a missing time, status, covariate, weight, stratum, cluster or id are dropped. With `start`, the time is
|
|
190
|
+
* the stop time and the risk set is `start < t <= stop`; start and stop times are merged together unless
|
|
191
|
+
* `control.timefix` is false. Counting-process means are unweighted; right-censored means are weighted. With `id`,
|
|
192
|
+
* `nId` reports distinct subjects; `rsq` still uses the number of rows. R's warnings are returned in `warnings`.
|
|
155
193
|
*
|
|
156
|
-
* @param time Follow-up times.
|
|
157
|
-
* @param status 1 for an event, 0 for a censored time.
|
|
194
|
+
* @param time Follow-up/stop times; with `start`, these are the stop times.
|
|
195
|
+
* @param status 1 for an event, 0 for a censored time (other counting-process values are dropped with a warning).
|
|
158
196
|
* @param x The covariate matrix, one row per observation (at least one column).
|
|
159
197
|
* @param options See {@link CoxphOptions}.
|
|
160
|
-
* @throws TypeError if `robust` is not a boolean. RangeError for invalid arguments, among them
|
|
161
|
-
* and a robust variance with fewer than two clusters.
|
|
198
|
+
* @throws TypeError if `robust` or `control.timefix` is not a boolean. RangeError for invalid arguments, among them
|
|
199
|
+
* an infinite weight, an interval with `start >= stop`, and a robust variance with fewer than two clusters.
|
|
162
200
|
*
|
|
163
201
|
* @example
|
|
164
202
|
* ```ts
|
|
@@ -171,14 +209,16 @@ export interface CoxphResult {
|
|
|
171
209
|
*/
|
|
172
210
|
export declare function coxph(time: readonly number[], status: readonly number[], x: readonly (readonly number[])[], options?: CoxphOptions): CoxphResult;
|
|
173
211
|
/**
|
|
174
|
-
* The fit of {@link coxph},
|
|
175
|
-
*
|
|
176
|
-
*
|
|
212
|
+
* The fit of {@link coxph}, plus the score and dfbeta residuals used by the tests (not exported from the package):
|
|
213
|
+
* R's `residuals(fit, type = "score")` (unweighted) and `residuals(fit, type = "dfbeta")` (weighted), one row per
|
|
214
|
+
* observation used, in input order. Counting-process fixtures also compare the final score vector and convergence flag.
|
|
177
215
|
*
|
|
178
216
|
* @internal
|
|
179
217
|
*/
|
|
180
|
-
export declare function fitCoxph(time: readonly number[], status: readonly number[], x: readonly (readonly number[])[], options?: CoxphOptions): {
|
|
218
|
+
export declare function fitCoxph(time: readonly number[], status: readonly number[], x: readonly (readonly number[])[], options?: CoxphOptions, collectCountingResiduals?: boolean): {
|
|
181
219
|
result: CoxphResult;
|
|
182
220
|
scoreResiduals?: number[][];
|
|
183
221
|
dfbeta?: number[][];
|
|
222
|
+
first?: number[];
|
|
223
|
+
converged?: boolean;
|
|
184
224
|
};
|