@numero-uno-jpn/rstats 1.7.0 → 1.8.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 (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.ja.md +3 -3
  3. package/README.md +3 -3
  4. package/dist/chunks/{chunk-76FLTZVF.js → chunk-2X6PE6JF.js} +2 -2
  5. package/dist/chunks/{chunk-YKNRDPIB.js → chunk-2ZQ2TSZS.js} +1 -1
  6. package/dist/chunks/{chunk-PCTRVBEJ.js → chunk-3DO726WZ.js} +2 -2
  7. package/dist/chunks/{chunk-THSV22QF.js → chunk-45HUI3M4.js} +2 -2
  8. package/dist/chunks/{chunk-QWDK3ZC2.js → chunk-52RWDNO6.js} +2 -2
  9. package/dist/chunks/{chunk-VQOU7U7R.js → chunk-53OM63EU.js} +2 -2
  10. package/dist/chunks/{chunk-MOJ2KIQE.js → chunk-73IRLCTF.js} +2 -2
  11. package/dist/chunks/{chunk-J7ZVV4DN.js → chunk-7ODUCEGX.js} +2 -2
  12. package/dist/chunks/chunk-ANZUXEMH.js +3 -0
  13. package/dist/chunks/chunk-BHQGMZTI.js +2 -0
  14. package/dist/chunks/{chunk-RIP2RKAW.js → chunk-D3LKPD4H.js} +2 -2
  15. package/dist/chunks/{chunk-FQRNZEH2.js → chunk-DG2RTNIR.js} +2 -2
  16. package/dist/chunks/{chunk-SDT3YHAG.js → chunk-GRTQ7FYQ.js} +2 -2
  17. package/dist/chunks/{chunk-R5BMFVIH.js → chunk-HXYH5ZMB.js} +2 -2
  18. package/dist/chunks/chunk-HYJ4MIZE.js +2 -0
  19. package/dist/chunks/{chunk-CUT3IHMY.js → chunk-IJST2ZGT.js} +1 -1
  20. package/dist/chunks/{chunk-B7XZMIQO.js → chunk-JIAFWEED.js} +2 -2
  21. package/dist/chunks/{chunk-TY3IFCLI.js → chunk-JXJDCQYE.js} +2 -2
  22. package/dist/chunks/{chunk-CZUOG2U5.js → chunk-LZB43TUL.js} +2 -2
  23. package/dist/chunks/{chunk-RX6MZO2Y.js → chunk-MLNWWGGE.js} +2 -2
  24. package/dist/chunks/{chunk-HSJ4OT3H.js → chunk-QQHF5T2A.js} +1 -1
  25. package/dist/chunks/{chunk-PLQQ4VFN.js → chunk-RWZ6ICYN.js} +2 -2
  26. package/dist/chunks/{chunk-JXEXOD7K.js → chunk-TQM6KGKT.js} +2 -2
  27. package/dist/chunks/{chunk-CB7STL5Z.js → chunk-TUL6UFLQ.js} +2 -2
  28. package/dist/chunks/{chunk-HORF36FD.js → chunk-TYMC2D5I.js} +2 -2
  29. package/dist/chunks/{chunk-BJMPSDJ7.js → chunk-V7ECXPWY.js} +2 -2
  30. package/dist/chunks/{chunk-AIEPW6DX.js → chunk-VB6PVRSN.js} +2 -2
  31. package/dist/chunks/{chunk-YVJ4LDDE.js → chunk-Y4KNH43T.js} +2 -2
  32. package/dist/chunks/{chunk-VALULDEX.js → chunk-YD4U3QZ3.js} +1 -1
  33. package/dist/chunks/{chunk-V2Y2W7LE.js → chunk-YT62DNDS.js} +2 -2
  34. package/dist/descriptive.js +2 -2
  35. package/dist/distributions.js +2 -2
  36. package/dist/entries/regression.d.ts +4 -0
  37. package/dist/entries/regression.js +6 -0
  38. package/dist/linalg.js +2 -2
  39. package/dist/mixed.js +2 -2
  40. package/dist/models/gee.d.ts +280 -0
  41. package/dist/models/gee.js +704 -0
  42. package/dist/models/glmnet.d.ts +259 -0
  43. package/dist/models/glmnet.js +1112 -0
  44. package/dist/models/modelMatrix.d.ts +2 -0
  45. package/dist/models/rq.d.ts +203 -0
  46. package/dist/models/rq.js +1089 -0
  47. package/dist/numerics.js +2 -2
  48. package/dist/regression.js +3 -3
  49. package/dist/rstats.js +1 -1
  50. package/dist/special.js +2 -2
  51. package/dist/tests.js +15 -15
  52. package/llms.txt +3 -0
  53. package/package.json +1 -1
  54. package/dist/chunks/chunk-56AMJQ27.js +0 -2
  55. package/dist/chunks/chunk-B6KJ4RWG.js +0 -2
  56. package/dist/chunks/chunk-KSH43GX4.js +0 -2
  57. package/dist/chunks/chunk-LMRCFKVK.js +0 -2
  58. package/dist/chunks/chunk-R7F7ELS7.js +0 -3
@@ -0,0 +1,259 @@
1
+ /**
2
+ * Family used for the penalized generalized linear model.
3
+ * @category Regression
4
+ */
5
+ export type GlmnetFamily = "gaussian" | "binomial" | "poisson" | "multinomial";
6
+ /**
7
+ * Multinomial penalty structure.
8
+ * @category Regression
9
+ */
10
+ export type GlmnetMultiType = "ungrouped" | "grouped";
11
+ /**
12
+ * Scale or coefficient selection returned by a penalized-model prediction.
13
+ * @category Regression
14
+ */
15
+ export type GlmnetPredictType = "link" | "response" | "class" | "nonzero";
16
+ /**
17
+ * Options for {@link glmnet}.
18
+ * @category Regression
19
+ */
20
+ export interface GlmnetOptions {
21
+ /** Response distribution used for the penalized fit. */
22
+ family?: GlmnetFamily;
23
+ /** Penalty structure used for a multinomial fit. */
24
+ typeMultinomial?: GlmnetMultiType;
25
+ /** Elastic-net mixing parameter between ridge and lasso penalties. */
26
+ alpha?: number;
27
+ /** Decreasing penalty values defining the fitted regularization path. */
28
+ lambda?: readonly number[];
29
+ /** Requested number of penalty values in the automatic path. */
30
+ nlambda?: number;
31
+ /** Ratio of the final to initial penalty in the automatic path. */
32
+ lambdaMinRatio?: number;
33
+ /** Whether predictor columns are standardized before fitting. */
34
+ standardize?: boolean;
35
+ /** Whether an unpenalized intercept is included. */
36
+ intercept?: boolean;
37
+ /** Nonnegative prior observation weights. */
38
+ weights?: readonly number[];
39
+ /** Known contribution to the linear predictor. */
40
+ offset?: readonly number[];
41
+ /** Nonnegative coefficient-specific penalty multipliers. */
42
+ penaltyFactor?: readonly number[];
43
+ /** Lower bounds imposed on coefficient values. */
44
+ lowerLimits?: number | readonly number[];
45
+ /** Upper bounds imposed on coefficient values. */
46
+ upperLimits?: number | readonly number[];
47
+ /** Maximum number of active coefficients allowed in the path. */
48
+ dfmax?: number;
49
+ /** Maximum number of ever-active coefficients allowed in the path. */
50
+ pmax?: number;
51
+ /** Minimum fractional deviance improvement used for path stopping. */
52
+ fdev?: number;
53
+ /** Maximum fraction of null deviance explained before path stopping. */
54
+ devmax?: number;
55
+ /** Maximum number of optimization iterations per penalty value. */
56
+ maxit?: number;
57
+ /** Convergence tolerance for the penalized optimization. */
58
+ thresh?: number;
59
+ }
60
+ /**
61
+ * Result of a scalar-family {@link glmnet} fit.
62
+ * @category Regression
63
+ */
64
+ export interface GlmnetScalarResult {
65
+ /** Response distribution used for the penalized fit. */
66
+ family: "gaussian" | "binomial" | "poisson";
67
+ /** Elastic-net mixing parameter between ridge and lasso penalties. */
68
+ alpha: number;
69
+ /** Decreasing penalty values defining the fitted regularization path. */
70
+ lambda: number[];
71
+ /** Intercept estimates for each penalty value. */
72
+ a0: number[];
73
+ /** Predictor coefficient estimates for each penalty value. */
74
+ beta: number[][];
75
+ /** Number of nonzero predictor coefficients at each penalty value. */
76
+ df: number[];
77
+ /** Fraction of null deviance explained at each penalty value. */
78
+ devRatio: number[];
79
+ /** Null-model deviance for the fitted family. */
80
+ nullDev: number;
81
+ /** Total number of coordinate-descent passes. */
82
+ npasses: number;
83
+ /** Whether each penalty value met the convergence criterion. */
84
+ converged: boolean[];
85
+ /** Maximum Karush-Kuhn-Tucker residual at each penalty value. */
86
+ kktResidual: number[];
87
+ /** Design, response, and preprocessing information retained by the fit. */
88
+ model: {
89
+ /** Original predictor matrix used by the fit. */
90
+ x: number[][];
91
+ /** Response values used by the fit. */
92
+ y: number[];
93
+ /** Nonnegative prior observation weights. */
94
+ weights: number[];
95
+ /** Known contribution to the linear predictor. */
96
+ offset: number[];
97
+ /** Predictor means used for standardization. */
98
+ xMean: number[];
99
+ /** Predictor scales used for standardization. */
100
+ xScale: number[];
101
+ /** Whether an unpenalized intercept is included. */
102
+ intercept: boolean;
103
+ /** Number of predictor columns. */
104
+ columns: number;
105
+ };
106
+ }
107
+ /**
108
+ * Result of a multinomial {@link glmnet} fit.
109
+ * @category Regression
110
+ */
111
+ export interface GlmnetMultinomialResult {
112
+ /** Response distribution used for the penalized fit. */
113
+ family: "multinomial";
114
+ /** Elastic-net mixing parameter between ridge and lasso penalties. */
115
+ alpha: number;
116
+ /** Decreasing penalty values defining the fitted regularization path. */
117
+ lambda: number[];
118
+ /** Intercept estimates for each penalty value. */
119
+ a0: number[][];
120
+ /** Predictor coefficient estimates for each penalty value. */
121
+ beta: Record<string, number[][]>;
122
+ /** Class-specific degrees of freedom at each penalty value. */
123
+ dfmat: number[][];
124
+ /** Fraction of null deviance explained at each penalty value. */
125
+ devRatio: number[];
126
+ /** Null-model deviance for the fitted family. */
127
+ nullDev: number;
128
+ /** Total number of coordinate-descent passes. */
129
+ npasses: number;
130
+ /** Whether each penalty value met the convergence criterion. */
131
+ converged: boolean[];
132
+ /** Maximum Karush-Kuhn-Tucker residual at each penalty value. */
133
+ kktResidual: number[];
134
+ /** Design, response, and preprocessing information retained by the fit. */
135
+ model: {
136
+ /** Original predictor matrix used by the fit. */
137
+ x: number[][];
138
+ /** Response values used by the fit. */
139
+ y: string[];
140
+ /** Nonnegative prior observation weights. */
141
+ weights: number[];
142
+ /** Known contribution to the linear predictor. */
143
+ offset: number[];
144
+ /** Predictor means used for standardization. */
145
+ xMean: number[];
146
+ /** Predictor scales used for standardization. */
147
+ xScale: number[];
148
+ /** Whether an unpenalized intercept is included. */
149
+ intercept: boolean;
150
+ /** Number of predictor columns. */
151
+ columns: number;
152
+ /** Class labels represented by the multinomial response. */
153
+ classes: string[];
154
+ /** Penalty structure used for a multinomial fit. */
155
+ typeMultinomial: GlmnetMultiType;
156
+ };
157
+ }
158
+ /**
159
+ * Union of scalar-family and multinomial regularization paths.
160
+ * @category Regression
161
+ */
162
+ export type GlmnetResult = GlmnetScalarResult | GlmnetMultinomialResult;
163
+ /**
164
+ * Options for {@link glmnetPredict}.
165
+ * @category Regression
166
+ */
167
+ export interface GlmnetPredictOptions {
168
+ /** Penalty value or values at which coefficients or predictions are requested. */
169
+ s?: number | readonly number[];
170
+ /** Prediction scale or output representation. */
171
+ type?: GlmnetPredictType;
172
+ /** Known contribution to the linear predictor. */
173
+ offset?: readonly number[];
174
+ }
175
+ /**
176
+ * Options for {@link cvGlmnet}; fold assignments are required.
177
+ * @category Regression
178
+ */
179
+ export interface CvGlmnetOptions extends GlmnetOptions {
180
+ /** Fixed fold assignment for deterministic cross-validation. */
181
+ foldid: readonly number[];
182
+ /** Loss or performance measure evaluated on held-out folds. */
183
+ typeMeasure?: "deviance" | "mse" | "mae" | "class" | "auc";
184
+ /** Whether fold-level scores are summarized before the cross-validation mean and standard error. */
185
+ grouped?: boolean;
186
+ /** Whether held-out predictions are retained. */
187
+ keep?: boolean;
188
+ }
189
+ /**
190
+ * Cross-validation summary returned by {@link cvGlmnet}.
191
+ * @category Regression
192
+ */
193
+ export interface CvGlmnetResult {
194
+ /** Full-data penalized fit associated with cross-validation. */
195
+ fit: GlmnetResult;
196
+ /** Decreasing penalty values defining the fitted regularization path. */
197
+ lambda: number[];
198
+ /** Mean cross-validated loss at each penalty value. */
199
+ cvm: number[];
200
+ /** Estimated standard error of the cross-validated loss. */
201
+ cvsd: number[];
202
+ /** Upper one-standard-error bound for the cross-validated loss. */
203
+ cvup: number[];
204
+ /** Lower one-standard-error bound for the cross-validated loss. */
205
+ cvlo: number[];
206
+ /** Number of nonzero coefficients at each penalty value. */
207
+ nzero: number[];
208
+ /** Penalty value minimizing the mean cross-validated loss. */
209
+ lambdaMin: number;
210
+ /** Largest penalty within one standard error of the minimum loss. */
211
+ lambda1se: number;
212
+ /** Fixed fold assignment for deterministic cross-validation. */
213
+ foldid: number[];
214
+ /** Name of the cross-validation measure used. */
215
+ name?: string;
216
+ /** Warnings generated during cross-validation. */
217
+ warnings?: string[];
218
+ /** Held-out predictions retained when keep is enabled. */
219
+ fitPreval?: number[][] | number[][][];
220
+ }
221
+ /**
222
+ * Fit a penalized generalized linear model path. Equivalent to R's `glmnet::glmnet()`.
223
+ *
224
+ * @category Regression
225
+ */
226
+ export declare function glmnet(x: readonly (readonly number[])[], y: readonly number[], options?: GlmnetOptions & {
227
+ family?: "gaussian" | "binomial" | "poisson";
228
+ }): GlmnetScalarResult;
229
+ export declare function glmnet(x: readonly (readonly number[])[], y: readonly string[], options: GlmnetOptions & {
230
+ family: "binomial";
231
+ }): GlmnetScalarResult;
232
+ export declare function glmnet(x: readonly (readonly number[])[], y: readonly string[], options: GlmnetOptions & {
233
+ family: "multinomial";
234
+ }): GlmnetMultinomialResult;
235
+ /** Extract coefficients at selected penalty values. Equivalent to R's `coef.glmnet()`.
236
+ *
237
+ * @category Regression
238
+ */
239
+ export declare function glmnetCoef(fit: GlmnetScalarResult, s?: number | readonly number[]): number[][];
240
+ export declare function glmnetCoef(fit: GlmnetMultinomialResult, s?: number | readonly number[]): Record<string, number[][]>;
241
+ /** Predict from a penalized generalized linear model. Equivalent to R's `predict.glmnet()`.
242
+ *
243
+ * @category Regression
244
+ */
245
+ export declare function glmnetPredict(fit: GlmnetScalarResult, newx: readonly (readonly number[])[], options?: GlmnetPredictOptions): number[][];
246
+ export declare function glmnetPredict(fit: GlmnetMultinomialResult, newx: readonly (readonly number[])[], options: GlmnetPredictOptions & {
247
+ type: "class";
248
+ }): string[][];
249
+ export declare function glmnetPredict(fit: GlmnetMultinomialResult, newx: readonly (readonly number[])[], options?: GlmnetPredictOptions & {
250
+ type?: "link" | "response" | "nonzero";
251
+ }): number[][][];
252
+ /** Cross-validate a penalized generalized linear model. Equivalent to R's `cv.glmnet()`.
253
+ *
254
+ * @category Regression
255
+ */
256
+ export declare function cvGlmnet(x: readonly (readonly number[])[], y: readonly number[], options: CvGlmnetOptions): CvGlmnetResult;
257
+ export declare function cvGlmnet(x: readonly (readonly number[])[], y: readonly string[], options: CvGlmnetOptions & {
258
+ family: "binomial" | "multinomial";
259
+ }): CvGlmnetResult;