@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
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/** Options shared by the epiR parallel-trial sample-size and power functions.
|
|
2
|
+
* @category Effect sizes and power
|
|
3
|
+
*/
|
|
4
|
+
export interface EpiOptions {
|
|
5
|
+
/** Total sample size; null/omitted when solving for sample size. */
|
|
6
|
+
n?: number | null;
|
|
7
|
+
/** Target power; null/omitted when solving for power. */
|
|
8
|
+
power?: number | null;
|
|
9
|
+
/** Treatment/control allocation ratio. Default 1. */
|
|
10
|
+
r?: number;
|
|
11
|
+
/** Equivalence or equality. Default "equivalence". */
|
|
12
|
+
type?: "equivalence" | "equality" | (string & {});
|
|
13
|
+
/** Round each group size up separately. Default false. */
|
|
14
|
+
nfractional?: boolean;
|
|
15
|
+
/** Significance level. Default 0.05. */
|
|
16
|
+
alpha?: number;
|
|
17
|
+
/** Number of tails for superiority: 1 or 2. Default 1. */
|
|
18
|
+
sidedTest?: 1 | 2;
|
|
19
|
+
}
|
|
20
|
+
/** Sample-size and power result for an epiR parallel-trial design.
|
|
21
|
+
* @category Effect sizes and power
|
|
22
|
+
*/
|
|
23
|
+
export interface EpiResult {
|
|
24
|
+
nTotal: number;
|
|
25
|
+
nTreat: number;
|
|
26
|
+
nControl: number;
|
|
27
|
+
nTotalUnrounded: number;
|
|
28
|
+
nTreatUnrounded: number;
|
|
29
|
+
nControlUnrounded: number;
|
|
30
|
+
power: number;
|
|
31
|
+
delta?: number;
|
|
32
|
+
warnings: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Equivalence/equality sample size or power for two proportions. Equivalent to `epiR::epi.ssequb()` in R.
|
|
35
|
+
* @param treat Expected treatment-group proportion.
|
|
36
|
+
* @param control Expected control-group proportion.
|
|
37
|
+
* @param delta Equivalence margin; pass null for equality.
|
|
38
|
+
* @param options Sample-size, power and allocation options.
|
|
39
|
+
* @returns The fractional and requested group sizes, and power. The sample-size formula follows epiR's expression and is not an exact inverse of the TOST power calculation.
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* epiSsequb(0.5, 0.45, 0.1, { n: 120 }).power;
|
|
43
|
+
* ```
|
|
44
|
+
* @category Effect sizes and power
|
|
45
|
+
*/
|
|
46
|
+
export declare function epiSsequb(treat: number, control: number, delta: number | null, options?: EpiOptions): EpiResult;
|
|
47
|
+
/** Equivalence/equality sample size or power for two means. Equivalent to `epiR::epi.ssequc()` in R.
|
|
48
|
+
* @param treat Expected treatment-group mean.
|
|
49
|
+
* @param control Expected control-group mean.
|
|
50
|
+
* @param sigma Common standard deviation.
|
|
51
|
+
* @param delta Equivalence margin; pass null for equality.
|
|
52
|
+
* @param options Sample-size, power and allocation options.
|
|
53
|
+
* @returns The fractional and requested group sizes, and power. The sample-size formula follows epiR's expression and is not an exact inverse of the TOST power calculation.
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* epiSsequc(20, 21, 10, 5, { n: 120 }).power;
|
|
57
|
+
* ```
|
|
58
|
+
* @category Effect sizes and power
|
|
59
|
+
*/
|
|
60
|
+
export declare function epiSsequc(treat: number, control: number, sigma: number, delta: number | null, options?: EpiOptions): EpiResult;
|
|
61
|
+
/** Non-inferiority sample size or power for two proportions. Equivalent to `epiR::epi.ssninfb()` in R.
|
|
62
|
+
* @param treat Expected treatment-group proportion.
|
|
63
|
+
* @param control Expected control-group proportion.
|
|
64
|
+
* @param delta Non-inferiority margin.
|
|
65
|
+
* @param options Sample-size, power and allocation options.
|
|
66
|
+
* @returns The fractional and requested group sizes, and power.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* epiSsninfb(0.85, 0.65, 0.1, { n: 120 }).power;
|
|
70
|
+
* ```
|
|
71
|
+
* @category Effect sizes and power
|
|
72
|
+
*/
|
|
73
|
+
export declare function epiSsninfb(treat: number, control: number, delta: number, options?: EpiOptions): EpiResult;
|
|
74
|
+
/** Non-inferiority sample size or power for two means. Equivalent to `epiR::epi.ssninfc()` in R.
|
|
75
|
+
* @param treat Expected treatment-group mean.
|
|
76
|
+
* @param control Expected control-group mean.
|
|
77
|
+
* @param sigma Common standard deviation.
|
|
78
|
+
* @param delta Non-inferiority margin.
|
|
79
|
+
* @param options Sample-size, power and allocation options.
|
|
80
|
+
* @returns The fractional and requested group sizes, and power.
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* epiSsninfc(0.22, 0.2, 0.1, 0.05, { n: 120 }).power;
|
|
84
|
+
* ```
|
|
85
|
+
* @category Effect sizes and power
|
|
86
|
+
*/
|
|
87
|
+
export declare function epiSsninfc(treat: number, control: number, sigma: number, delta: number, options?: EpiOptions): EpiResult;
|
|
88
|
+
/** Superiority sample size or power for two proportions. Equivalent to `epiR::epi.sssupb()` in R.
|
|
89
|
+
* @param treat Expected treatment-group proportion.
|
|
90
|
+
* @param control Expected control-group proportion.
|
|
91
|
+
* @param delta Superiority margin.
|
|
92
|
+
* @param options Sample-size, power and allocation options.
|
|
93
|
+
* @returns The fractional and requested group sizes, and power.
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* epiSssupb(0.5, 0.3, 0.05, { n: 101, r: 0.5, sidedTest: 1 }).power;
|
|
97
|
+
* ```
|
|
98
|
+
* @category Effect sizes and power
|
|
99
|
+
*/
|
|
100
|
+
export declare function epiSssupb(treat: number, control: number, delta: number, options?: EpiOptions): EpiResult;
|
|
101
|
+
/** Superiority sample size or power for two means. Equivalent to `epiR::epi.sssupc()` in R.
|
|
102
|
+
* @param treat Expected treatment-group mean.
|
|
103
|
+
* @param control Expected control-group mean.
|
|
104
|
+
* @param sigma Common standard deviation.
|
|
105
|
+
* @param delta Superiority margin.
|
|
106
|
+
* @param options Sample-size, power and allocation options.
|
|
107
|
+
* @returns The fractional and requested group sizes, and power.
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* epiSssupc(20, 20, 10, 5, { n: 120, r: 1.5, sidedTest: 1 }).power;
|
|
111
|
+
* ```
|
|
112
|
+
* @category Effect sizes and power
|
|
113
|
+
*/
|
|
114
|
+
export declare function epiSssupc(treat: number, control: number, sigma: number, delta: number, options?: EpiOptions): EpiResult;
|
|
115
|
+
/** Options for the exact paired McNemar power calculation.
|
|
116
|
+
* @category Effect sizes and power
|
|
117
|
+
*/
|
|
118
|
+
export interface PowerPaired2x2Options {
|
|
119
|
+
sigLevel?: number;
|
|
120
|
+
alternative?: "two.sided" | "one.sided" | (string & {});
|
|
121
|
+
strict?: boolean;
|
|
122
|
+
nullOddsRatio?: number;
|
|
123
|
+
/** Probability budget omitted from the extreme tails of the discordant-pair count. Default 1e-6; zero uses all counts. */
|
|
124
|
+
errbound?: number;
|
|
125
|
+
tsmethod?: "central" | "minlike" | "blaker" | (string & {});
|
|
126
|
+
}
|
|
127
|
+
/** Result of the exact paired McNemar power calculation.
|
|
128
|
+
* @category Effect sizes and power
|
|
129
|
+
*/
|
|
130
|
+
export interface PowerPaired2x2Result {
|
|
131
|
+
power: number;
|
|
132
|
+
npairs: number;
|
|
133
|
+
pb: number;
|
|
134
|
+
pc: number;
|
|
135
|
+
sigLevel: number;
|
|
136
|
+
alternative: "two.sided" | "one.sided";
|
|
137
|
+
nullOddsRatio: number;
|
|
138
|
+
note: string;
|
|
139
|
+
method: string;
|
|
140
|
+
warnings: string[];
|
|
141
|
+
}
|
|
142
|
+
/** Exact power of McNemar's test for paired binary outcomes. Equivalent to `exact2x2::powerPaired2x2()` in R.
|
|
143
|
+
* @param pb Probability of a discordant pair with control 0 and treatment 1.
|
|
144
|
+
* @param pc Probability of a discordant pair with control 1 and treatment 0.
|
|
145
|
+
* @param npairs Number of pairs.
|
|
146
|
+
* @param options Test options. `errbound=0` evaluates the full sum; a positive value may omit extreme discordant-pair-count tails with total omitted probability no greater than `errbound`.
|
|
147
|
+
* @returns The power and test settings.
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* powerPaired2x2(0.5, 0.3, 40).power;
|
|
151
|
+
* ```
|
|
152
|
+
* @category Effect sizes and power
|
|
153
|
+
*/
|
|
154
|
+
export declare function powerPaired2x2(pb: number, pc: number, npairs: number, options?: PowerPaired2x2Options): PowerPaired2x2Result;
|
|
155
|
+
/** Significance-level options for survival sample-size calculations.
|
|
156
|
+
* @category Effect sizes and power
|
|
157
|
+
*/
|
|
158
|
+
export interface SurvivalOptions {
|
|
159
|
+
alpha?: number;
|
|
160
|
+
}
|
|
161
|
+
/** Result of a Freedman clinical-trial sample-size calculation.
|
|
162
|
+
* @category Effect sizes and power
|
|
163
|
+
*/
|
|
164
|
+
export interface SSizeCTResult {
|
|
165
|
+
nE: number;
|
|
166
|
+
nC: number;
|
|
167
|
+
}
|
|
168
|
+
/** Freedman clinical-trial power. Equivalent to `powerSurvEpi::powerCT.default()` in R.
|
|
169
|
+
* @param nE Experimental-group sample size.
|
|
170
|
+
* @param nC Control-group sample size.
|
|
171
|
+
* @param pE Experimental-group event probability.
|
|
172
|
+
* @param pC Control-group event probability.
|
|
173
|
+
* @param RR Experimental/control hazard ratio.
|
|
174
|
+
* @param options Significance level.
|
|
175
|
+
* @returns The normal-approximation power.
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* powerCT(200, 200, 0.3707, 0.489, 0.7);
|
|
179
|
+
* ```
|
|
180
|
+
* @category Effect sizes and power
|
|
181
|
+
*/
|
|
182
|
+
export declare function powerCT(nE: number, nC: number, pE: number, pC: number, RR: number, options?: SurvivalOptions): number;
|
|
183
|
+
/** Freedman clinical-trial sample size. Equivalent to `powerSurvEpi::ssizeCT.default()` in R.
|
|
184
|
+
* @param power Target power.
|
|
185
|
+
* @param k Experimental/control allocation ratio.
|
|
186
|
+
* @param pE Experimental-group event probability.
|
|
187
|
+
* @param pC Control-group event probability.
|
|
188
|
+
* @param RR Experimental/control hazard ratio.
|
|
189
|
+
* @param options Significance level.
|
|
190
|
+
* @returns The integer sample sizes in the two groups.
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* ssizeCT(0.8, 1, 0.3707, 0.489, 0.7);
|
|
194
|
+
* ```
|
|
195
|
+
* @category Effect sizes and power
|
|
196
|
+
*/
|
|
197
|
+
export declare function ssizeCT(power: number, k: number, pE: number, pC: number, RR: number, options?: SurvivalOptions): SSizeCTResult;
|
|
198
|
+
/** Schoenfeld/Latouche Cox-model power. Equivalent to `powerSurvEpi::powerEpi.default()` in R.
|
|
199
|
+
* @param n Total sample size.
|
|
200
|
+
* @param theta Hazard ratio.
|
|
201
|
+
* @param p Prevalence of the binary covariate.
|
|
202
|
+
* @param psi Event proportion.
|
|
203
|
+
* @param rho2 Squared correlation with another covariate.
|
|
204
|
+
* @param options Significance level.
|
|
205
|
+
* @returns The normal-approximation power.
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* powerEpi(139, 2, 0.39, 0.505, 0.132 ** 2);
|
|
209
|
+
* ```
|
|
210
|
+
* @category Effect sizes and power
|
|
211
|
+
*/
|
|
212
|
+
export declare function powerEpi(n: number, theta: number, p: number, psi: number, rho2: number, options?: SurvivalOptions): number;
|
|
213
|
+
/** Schoenfeld/Latouche total sample size. Equivalent to `powerSurvEpi::ssizeEpi.default()` in R.
|
|
214
|
+
* @param power Target power.
|
|
215
|
+
* @param theta Hazard ratio.
|
|
216
|
+
* @param p Prevalence of the binary covariate.
|
|
217
|
+
* @param psi Event proportion.
|
|
218
|
+
* @param rho2 Squared correlation with another covariate.
|
|
219
|
+
* @param options Significance level.
|
|
220
|
+
* @returns The integer total sample size.
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* ssizeEpi(0.8, 2, 0.39, 0.505, 0.132 ** 2);
|
|
224
|
+
* ```
|
|
225
|
+
* @category Effect sizes and power
|
|
226
|
+
*/
|
|
227
|
+
export declare function ssizeEpi(power: number, theta: number, p: number, psi: number, rho2: number, options?: SurvivalOptions): number;
|
|
228
|
+
/** Schoenfeld/Latouche required event count. Equivalent to `powerSurvEpi::numDEpi.default()` in R.
|
|
229
|
+
* @param power Target power.
|
|
230
|
+
* @param theta Hazard ratio.
|
|
231
|
+
* @param p Prevalence of the binary covariate.
|
|
232
|
+
* @param rho2 Squared correlation with another covariate.
|
|
233
|
+
* @param options Significance level.
|
|
234
|
+
* @returns The integer number of events required.
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* numDEpi(0.8, 2, 0.39, 0.132 ** 2);
|
|
238
|
+
* ```
|
|
239
|
+
* @category Effect sizes and power
|
|
240
|
+
*/
|
|
241
|
+
export declare function numDEpi(power: number, theta: number, p: number, rho2: number, options?: SurvivalOptions): number;
|
|
242
|
+
/** A feasible two-stage Simon candidate.
|
|
243
|
+
* @category Effect sizes and power
|
|
244
|
+
*/
|
|
245
|
+
export interface SimonRow {
|
|
246
|
+
r1: number;
|
|
247
|
+
n1: number;
|
|
248
|
+
r: number;
|
|
249
|
+
n: number;
|
|
250
|
+
enP0: number;
|
|
251
|
+
petP0: number;
|
|
252
|
+
}
|
|
253
|
+
/** A selected Simon design and its interval of q values.
|
|
254
|
+
* @category Effect sizes and power
|
|
255
|
+
*/
|
|
256
|
+
export interface SimonDesign extends SimonRow {
|
|
257
|
+
qLo: number;
|
|
258
|
+
qHi: number;
|
|
259
|
+
}
|
|
260
|
+
/** Candidate designs and selected minimax, optimal and admissible Simon designs.
|
|
261
|
+
* @category Effect sizes and power
|
|
262
|
+
*/
|
|
263
|
+
export interface SimonDesignResult {
|
|
264
|
+
out: SimonRow[];
|
|
265
|
+
minimax: SimonDesign;
|
|
266
|
+
optimal: SimonDesign;
|
|
267
|
+
admissible: SimonDesign[];
|
|
268
|
+
pu: number;
|
|
269
|
+
pa: number;
|
|
270
|
+
alpha: number;
|
|
271
|
+
beta: number;
|
|
272
|
+
nmax: number;
|
|
273
|
+
warnings: string[];
|
|
274
|
+
}
|
|
275
|
+
/** Enumerates Simon's two-stage Phase II designs. Equivalent to `clinfun::ph2simon()` in R.
|
|
276
|
+
* @param pu Unacceptable response rate.
|
|
277
|
+
* @param pa Desirable response rate.
|
|
278
|
+
* @param ep1 Maximum type-I error at pu.
|
|
279
|
+
* @param ep2 Maximum type-II error at pa.
|
|
280
|
+
* @param options Maximum total sample size, at most 1000.
|
|
281
|
+
* @returns Candidate rows and structured minimax, optimal and admissible designs.
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* ph2simon(0.2, 0.4, 0.05, 0.1).minimax.n;
|
|
285
|
+
* ```
|
|
286
|
+
* @category Effect sizes and power
|
|
287
|
+
*/
|
|
288
|
+
export declare function ph2simon(pu: number, pa: number, ep1: number, ep2: number, options?: {
|
|
289
|
+
nmax?: number;
|
|
290
|
+
}): SimonDesignResult;
|