@numero-uno-jpn/rstats 1.2.0 → 1.4.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 (89) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/README.ja.md +28 -11
  3. package/README.md +27 -10
  4. package/dist/chunks/{chunk-RRO4LMCB.js → chunk-27VFB3SA.js} +2 -2
  5. package/dist/chunks/{chunk-BKV3FINA.js → chunk-56GFP4UU.js} +2 -2
  6. package/dist/chunks/{chunk-JWBSEL3V.js → chunk-5SW3L6J3.js} +2 -2
  7. package/dist/chunks/{chunk-NSU6U3ET.js → chunk-6FZAJQ4H.js} +2 -2
  8. package/dist/chunks/{chunk-VERBXW6E.js → chunk-BQJFFGYP.js} +2 -2
  9. package/dist/chunks/{chunk-ORE5ZRCY.js → chunk-F6Z3GLWA.js} +2 -2
  10. package/dist/chunks/{chunk-2NNBUYHJ.js → chunk-GBSMRVUY.js} +2 -2
  11. package/dist/chunks/{chunk-7WG7X2UI.js → chunk-GEF2YRBV.js} +2 -2
  12. package/dist/chunks/{chunk-L23RSC2N.js → chunk-GIER5WMB.js} +2 -2
  13. package/dist/chunks/{chunk-IAWXF73N.js → chunk-GLGOV3A5.js} +2 -2
  14. package/dist/chunks/{chunk-F3EQLL4F.js → chunk-H72MW7YP.js} +2 -2
  15. package/dist/chunks/{chunk-T5DRIITM.js → chunk-HWB7XRX2.js} +2 -2
  16. package/dist/chunks/chunk-J72MLFUG.js +2 -0
  17. package/dist/chunks/{chunk-TNETWBF5.js → chunk-PZ66PUWC.js} +2 -2
  18. package/dist/chunks/{chunk-IMPRIQE5.js → chunk-RUZATICF.js} +1 -1
  19. package/dist/chunks/{chunk-BI7NYJWP.js → chunk-RY7CCWVU.js} +1 -1
  20. package/dist/chunks/{chunk-7INBXTVV.js → chunk-S2YCFUCA.js} +2 -2
  21. package/dist/chunks/chunk-SVS54D6Z.js +2 -0
  22. package/dist/chunks/{chunk-HBHMEPGY.js → chunk-TEHMTQNB.js} +3 -3
  23. package/dist/chunks/chunk-UMMCVF53.js +2 -0
  24. package/dist/chunks/{chunk-5SGTWSCB.js → chunk-UNP4HBPP.js} +2 -2
  25. package/dist/chunks/{chunk-A66M3ZEA.js → chunk-V2KVTAVV.js} +2 -2
  26. package/dist/chunks/{chunk-EEU7D4RU.js → chunk-WWJGCBWH.js} +1 -1
  27. package/dist/chunks/chunk-X7K6EF7S.js +2 -0
  28. package/dist/chunks/{chunk-73LNRWU3.js → chunk-YBOSCQF2.js} +1 -1
  29. package/dist/chunks/{chunk-6FZHTD5G.js → chunk-ZQSOMEIM.js} +2 -2
  30. package/dist/chunks/{chunk-4AOTAT3O.js → chunk-ZRFZ5UIB.js} +2 -2
  31. package/dist/descriptive.js +2 -2
  32. package/dist/distributions.js +2 -2
  33. package/dist/entries/tests.d.ts +13 -0
  34. package/dist/entries/tests.js +13 -0
  35. package/dist/htest/agreement.d.ts +2 -2
  36. package/dist/htest/blandAltman.d.ts +100 -0
  37. package/dist/htest/blandAltman.js +159 -0
  38. package/dist/htest/diagnosticTests.d.ts +91 -0
  39. package/dist/htest/diagnosticTests.js +116 -0
  40. package/dist/htest/iccPsych.d.ts +106 -0
  41. package/dist/htest/iccPsych.js +332 -0
  42. package/dist/htest/ksTest.d.ts +1 -1
  43. package/dist/htest/mcreg.d.ts +209 -0
  44. package/dist/htest/mcreg.js +735 -0
  45. package/dist/htest/roc.d.ts +287 -0
  46. package/dist/htest/roc.js +635 -0
  47. package/dist/htest/rocTest.d.ts +139 -0
  48. package/dist/htest/rocTest.js +444 -0
  49. package/dist/htest/tTOST.d.ts +202 -0
  50. package/dist/htest/tTOST.js +558 -0
  51. package/dist/htest/trendTests.d.ts +1 -1
  52. package/dist/htest/trendTests.js +1 -1
  53. package/dist/internal/summary.js +5 -0
  54. package/dist/linalg/qr.d.ts +3 -0
  55. package/dist/linalg/qr.js +3 -0
  56. package/dist/linalg.js +2 -2
  57. package/dist/mixed.js +2 -2
  58. package/dist/models/coeftest.d.ts +139 -0
  59. package/dist/models/coeftest.js +237 -0
  60. package/dist/models/competingRisks.d.ts +188 -0
  61. package/dist/models/competingRisks.js +673 -0
  62. package/dist/models/coxZph.d.ts +67 -0
  63. package/dist/models/coxZph.js +479 -0
  64. package/dist/models/coxph.d.ts +107 -16
  65. package/dist/models/coxph.js +641 -72
  66. package/dist/models/glm.d.ts +11 -1
  67. package/dist/models/glm.js +19 -2
  68. package/dist/models/inputRows.d.ts +10 -0
  69. package/dist/models/inputRows.js +23 -0
  70. package/dist/models/lm.d.ts +8 -0
  71. package/dist/models/lm.js +14 -2
  72. package/dist/models/rmst2.d.ts +126 -0
  73. package/dist/models/rmst2.js +365 -0
  74. package/dist/models/sandwich.d.ts +177 -0
  75. package/dist/models/sandwich.js +923 -0
  76. package/dist/models/survival.d.ts +65 -24
  77. package/dist/models/survival.js +407 -72
  78. package/dist/models/survreg.d.ts +160 -0
  79. package/dist/models/survreg.js +809 -0
  80. package/dist/numerics.js +2 -2
  81. package/dist/random/rng.d.ts +8 -1
  82. package/dist/random/rng.js +14 -1
  83. package/dist/rstats.js +16 -16
  84. package/dist/special.js +2 -2
  85. package/dist/tests.js +13 -13
  86. package/llms.txt +25 -0
  87. package/package.json +1 -1
  88. package/dist/chunks/chunk-47IIPUFN.js +0 -2
  89. package/dist/chunks/chunk-CQB4BJBR.js +0 -2
@@ -39,11 +39,11 @@ export interface SurvdiffResult {
39
39
  warnings: string[];
40
40
  }
41
41
  /**
42
- * Confidence interval type of {@link survfit}.
42
+ * Confidence interval type of {@link survfit}. The unambiguous prefixes "p", "a", "n", "log-", and "logi" are accepted.
43
43
  *
44
44
  * @category Survival analysis
45
45
  */
46
- export type SurvfitConfType = "log" | "plain" | "log-log";
46
+ export type SurvfitConfType = "log" | "plain" | "log-log" | "logit" | "arcsin" | "none" | "p" | "a" | "n" | "log-" | "logi";
47
47
  /**
48
48
  * Options for {@link survfit}.
49
49
  *
@@ -52,7 +52,21 @@ export type SurvfitConfType = "log" | "plain" | "log-log";
52
52
  export interface SurvfitOptions {
53
53
  /** Group labels, one per observation: one curve per group. Omitted: a single curve. */
54
54
  group?: readonly GroupLabel[];
55
- /** Transformation of the pointwise confidence intervals. Default `"log"`. */
55
+ /** Start times for counting-process data; `time` contains the stop times. */
56
+ start?: readonly number[];
57
+ /** Subject identifiers for counting-process data; requires `start`; adjacent split rows are not censorings. */
58
+ id?: readonly (GroupLabel | null)[];
59
+ /** Case weights. Non-negative safe-integer counts are required. */
60
+ weights?: readonly number[];
61
+ /** Cumulative hazard estimator: 1 Nelson-Aalen, 2 Fleming-Harrington. Default 1. */
62
+ ctype?: 1 | 2;
63
+ /** Survival estimator: 1 Kaplan-Meier, 2 exponential of cumulative hazard. Default 1. */
64
+ stype?: 1 | 2;
65
+ /** Use the infinitesimal-jackknife variance. Default false; non-integer weights are rejected. */
66
+ robust?: boolean;
67
+ /** Restricted-mean upper limit: "common" (default), "individual", "none", or a finite number. */
68
+ rmean?: "none" | "common" | "individual" | number;
69
+ /** Transformation of the pointwise confidence intervals. Default "log". */
56
70
  confType?: SurvfitConfType;
57
71
  /** Confidence level. Default 0.95. */
58
72
  confInt?: number;
@@ -63,33 +77,57 @@ export interface SurvfitOptions {
63
77
  * @category Survival analysis
64
78
  */
65
79
  export interface SurvfitResult {
66
- /** Stratum of each row (`"group=<label>"`, or `"all"` for a single curve) */
80
+ /** Stratum label for every time row. */
67
81
  strata: string[];
68
- /** Time of each row (the distinct times of the stratum, censored ones included) */
82
+ /** Distinct observed times, including censoring times. */
69
83
  time: number[];
70
- /** Number at risk just before the time (R's `n.risk`) */
84
+ /** Weighted number at risk just before each time. */
71
85
  nRisk: number[];
72
- /** Number of events at the time (R's `n.event`) */
86
+ /** Weighted number of events at each time. */
73
87
  nEvent: number[];
74
- /** Number censored at the time (R's `n.censor`) */
88
+ /** Weighted number censored at each time. */
75
89
  nCensor: number[];
76
- /** Kaplan-Meier estimate S(t) */
90
+ /** Survival estimate: Kaplan-Meier (`stype: 1`) or exp(-cumhaz) (`stype: 2`). */
77
91
  surv: number[];
78
- /** Standard error of S(t) (S times the standard error of log S) */
92
+ /** Standard error of the survival estimate (the summary standard error). */
79
93
  stdErr: number[];
80
- /** Alias of `stdErr`: the same array. */
94
+ /** Alias of `stdErr`. */
81
95
  stdError: number[];
82
- /**
83
- * Lower limit of the pointwise confidence interval of S(t) (where S(t) = 1, 1 for each `confType`; with `"log-log"`
84
- * as survival 3.8-12, NA before it)
85
- */
96
+ /** Lower and upper pointwise confidence limits. */
86
97
  lower: number[];
87
- /** Upper limit of the pointwise confidence interval of S(t) */
88
98
  upper: number[];
89
- /** Per stratum, [median, lower limit, upper limit] (NaN for R's NA) */
99
+ /** Cumulative hazard and its standard error. */
100
+ cumhaz: number[];
101
+ stdChaz: number[];
102
+ /** Whether the standard error is on the log-survival scale. */
103
+ logse: boolean;
104
+ /** Number of retained records per stratum. */
105
+ n: number[];
106
+ /** Unweighted risk/event/censor counts, present when case weights were supplied. */
107
+ counts?: {
108
+ nRisk: number[];
109
+ nEvent: number[];
110
+ nCensor: number[];
111
+ };
112
+ /** Summary-table record count, maximum risk set, starting risk set and weighted event total. */
113
+ records: number[];
114
+ nMax: number[];
115
+ nStart: number[];
116
+ events: number[];
117
+ /** Restricted mean survival time and its standard error per stratum (NaN when rmean is "none"). */
118
+ rmean: number[];
119
+ seRmean: number[];
120
+ /** Per stratum: median, lower median limit, upper median limit. */
90
121
  median: number[][];
91
- /** The strata of `median` */
92
122
  medianRows: string[];
123
+ /** R-style summary table, with column and row names. */
124
+ table: {
125
+ colNames: string[];
126
+ rowNames: string[];
127
+ table: number[][];
128
+ };
129
+ /** Warnings produced by the fit. */
130
+ warnings: string[];
93
131
  }
94
132
  /**
95
133
  * Test of the difference between survival curves: the G-rho family of Harrington and Fleming, the log-rank test for
@@ -97,7 +135,7 @@ export interface SurvfitResult {
97
135
  *
98
136
  * Rows with a missing time, status or group are dropped.
99
137
  *
100
- * @param time Follow-up times.
138
+ * @param time Follow-up times, or stop times when `options.start` is supplied.
101
139
  * @param status 1 for an event, 0 for a censored time.
102
140
  * @param group Group labels, one per observation.
103
141
  * @param options See {@link SurvdiffOptions}.
@@ -113,15 +151,18 @@ export interface SurvfitResult {
113
151
  */
114
152
  export declare function survdiff(time: readonly number[], status: readonly number[], group: readonly (GroupLabel | null)[], options?: SurvdiffOptions): SurvdiffResult;
115
153
  /**
116
- * Kaplan-Meier estimate of the survival function with Greenwood's standard error and pointwise confidence intervals.
117
- * Equivalent to R's `survival::survfit()`. As `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int),
118
- * censored = TRUE)`, with the medians and their confidence limits of `summary(fit)$table`.
154
+ * Kaplan-Meier or exponential cumulative-hazard estimate with pointwise confidence intervals, medians and restricted means.
155
+ * Equivalent to R's `survival::survfit()`. Supports right-censored and counting-process data, Nelson-Aalen and Fleming-Harrington cumulative hazards,
156
+ * integer case weights, infinitesimal-jackknife standard errors and all six confidence transformations.
119
157
  *
120
- * Rows with a missing time, status or group are dropped.
158
+ * Rows with a missing time, status, group, id or weight are dropped. With `start`, the risk set at t is
159
+ * `start < t <= time`; without `id`, each split row ending without an event is a censoring. With `id`, a row
160
+ * followed by another row for the same subject at the same boundary is not a censoring.
121
161
  *
122
- * @param time Follow-up times.
162
+ * @param time Follow-up times, or stop times when `options.start` is supplied.
123
163
  * @param status 1 for an event, 0 for a censored time.
124
164
  * @param options See {@link SurvfitOptions}.
165
+ * @returns Time-row estimates, pointwise limits, per-stratum medians and restricted-mean summaries.
125
166
  *
126
167
  * @example
127
168
  * ```ts