@numero-uno-jpn/rstats 1.4.0 → 1.6.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.ja.md +13 -6
  3. package/README.md +13 -6
  4. package/dist/chunks/{chunk-GEF2YRBV.js → chunk-2I7Z7L5J.js} +2 -2
  5. package/dist/chunks/{chunk-F6Z3GLWA.js → chunk-2TVHT4PF.js} +2 -2
  6. package/dist/chunks/{chunk-GBSMRVUY.js → chunk-3PCHPKBD.js} +2 -2
  7. package/dist/chunks/{chunk-TEHMTQNB.js → chunk-55XSRONZ.js} +2 -2
  8. package/dist/chunks/{chunk-5SW3L6J3.js → chunk-5AITXV3T.js} +2 -2
  9. package/dist/chunks/{chunk-GLGOV3A5.js → chunk-7ZNFRZO4.js} +2 -2
  10. package/dist/chunks/{chunk-56GFP4UU.js → chunk-ABSUQPOG.js} +2 -2
  11. package/dist/chunks/{chunk-RUZATICF.js → chunk-AHFMBHZW.js} +1 -1
  12. package/dist/chunks/chunk-BJTGQ52J.js +2 -0
  13. package/dist/chunks/{chunk-SVS54D6Z.js → chunk-BMEO5X5F.js} +2 -2
  14. package/dist/chunks/chunk-F7G74UNI.js +3 -0
  15. package/dist/chunks/{chunk-HWB7XRX2.js → chunk-FLITCXLY.js} +2 -2
  16. package/dist/chunks/{chunk-PZ66PUWC.js → chunk-KAAUNR3G.js} +1 -1
  17. package/dist/chunks/chunk-KND2BFD5.js +2 -0
  18. package/dist/chunks/{chunk-ZRFZ5UIB.js → chunk-N2PNW4HR.js} +2 -2
  19. package/dist/chunks/{chunk-V2KVTAVV.js → chunk-NVIJXWS6.js} +2 -2
  20. package/dist/chunks/{chunk-J72MLFUG.js → chunk-O5CMNUJL.js} +2 -2
  21. package/dist/chunks/{chunk-WWJGCBWH.js → chunk-OZLDZOOA.js} +1 -1
  22. package/dist/chunks/chunk-RSTU6CX7.js +2 -0
  23. package/dist/chunks/{chunk-GIER5WMB.js → chunk-SFZF44G6.js} +2 -2
  24. package/dist/chunks/{chunk-ZQSOMEIM.js → chunk-TPBVVP32.js} +2 -2
  25. package/dist/chunks/{chunk-S2YCFUCA.js → chunk-WAMHZ47G.js} +2 -2
  26. package/dist/chunks/chunk-XNWSQVXS.js +2 -0
  27. package/dist/chunks/{chunk-X7K6EF7S.js → chunk-Z2XN4NN7.js} +2 -2
  28. package/dist/chunks/{chunk-RY7CCWVU.js → chunk-ZL7EAPO5.js} +1 -1
  29. package/dist/descriptive.js +2 -2
  30. package/dist/distributions.js +2 -2
  31. package/dist/entries/mixed.d.ts +2 -0
  32. package/dist/entries/mixed.js +2 -0
  33. package/dist/entries/tests.d.ts +2 -0
  34. package/dist/entries/tests.js +2 -0
  35. package/dist/htest/sampleSize.d.ts +290 -0
  36. package/dist/htest/sampleSize.js +625 -0
  37. package/dist/linalg.js +2 -2
  38. package/dist/mixed.js +5 -5
  39. package/dist/models/competingRisks.d.ts +1 -1
  40. package/dist/models/competingRisks.js +42 -30
  41. package/dist/models/metaAnalysis.d.ts +207 -0
  42. package/dist/models/metaAnalysis.js +696 -0
  43. package/dist/models/mixedConfint.d.ts +42 -0
  44. package/dist/models/mixedConfint.js +573 -0
  45. package/dist/models/mixedSimulate.d.ts +36 -0
  46. package/dist/models/mixedSimulate.js +232 -0
  47. package/dist/numerics.js +2 -2
  48. package/dist/rstats.js +19 -16
  49. package/dist/special.js +2 -2
  50. package/dist/tests.js +16 -13
  51. package/llms.txt +8 -3
  52. package/package.json +1 -1
  53. package/dist/chunks/chunk-27VFB3SA.js +0 -2
  54. package/dist/chunks/chunk-6FZAJQ4H.js +0 -2
  55. package/dist/chunks/chunk-BQJFFGYP.js +0 -2
  56. package/dist/chunks/chunk-H72MW7YP.js +0 -2
  57. package/dist/chunks/chunk-UMMCVF53.js +0 -2
  58. package/dist/chunks/chunk-UNP4HBPP.js +0 -3
  59. package/dist/chunks/chunk-YBOSCQF2.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;