@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.
Files changed (67) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.ja.md +11 -9
  3. package/README.md +12 -9
  4. package/dist/chunks/{chunk-O5CMNUJL.js → chunk-2X6PE6JF.js} +2 -2
  5. package/dist/chunks/{chunk-KAAUNR3G.js → chunk-2ZQ2TSZS.js} +1 -1
  6. package/dist/chunks/{chunk-F7G74UNI.js → chunk-3DO726WZ.js} +2 -2
  7. package/dist/chunks/{chunk-WAMHZ47G.js → chunk-45HUI3M4.js} +2 -2
  8. package/dist/chunks/{chunk-ABSUQPOG.js → chunk-52RWDNO6.js} +2 -2
  9. package/dist/chunks/chunk-53OM63EU.js +2 -0
  10. package/dist/chunks/{chunk-2I7Z7L5J.js → chunk-73IRLCTF.js} +2 -2
  11. package/dist/chunks/chunk-7ODUCEGX.js +2 -0
  12. package/dist/chunks/{chunk-55XSRONZ.js → chunk-ANZUXEMH.js} +2 -2
  13. package/dist/chunks/chunk-BHQGMZTI.js +2 -0
  14. package/dist/chunks/{chunk-3PCHPKBD.js → chunk-D3LKPD4H.js} +2 -2
  15. package/dist/chunks/chunk-DG2RTNIR.js +2 -0
  16. package/dist/chunks/{chunk-Z2XN4NN7.js → chunk-GRTQ7FYQ.js} +2 -2
  17. package/dist/chunks/chunk-HXYH5ZMB.js +2 -0
  18. package/dist/chunks/{chunk-NVIJXWS6.js → chunk-HYJ4MIZE.js} +2 -2
  19. package/dist/chunks/{chunk-ZL7EAPO5.js → chunk-IJST2ZGT.js} +1 -1
  20. package/dist/chunks/{chunk-2TVHT4PF.js → chunk-JIAFWEED.js} +2 -2
  21. package/dist/chunks/{chunk-7ZNFRZO4.js → chunk-JXJDCQYE.js} +2 -2
  22. package/dist/chunks/{chunk-FLITCXLY.js → chunk-LZB43TUL.js} +2 -2
  23. package/dist/chunks/chunk-MLNWWGGE.js +2 -0
  24. package/dist/chunks/{chunk-OZLDZOOA.js → chunk-QQHF5T2A.js} +1 -1
  25. package/dist/chunks/chunk-RWZ6ICYN.js +2 -0
  26. package/dist/chunks/{chunk-RSTU6CX7.js → chunk-TQM6KGKT.js} +2 -2
  27. package/dist/chunks/chunk-TUL6UFLQ.js +2 -0
  28. package/dist/chunks/{chunk-BMEO5X5F.js → chunk-TYMC2D5I.js} +2 -2
  29. package/dist/chunks/chunk-V7ECXPWY.js +2 -0
  30. package/dist/chunks/chunk-VB6PVRSN.js +2 -0
  31. package/dist/chunks/chunk-Y4KNH43T.js +2 -0
  32. package/dist/chunks/{chunk-AHFMBHZW.js → chunk-YD4U3QZ3.js} +1 -1
  33. package/dist/chunks/{chunk-SFZF44G6.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 +7 -0
  37. package/dist/entries/regression.js +12 -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/nls.d.ts +286 -0
  46. package/dist/models/nls.js +1007 -0
  47. package/dist/models/nlsFormula.d.ts +37 -0
  48. package/dist/models/nlsFormula.js +295 -0
  49. package/dist/models/polr.d.ts +341 -0
  50. package/dist/models/polr.js +1028 -0
  51. package/dist/models/rlm.d.ts +282 -0
  52. package/dist/models/rlm.js +766 -0
  53. package/dist/models/rq.d.ts +203 -0
  54. package/dist/models/rq.js +1089 -0
  55. package/dist/numerics.js +2 -2
  56. package/dist/regression.js +3 -0
  57. package/dist/rstats.js +1 -1
  58. package/dist/special.js +2 -2
  59. package/dist/tests.js +15 -15
  60. package/llms.txt +8 -1
  61. package/package.json +6 -1
  62. package/dist/chunks/chunk-5AITXV3T.js +0 -2
  63. package/dist/chunks/chunk-BJTGQ52J.js +0 -2
  64. package/dist/chunks/chunk-KND2BFD5.js +0 -2
  65. package/dist/chunks/chunk-N2PNW4HR.js +0 -2
  66. package/dist/chunks/chunk-TPBVVP32.js +0 -2
  67. package/dist/chunks/chunk-XNWSQVXS.js +0 -2
@@ -0,0 +1,203 @@
1
+ import { type DesignContrast } from "./modelMatrix.js";
2
+ import type { DataFrame } from "./modelFrame.js";
3
+ import type { Sample } from "../htest/types.js";
4
+ /** Algorithm used to fit a quantile-regression model.
5
+ *
6
+ * @category Regression
7
+ */
8
+ export type RqMethod = "br" | "fn";
9
+ /** Options for {@link rq}.
10
+ *
11
+ * @category Regression
12
+ */
13
+ export interface RqOptions {
14
+ /** Quantile probability or probabilities to fit. */
15
+ tau?: number | Sample;
16
+ /** Quantile-regression optimization method. */
17
+ method?: RqMethod;
18
+ /** Nonnegative prior observation weights. */
19
+ weights?: Sample | string;
20
+ /** Contrast coding specifications for factor predictors. */
21
+ contrasts?: Record<string, DesignContrast>;
22
+ /** Explicit level order for factor predictors. */
23
+ levels?: Record<string, readonly string[]>;
24
+ /** Maximum number of optimization iterations. */
25
+ maxit?: number;
26
+ /** Convergence tolerance for the optimization. */
27
+ eps?: number;
28
+ }
29
+ /** Model data retained by a quantile-regression fit.
30
+ *
31
+ * @category Regression
32
+ */
33
+ export interface RqModel {
34
+ /** Model formula used to define the response and predictors. */
35
+ formula: string;
36
+ /** Numeric model matrix used by the fit. */
37
+ x: number[][];
38
+ /** Observed response values. */
39
+ y: number[];
40
+ /** Nonnegative prior observation weights. */
41
+ weights: number[];
42
+ /** Original data-row indices retained in the model frame. */
43
+ rows: number[];
44
+ /** Names of the columns in the model matrix. */
45
+ columnNames: string[];
46
+ /** Quantile probability or probabilities to fit. */
47
+ tau: number[];
48
+ /** Quantile-regression optimization method. */
49
+ method: RqMethod;
50
+ }
51
+ /** Result returned by {@link rq}.
52
+ *
53
+ * @category Regression
54
+ */
55
+ export interface RqResult {
56
+ /** Estimated regression coefficients. */
57
+ coefficients: Record<string, number | number[]>;
58
+ /** Fitted conditional means or quantiles for the input rows. */
59
+ fittedValues: number[] | number[][];
60
+ /** Response residuals for the input rows. */
61
+ residuals: number[] | number[][];
62
+ /** Quantile check-loss objective value. */
63
+ rho: number | number[];
64
+ /** Whether the numerical fitting procedure met its convergence criterion. */
65
+ converged: boolean;
66
+ /** Number of iterations used by the fitting procedure. */
67
+ iterations: number;
68
+ /** Warnings recorded while fitting or summarizing the model. */
69
+ warnings: string[];
70
+ /** Model-frame and design information retained for downstream methods. */
71
+ model: RqModel;
72
+ }
73
+ /**
74
+ * Fit a linear conditional quantile model. Equivalent to `quantreg::rq()` in R.
75
+ * Uses the formula/model-matrix interface of other regression models.
76
+ *
77
+ * @param formula A formula such as `y ~ x`.
78
+ * @param data A data frame of columns.
79
+ * @param options Quantile, algorithm, and prior weights.
80
+ * @example
81
+ * ```ts
82
+ * rq("y ~ x", { x: [1, 2, 3, 4], y: [2, 1, 4, 3] }, { tau: 0.5 });
83
+ * ```
84
+ * @category Regression
85
+ */
86
+ export declare function rq(formula: string, data: DataFrame, options?: RqOptions): RqResult;
87
+ /**
88
+ * Predict conditional quantiles for new observations. Equivalent to `quantreg::predict.rq()` in R.
89
+ *
90
+ * @category Regression
91
+ */
92
+ export declare function rqPredict(fit: RqResult, newdata: DataFrame): number[] | number[][];
93
+ /** Options for rqSummary.
94
+ * @category Regression
95
+ */
96
+ export interface RqSummaryOptions {
97
+ /** Standard-error or interval method used for the summary. */
98
+ se?: "nid" | "rank";
99
+ /** Estimated coefficient covariance matrix or matrices. */
100
+ covariance?: boolean;
101
+ /** Confidence level for reported intervals. */
102
+ level?: number;
103
+ /** The iid form of the rank test (R's `iid`). Only `true` (the default) is supported in 1.8.0. */
104
+ iid?: boolean;
105
+ }
106
+ /** A coefficient row in an rq summary.
107
+ * @category Regression
108
+ */
109
+ export interface RqCoefficientSummary {
110
+ /** Quantile probability or probabilities to fit. */
111
+ tau: number;
112
+ /** Model term represented by this coefficient row. */
113
+ term: string;
114
+ /** Estimated coefficient value. */
115
+ estimate: number;
116
+ /** NaN for `se = "rank"`, which gives an interval (`lower`, `upper`) instead. */
117
+ stdError: number;
118
+ /** Wald test statistic for the coefficient. */
119
+ statistic: number;
120
+ /** Two-sided p-value associated with the coefficient statistic. */
121
+ pValue: number;
122
+ /** The confidence limits of `se = "rank"` (R's `lower bd` and `upper bd`). */
123
+ lower?: number;
124
+ /** Upper confidence limit for the coefficient. */
125
+ upper?: number;
126
+ }
127
+ /** Result of rqSummary.
128
+ * @category Regression
129
+ */
130
+ export interface RqSummaryResult {
131
+ /** Estimated regression coefficients. */
132
+ coefficients: RqCoefficientSummary[];
133
+ /** Estimated coefficient covariance matrix or matrices. */
134
+ covariance?: number[][][];
135
+ /** Standard-error or interval method used for the summary. */
136
+ se: string;
137
+ /** Warnings recorded while fitting or summarizing the model. */
138
+ warnings: string[];
139
+ }
140
+ /** Options for confidence prediction intervals.
141
+ * @category Regression
142
+ */
143
+ export interface RqPredictOptions {
144
+ /** Whether prediction output includes confidence intervals. */
145
+ interval?: "none" | "confidence";
146
+ /** Prediction scale or confidence-interval construction method. */
147
+ type?: "none" | "direct" | "percentile";
148
+ /** Confidence level for reported intervals. */
149
+ level?: number;
150
+ }
151
+ /** Result of confidence prediction.
152
+ * @category Regression
153
+ */
154
+ export interface RqPredictResult {
155
+ /** Predicted conditional quantiles or fitted values. */
156
+ fit: number[] | number[][];
157
+ /** Lower confidence limit for the coefficient. */
158
+ lower?: number[] | number[][];
159
+ /** Upper confidence limit for the coefficient. */
160
+ upper?: number[] | number[][];
161
+ /** Confidence level for reported intervals. */
162
+ level: number;
163
+ /** Prediction scale or confidence-interval construction method. */
164
+ type: string;
165
+ }
166
+ /** Coefficient summary with Hall–Sheather bandwidth and the nid sandwich covariance. Equivalent to R's `summary.rq()`.
167
+ *
168
+ * @category Regression
169
+ */
170
+ export declare function rqSummary(fit: RqResult, options?: RqSummaryOptions): RqSummaryResult;
171
+ /** Confidence intervals for conditional quantile predictions using nid or direct quantile refits. Equivalent to R's `predict.rq()`.
172
+ *
173
+ * @category Regression
174
+ */
175
+ export declare function rqPredictInterval(fit: RqResult, newdata: DataFrame, options?: RqPredictOptions): RqPredictResult;
176
+ /** Wald test of equality of slopes across the quantiles in a multiple-tau fit. Equivalent to R's `anova.rq()`.
177
+ *
178
+ * @category Regression
179
+ */
180
+ /** Wald comparisons for nested models or slopes across multiple quantiles. Equivalent to R's `anova.rq()`.
181
+ *
182
+ * @category Regression
183
+ */
184
+ export declare function rqAnova(fit: RqResult): RqWaldResult;
185
+ export declare function rqAnova(fit: RqResult, joint: true): RqWaldResult;
186
+ export declare function rqAnova(fit: RqResult, joint: false): RqWaldResult[];
187
+ export declare function rqAnova(fit: RqResult, joint: boolean): RqWaldResult | RqWaldResult[];
188
+ export declare function rqAnova(fit: RqResult, reduced: RqResult): RqWaldResult;
189
+ /** Result of a quantile-regression Wald comparison.
190
+ * @category Regression
191
+ */
192
+ export interface RqWaldResult {
193
+ /** Joint Wald statistic for the tested slope restrictions across quantiles. */
194
+ statistic: number;
195
+ /** Numerator degrees of freedom for the Wald test. */
196
+ df: number;
197
+ /** Residual degrees of freedom used for the reference distribution. */
198
+ dfResidual: number;
199
+ /** P-value for the joint Wald comparison. */
200
+ pValue: number;
201
+ /** Wald comparison method used for the multi-quantile test. */
202
+ method: "Wald";
203
+ }