@numero-uno-jpn/rstats 1.17.0 → 1.18.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 (91) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.ja.md +6 -6
  3. package/README.md +6 -6
  4. package/dist/causal/mediationProcedures.js +18 -1
  5. package/dist/causal/moderation.js +11 -2
  6. package/dist/causal.js +2 -2
  7. package/dist/chunks/{chunk-NPWWGIFG.js → chunk-2JB7F646.js} +2 -2
  8. package/dist/chunks/{chunk-JG4TWDQ4.js → chunk-3JFRDXN7.js} +2 -2
  9. package/dist/chunks/chunk-53WQDB3C.js +2 -0
  10. package/dist/chunks/{chunk-QCPGV7XH.js → chunk-5CTWYFMB.js} +2 -2
  11. package/dist/chunks/chunk-6I23C2YJ.js +2 -0
  12. package/dist/chunks/{chunk-6MLDKHTY.js → chunk-CTZUYKVL.js} +2 -2
  13. package/dist/chunks/{chunk-GOYTZ5RB.js → chunk-EC77KAAM.js} +2 -2
  14. package/dist/chunks/{chunk-VZSQAGL2.js → chunk-FLFNMSHI.js} +2 -2
  15. package/dist/chunks/{chunk-XEJX5HBJ.js → chunk-GEHMND3C.js} +2 -2
  16. package/dist/chunks/{chunk-KY53MB3J.js → chunk-GIK34P23.js} +2 -2
  17. package/dist/chunks/chunk-H6Z7JVSD.js +2 -0
  18. package/dist/chunks/{chunk-YMI33F7W.js → chunk-HG4LJBNV.js} +2 -2
  19. package/dist/chunks/chunk-HGAEVPVS.js +2 -0
  20. package/dist/chunks/{chunk-EIUK6TKF.js → chunk-HMLYEFQN.js} +2 -2
  21. package/dist/chunks/chunk-HRRCC2BD.js +2 -0
  22. package/dist/chunks/chunk-IBHMM2SL.js +2 -0
  23. package/dist/chunks/chunk-ICDW3I2F.js +2 -0
  24. package/dist/chunks/chunk-IKMW63BE.js +2 -0
  25. package/dist/chunks/{chunk-O4D43LWM.js → chunk-IOJVFYHW.js} +2 -2
  26. package/dist/chunks/chunk-IW4S634O.js +2 -0
  27. package/dist/chunks/{chunk-GIIURG5X.js → chunk-JF4PXFJE.js} +2 -2
  28. package/dist/chunks/chunk-JPWYGTUN.js +2 -0
  29. package/dist/chunks/{chunk-I2KJMF4G.js → chunk-KJMLQHCY.js} +1 -1
  30. package/dist/chunks/chunk-KVJBCT3D.js +2 -0
  31. package/dist/chunks/chunk-LCIX76FR.js +2 -0
  32. package/dist/chunks/chunk-LY5XGFPU.js +2 -0
  33. package/dist/chunks/{chunk-NCDPZSI2.js → chunk-MKZH65DK.js} +2 -2
  34. package/dist/chunks/{chunk-GTSK4IN4.js → chunk-MVPHISOV.js} +1 -1
  35. package/dist/chunks/chunk-MXZ64QME.js +2 -0
  36. package/dist/chunks/{chunk-NCRL33PQ.js → chunk-N7BUE54L.js} +2 -2
  37. package/dist/chunks/{chunk-L77QFL3C.js → chunk-NDZVVNBB.js} +2 -2
  38. package/dist/chunks/{chunk-EB45CDFA.js → chunk-NOTJ45G3.js} +2 -2
  39. package/dist/chunks/{chunk-ZRKXHVTJ.js → chunk-QUD3374N.js} +2 -2
  40. package/dist/chunks/{chunk-XR7Y4ZV6.js → chunk-RXYZQ3UX.js} +2 -2
  41. package/dist/chunks/{chunk-V54MBEJM.js → chunk-SCFFHEDZ.js} +2 -2
  42. package/dist/chunks/{chunk-RNGDVSTS.js → chunk-V6FMGGUV.js} +2 -2
  43. package/dist/chunks/{chunk-TTOJDLIQ.js → chunk-VATAUY7N.js} +2 -2
  44. package/dist/chunks/chunk-W5M3R4NH.js +2 -0
  45. package/dist/chunks/{chunk-DD2GG4EC.js → chunk-WYVUCQO3.js} +1 -1
  46. package/dist/chunks/{chunk-JHABMYNH.js → chunk-XQCHC3SH.js} +1 -1
  47. package/dist/chunks/chunk-XUMVTGMM.js +2 -0
  48. package/dist/chunks/{chunk-72I7GDWL.js → chunk-YXMHWS5R.js} +2 -2
  49. package/dist/chunks/{chunk-LKKUUREA.js → chunk-Z33Q545U.js} +2 -2
  50. package/dist/descriptive/qcc.d.ts +320 -0
  51. package/dist/descriptive/qcc.js +524 -0
  52. package/dist/descriptive/qccTools.d.ts +301 -0
  53. package/dist/descriptive/qccTools.js +390 -0
  54. package/dist/descriptive.js +2 -2
  55. package/dist/distributions.js +2 -2
  56. package/dist/entries/descriptive.d.ts +2 -0
  57. package/dist/entries/descriptive.js +2 -0
  58. package/dist/entries/regression.d.ts +1 -0
  59. package/dist/entries/regression.js +2 -0
  60. package/dist/linalg.js +2 -2
  61. package/dist/mixed.js +2 -2
  62. package/dist/models/betareg.js +14 -2
  63. package/dist/models/bradleyterry.d.ts +188 -0
  64. package/dist/models/bradleyterry.js +533 -0
  65. package/dist/models/survreg.d.ts +5 -0
  66. package/dist/models/survreg.js +23 -3
  67. package/dist/models/tobit.js +16 -5
  68. package/dist/multivariate.js +2 -2
  69. package/dist/numerics.js +2 -2
  70. package/dist/regression.js +3 -3
  71. package/dist/rstats.js +17 -17
  72. package/dist/special.js +2 -2
  73. package/dist/tests.js +2 -2
  74. package/dist/timeseries.js +2 -2
  75. package/package.json +1 -1
  76. package/dist/chunks/chunk-23QCIPET.js +0 -2
  77. package/dist/chunks/chunk-3UEYA6VG.js +0 -2
  78. package/dist/chunks/chunk-3Y4DNK4O.js +0 -2
  79. package/dist/chunks/chunk-4BGGWQWS.js +0 -2
  80. package/dist/chunks/chunk-5UFVACSV.js +0 -2
  81. package/dist/chunks/chunk-5W2OZAHQ.js +0 -2
  82. package/dist/chunks/chunk-BWDXJL7T.js +0 -2
  83. package/dist/chunks/chunk-GLABB425.js +0 -2
  84. package/dist/chunks/chunk-JV3POOET.js +0 -2
  85. package/dist/chunks/chunk-K3YSXDTU.js +0 -2
  86. package/dist/chunks/chunk-LY2UZGUL.js +0 -2
  87. package/dist/chunks/chunk-PSQ6MLJM.js +0 -2
  88. package/dist/chunks/chunk-RM5D7Q7W.js +0 -2
  89. package/dist/chunks/chunk-SA2E5GVO.js +0 -2
  90. package/dist/chunks/chunk-T5ZALLTJ.js +0 -2
  91. package/dist/chunks/chunk-XPYZOG5H.js +0 -2
@@ -0,0 +1,320 @@
1
+ /**
2
+ * The type of a Shewhart chart (qcc's `type`): group means `"xbar"`, ranges `"R"`, standard deviations `"S"`,
3
+ * individual values `"xbar.one"`, proportion `"p"` and number `"np"` of nonconforming units, nonconformities `"c"` and
4
+ * nonconformities per unit `"u"`, and the number of non-events between events `"g"`.
5
+ * @category Descriptive statistics
6
+ */
7
+ export type QccType = "xbar" | "R" | "S" | "xbar.one" | "p" | "np" | "c" | "u" | "g";
8
+ /**
9
+ * A method of estimating the process standard deviation (qcc's `std.dev`): from the group ranges `"UWAVE-R"`,
10
+ * `"MVLUE-R"`, from the group standard deviations `"UWAVE-SD"`, `"MVLUE-SD"`, `"RMSDF"` (grouped data), from the moving
11
+ * ranges `"MR"` or the standard deviation `"SD"` (individual values).
12
+ * @category Descriptive statistics
13
+ */
14
+ export type QccStdDevMethod = "UWAVE-R" | "UWAVE-SD" | "MVLUE-R" | "MVLUE-SD" | "RMSDF" | "MR" | "SD";
15
+ /**
16
+ * Data of a control chart: one value per group (a vector), or one row per group (a matrix as an array of rows; `null`
17
+ * or `NaN` for a missing value, so that the groups may differ in size).
18
+ * @category Descriptive statistics
19
+ */
20
+ export type QccData = readonly (number | null)[] | readonly (readonly (number | null)[])[];
21
+ /**
22
+ * Options for {@link qcc}.
23
+ * @category Descriptive statistics
24
+ */
25
+ export interface QccOptions {
26
+ /** The chart (required). */
27
+ type: QccType;
28
+ /**
29
+ * The group sizes: one number for all groups or one per group. Required for `"p"`, `"np"` and `"u"`; for a matrix
30
+ * the sizes are the numbers of non-missing values of the rows.
31
+ */
32
+ sizes?: number | readonly number[];
33
+ /** The center (target) of the statistic; estimated from the data when not given. */
34
+ center?: number;
35
+ /**
36
+ * The process standard deviation, or the method that estimates it. Defaults: `"UWAVE-R"` for xbar (`"RMSDF"` when a
37
+ * group is larger than 25, as qcc) and R, `"UWAVE-SD"` for S, `"MR"` for xbar.one.
38
+ */
39
+ stdDev?: number | QccStdDevMethod;
40
+ /** Control limits `[LCL, UCL]` to use instead of computing them. */
41
+ limits?: readonly [number, number];
42
+ /** Further groups charted with the center, standard deviation and limits of `data` (qcc's `newdata`). */
43
+ newdata?: QccData;
44
+ /** The sizes of the groups of `newdata` (default: as `sizes` when that is one number). */
45
+ newsizes?: number | readonly number[];
46
+ /** Labels of the groups (and of the groups of `newdata`, `newlabels`). */
47
+ labels?: readonly string[];
48
+ /** Labels of the groups of `newdata`. */
49
+ newlabels?: readonly string[];
50
+ /** The number of standard deviations of the limits (default 3); ignored when `confidenceLevel` is given. */
51
+ nsigmas?: number;
52
+ /** A probability in (0, 1): probability limits at this level instead of `nsigmas`. */
53
+ confidenceLevel?: number;
54
+ /** The length of a run on one side of the center that signals (default 7, qcc's `run.length` option). */
55
+ runLength?: number;
56
+ /** The number of points of the moving ranges for xbar.one with `"MR"` (default 2, qcc's `k`). */
57
+ k?: number;
58
+ }
59
+ /**
60
+ * The points out of control (qcc's `violations`): 1-based indices over the groups of `data` followed by those of
61
+ * `newdata`.
62
+ * @category Descriptive statistics
63
+ */
64
+ export interface QccViolations {
65
+ /** The points above the upper limit, in order, then those below the lower limit (as qcc). */
66
+ beyondLimits: number[];
67
+ /** The points that are the `runLength`-th or a later point of a run strictly on one side of the center. */
68
+ violatingRuns: number[];
69
+ }
70
+ /**
71
+ * Result of {@link qcc}.
72
+ * @category Descriptive statistics
73
+ */
74
+ export interface QccResult {
75
+ /** The chart. */
76
+ type: QccType;
77
+ /** The charted statistic of each group of `data`. */
78
+ statistics: number[];
79
+ /** The group sizes. */
80
+ sizes: number[];
81
+ /** The center: one number, or one per group for an np chart with unequal sizes. */
82
+ center: number | number[];
83
+ /** The process standard deviation (one per group for an np chart with unequal sizes). */
84
+ stdDev: number | number[];
85
+ /** The method that estimated `stdDev`, or `null` when it was given or follows from the center. */
86
+ stdDevMethod: QccStdDevMethod | null;
87
+ /**
88
+ * The control limits: one pair when all groups (of `data` and `newdata`) have the same size, else one pair per group
89
+ * of `data` followed by those of `newdata`.
90
+ */
91
+ limits: {
92
+ /** The lower control limits. */
93
+ lcl: number[];
94
+ /** The upper control limits. */
95
+ ucl: number[];
96
+ };
97
+ /** `nsigmas`, or `null` for probability limits. */
98
+ nsigmas: number | null;
99
+ /** The level of probability limits, or `null`. */
100
+ confidenceLevel: number | null;
101
+ /** The statistic of each group of `newdata` (empty without newdata). */
102
+ newstatistics: number[];
103
+ /** The sizes of the groups of `newdata`. */
104
+ newsizes: number[];
105
+ /** Labels of the groups (and of newdata), or `null`. */
106
+ labels: string[] | null;
107
+ /** The points out of control. */
108
+ violations: QccViolations;
109
+ /** The data of the chart, as groups (one value per group for vector data); used by {@link processCapability}. */
110
+ data: number[][];
111
+ /** The run length used for `violations`. */
112
+ runLength: number;
113
+ /** R's warnings. */
114
+ warnings: string[];
115
+ }
116
+ /** d2(n), NaN outside the table (n above 25, as qcc) */
117
+ export declare function d2(n: number): number;
118
+ /** d3(n), NaN outside the table (n above 50) */
119
+ export declare function d3(n: number): number;
120
+ /** c4(n) = sqrt(2 / (n - 1)) Gamma(n / 2) / Gamma((n - 1) / 2) */
121
+ export declare function c4(n: number): number;
122
+ /**
123
+ * The points out of control of charted statistics: those beyond the limits and those in long runs on one side of the
124
+ * center. The limits are one pair for all points or one per point. An NA statistic is left out of both lists (qcc puts
125
+ * NA into them) and ends a run.
126
+ *
127
+ * Equivalent to `qcc::shewhart.rules()` in R.
128
+ * @category Descriptive statistics
129
+ */
130
+ export declare function shewhartRules(statistics: readonly number[], center: number | readonly number[], limits: {
131
+ lcl: readonly number[];
132
+ ucl: readonly number[];
133
+ }, options?: {
134
+ runLength?: number;
135
+ }): QccViolations;
136
+ /**
137
+ * A Shewhart control chart without the plot: the charted statistics, the center, the process standard deviation, the
138
+ * control limits and the points out of control. The charts:
139
+ *
140
+ * - xbar, R, S: data one row per group; sigma by UWAVE-R (default), MVLUE-R, UWAVE-SD, MVLUE-SD or RMSDF, the
141
+ * centers weighted by the group sizes; R limits `center +- k d3(n) sigma`, S limits `center +- k sigma
142
+ * sqrt(1 - c4(n)^2)`; probability limits from the range distribution (qtukey) and from chi-square.
143
+ * - xbar.one: individual values, sigma from moving ranges (MR) or the standard deviation (SD).
144
+ * - p, np, c, u, g: counts; limits from the binomial, Poisson and geometric models.
145
+ *
146
+ * As qcc: a group of size 1 is an error when sigma is estimated; groups larger than 25 switch the default of the xbar
147
+ * chart to RMSDF and give NA limits for the R chart (no d2 / d3 there); unequal sizes are an error for the c chart.
148
+ * Unlike qcc, NA statistics are left out of the violation indices.
149
+ *
150
+ * Equivalent to `qcc::qcc()` in R.
151
+ *
152
+ * @param data one value per group, or one row per group
153
+ * @param options the chart `type` and the options of qcc
154
+ * @category Descriptive statistics
155
+ */
156
+ export declare function qcc(data: QccData, options: QccOptions): QccResult;
157
+ /**
158
+ * Options for {@link cusum}.
159
+ * @category Descriptive statistics
160
+ */
161
+ export interface CusumOptions {
162
+ /** The group sizes (individual values: 1). */
163
+ sizes?: number | readonly number[];
164
+ /** The target (default: the center of the xbar or xbar.one chart of the data). */
165
+ center?: number;
166
+ /** The process standard deviation or the method that estimates it (as {@link qcc}). */
167
+ stdDev?: number | QccStdDevMethod;
168
+ /** The initial cumulative sums, in standard errors (default 0; must be in [0, decisionInterval)). */
169
+ headStart?: number;
170
+ /** The number of standard errors at which a cumulative sum signals (default 5). */
171
+ decisionInterval?: number;
172
+ /** The shift to detect, in standard errors (default 1); the reference value is half of it. */
173
+ seShift?: number;
174
+ /** Further groups whose sums continue those of `data`. */
175
+ newdata?: QccData;
176
+ /** The sizes of the groups of `newdata`. */
177
+ newsizes?: number | readonly number[];
178
+ }
179
+ /**
180
+ * Result of {@link cusum}.
181
+ * @category Descriptive statistics
182
+ */
183
+ export interface CusumResult {
184
+ /** The group means (or values) of data. */
185
+ statistics: number[];
186
+ /** The group means (or values) of newdata. */
187
+ newstatistics: number[];
188
+ /** The sizes of data and newdata. */
189
+ sizes: number[];
190
+ /** The target. */
191
+ center: number;
192
+ /** The process standard deviation. */
193
+ stdDev: number;
194
+ /** The upper cumulative sums C+. */
195
+ pos: number[];
196
+ /** The lower cumulative sums as non-positive values (-C-, as qcc). */
197
+ neg: number[];
198
+ /** The initial cumulative sums, in standard errors. */
199
+ headStart: number;
200
+ /** The decision interval, in standard errors. */
201
+ decisionInterval: number;
202
+ /** The shift to detect, in standard errors. */
203
+ seShift: number;
204
+ /** Indices (1-based) where -neg or pos exceeds the decision interval. */
205
+ violations: {
206
+ /** Where -neg exceeds it (a decrease). */
207
+ lower: number[];
208
+ /** Where pos exceeds it (an increase). */
209
+ upper: number[];
210
+ };
211
+ /** R's warnings. */
212
+ warnings: string[];
213
+ }
214
+ /**
215
+ * A cusum chart: the tabular cumulative sums of the standardized group means or individual values above and below the
216
+ * target. The reference value is `seShift / 2`; a sum beyond the decision interval signals.
217
+ *
218
+ * Equivalent to `qcc::cusum()` in R.
219
+ *
220
+ * @param data one row per group, or individual values
221
+ * @category Descriptive statistics
222
+ */
223
+ export declare function cusum(data: QccData, options?: CusumOptions): CusumResult;
224
+ /**
225
+ * Options for {@link ewma}.
226
+ * @category Descriptive statistics
227
+ */
228
+ export interface EwmaOptions {
229
+ /** The group sizes (individual values: 1). */
230
+ sizes?: number | readonly number[];
231
+ /** The target and starting value (default: the center of the xbar or xbar.one chart of the data). */
232
+ center?: number;
233
+ /** The process standard deviation or the method that estimates it (as {@link qcc}). */
234
+ stdDev?: number | QccStdDevMethod;
235
+ /** The smoothing parameter in [0, 1] (default 0.2). */
236
+ lambda?: number;
237
+ /** The number of standard deviations of the limits (default 3). */
238
+ nsigmas?: number;
239
+ /** Further groups smoothed on from `data`. */
240
+ newdata?: QccData;
241
+ /** The sizes of the groups of `newdata`. */
242
+ newsizes?: number | readonly number[];
243
+ }
244
+ /**
245
+ * Result of {@link ewma}.
246
+ * @category Descriptive statistics
247
+ */
248
+ export interface EwmaResult {
249
+ /** The group means (or values) of data. */
250
+ statistics: number[];
251
+ /** The group means (or values) of newdata. */
252
+ newstatistics: number[];
253
+ /** The sizes of data and newdata. */
254
+ sizes: number[];
255
+ /** The target and starting value. */
256
+ center: number;
257
+ /** The process standard deviation. */
258
+ stdDev: number;
259
+ /** The smoothed values. */
260
+ y: number[];
261
+ /** The standard deviation of each smoothed value (qcc's closed form with each point's own size). */
262
+ sigma: number[];
263
+ /** The smoothing parameter. */
264
+ lambda: number;
265
+ /** The number of standard deviations of the limits. */
266
+ nsigmas: number;
267
+ /** The limits of each point. */
268
+ limits: {
269
+ /** The lower control limits of each point. */
270
+ lcl: number[];
271
+ /** The upper control limits of each point. */
272
+ ucl: number[];
273
+ };
274
+ /** Indices (1-based) of the points outside their limits. */
275
+ violations: number[];
276
+ /** R's warnings. */
277
+ warnings: string[];
278
+ }
279
+ /**
280
+ * An EWMA chart: the exponentially weighted moving average of the group means or individual values, started at the
281
+ * center. The limits are `center +- nsigmas sigma_i` with `sigma_i = sd / sqrt(n_i) sqrt(lambda / (2 - lambda)
282
+ * (1 - (1 - lambda)^(2 i)))`, qcc's form, with each point's own size also when the sizes differ.
283
+ *
284
+ * Equivalent to `qcc::ewma()` in R.
285
+ *
286
+ * @param data one row per group, or individual values
287
+ * @category Descriptive statistics
288
+ */
289
+ export declare function ewma(data: QccData, options?: EwmaOptions): EwmaResult;
290
+ /**
291
+ * Options for {@link ewmaSmooth}.
292
+ * @category Descriptive statistics
293
+ */
294
+ export interface EwmaSmoothOptions {
295
+ /** The smoothing parameter (default 0.2). */
296
+ lambda?: number;
297
+ /** The starting value (default: the first y in the order of x). */
298
+ start?: number;
299
+ }
300
+ /**
301
+ * Result of {@link ewmaSmooth}.
302
+ * @category Descriptive statistics
303
+ */
304
+ export interface EwmaSmoothResult {
305
+ /** x sorted. */
306
+ x: number[];
307
+ /** The smoothed y in the order of x. */
308
+ y: number[];
309
+ /** The smoothing parameter. */
310
+ lambda: number;
311
+ /** The starting value. */
312
+ start: number;
313
+ }
314
+ /**
315
+ * EWMA smoothing of y in the order of x. It computes `z_t = lambda y_t + (1 - lambda) z_{t-1}` from `z_0 = start`.
316
+ *
317
+ * Equivalent to `qcc::ewmaSmooth()` in R.
318
+ * @category Descriptive statistics
319
+ */
320
+ export declare function ewmaSmooth(x: readonly number[], y: readonly number[], options?: EwmaSmoothOptions): EwmaSmoothResult;