@numero-uno-jpn/rstats 1.6.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.
- package/CHANGELOG.md +33 -0
- package/README.ja.md +11 -9
- package/README.md +12 -9
- package/dist/chunks/{chunk-O5CMNUJL.js → chunk-2X6PE6JF.js} +2 -2
- package/dist/chunks/{chunk-KAAUNR3G.js → chunk-2ZQ2TSZS.js} +1 -1
- package/dist/chunks/{chunk-F7G74UNI.js → chunk-3DO726WZ.js} +2 -2
- package/dist/chunks/{chunk-WAMHZ47G.js → chunk-45HUI3M4.js} +2 -2
- package/dist/chunks/{chunk-ABSUQPOG.js → chunk-52RWDNO6.js} +2 -2
- package/dist/chunks/chunk-53OM63EU.js +2 -0
- package/dist/chunks/{chunk-2I7Z7L5J.js → chunk-73IRLCTF.js} +2 -2
- package/dist/chunks/chunk-7ODUCEGX.js +2 -0
- package/dist/chunks/{chunk-55XSRONZ.js → chunk-ANZUXEMH.js} +2 -2
- package/dist/chunks/chunk-BHQGMZTI.js +2 -0
- package/dist/chunks/{chunk-3PCHPKBD.js → chunk-D3LKPD4H.js} +2 -2
- package/dist/chunks/chunk-DG2RTNIR.js +2 -0
- package/dist/chunks/{chunk-Z2XN4NN7.js → chunk-GRTQ7FYQ.js} +2 -2
- package/dist/chunks/chunk-HXYH5ZMB.js +2 -0
- package/dist/chunks/{chunk-NVIJXWS6.js → chunk-HYJ4MIZE.js} +2 -2
- package/dist/chunks/{chunk-ZL7EAPO5.js → chunk-IJST2ZGT.js} +1 -1
- package/dist/chunks/{chunk-2TVHT4PF.js → chunk-JIAFWEED.js} +2 -2
- package/dist/chunks/{chunk-7ZNFRZO4.js → chunk-JXJDCQYE.js} +2 -2
- package/dist/chunks/{chunk-FLITCXLY.js → chunk-LZB43TUL.js} +2 -2
- package/dist/chunks/chunk-MLNWWGGE.js +2 -0
- package/dist/chunks/{chunk-OZLDZOOA.js → chunk-QQHF5T2A.js} +1 -1
- package/dist/chunks/chunk-RWZ6ICYN.js +2 -0
- package/dist/chunks/{chunk-RSTU6CX7.js → chunk-TQM6KGKT.js} +2 -2
- package/dist/chunks/chunk-TUL6UFLQ.js +2 -0
- package/dist/chunks/{chunk-BMEO5X5F.js → chunk-TYMC2D5I.js} +2 -2
- package/dist/chunks/chunk-V7ECXPWY.js +2 -0
- package/dist/chunks/chunk-VB6PVRSN.js +2 -0
- package/dist/chunks/chunk-Y4KNH43T.js +2 -0
- package/dist/chunks/{chunk-AHFMBHZW.js → chunk-YD4U3QZ3.js} +1 -1
- package/dist/chunks/{chunk-SFZF44G6.js → chunk-YT62DNDS.js} +2 -2
- package/dist/descriptive.js +2 -2
- package/dist/distributions.js +2 -2
- package/dist/entries/regression.d.ts +7 -0
- package/dist/entries/regression.js +12 -0
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +2 -2
- package/dist/models/gee.d.ts +280 -0
- package/dist/models/gee.js +704 -0
- package/dist/models/glmnet.d.ts +259 -0
- package/dist/models/glmnet.js +1112 -0
- package/dist/models/modelMatrix.d.ts +2 -0
- package/dist/models/nls.d.ts +286 -0
- package/dist/models/nls.js +1007 -0
- package/dist/models/nlsFormula.d.ts +37 -0
- package/dist/models/nlsFormula.js +295 -0
- package/dist/models/polr.d.ts +341 -0
- package/dist/models/polr.js +1028 -0
- package/dist/models/rlm.d.ts +282 -0
- package/dist/models/rlm.js +766 -0
- package/dist/models/rq.d.ts +203 -0
- package/dist/models/rq.js +1089 -0
- package/dist/numerics.js +2 -2
- package/dist/regression.js +3 -0
- package/dist/rstats.js +1 -1
- package/dist/special.js +2 -2
- package/dist/tests.js +15 -15
- package/llms.txt +8 -1
- package/package.json +6 -1
- package/dist/chunks/chunk-5AITXV3T.js +0 -2
- package/dist/chunks/chunk-BJTGQ52J.js +0 -2
- package/dist/chunks/chunk-KND2BFD5.js +0 -2
- package/dist/chunks/chunk-N2PNW4HR.js +0 -2
- package/dist/chunks/chunk-TPBVVP32.js +0 -2
- package/dist/chunks/chunk-XNWSQVXS.js +0 -2
|
@@ -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;
|