@numero-uno-jpn/rstats 1.19.0 → 1.20.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 +38 -0
- package/README.ja.md +6 -6
- package/README.md +6 -6
- package/dist/causal.js +2 -2
- package/dist/chunks/chunk-33ODAPMR.js +2 -0
- package/dist/chunks/chunk-3ST6RZXG.js +2 -0
- package/dist/chunks/{chunk-FAKOND5W.js → chunk-4EQN74JN.js} +2 -2
- package/dist/chunks/chunk-5RRFO4NU.js +2 -0
- package/dist/chunks/{chunk-ILQ4VWSD.js → chunk-64DDDGJU.js} +2 -2
- package/dist/chunks/chunk-66TEOHPF.js +2 -0
- package/dist/chunks/chunk-6ISDROPG.js +2 -0
- package/dist/chunks/{chunk-OTETSONJ.js → chunk-6LAKI2QG.js} +2 -2
- package/dist/chunks/{chunk-SJJJ7Y4X.js → chunk-6QCH4LAL.js} +2 -2
- package/dist/chunks/{chunk-FCGTZ6BD.js → chunk-6RA73LXX.js} +2 -2
- package/dist/chunks/{chunk-MPBFXHXT.js → chunk-7C2ECGT6.js} +1 -1
- package/dist/chunks/{chunk-QH4GK3JN.js → chunk-7KPFNJBE.js} +2 -2
- package/dist/chunks/chunk-ARPXG2PG.js +2 -0
- package/dist/chunks/chunk-AWXW4WSX.js +2 -0
- package/dist/chunks/{chunk-WWRKCRTZ.js → chunk-B5GSH3AK.js} +1 -1
- package/dist/chunks/{chunk-XHHDBEHB.js → chunk-BLDLJHUG.js} +2 -2
- package/dist/chunks/{chunk-ANFN3X2M.js → chunk-BU4I544S.js} +2 -2
- package/dist/chunks/{chunk-LWFKGF43.js → chunk-CAUNJ7S6.js} +2 -2
- package/dist/chunks/chunk-DFGW4QWU.js +2 -0
- package/dist/chunks/{chunk-MOYWWJP4.js → chunk-DPCCSFCG.js} +1 -1
- package/dist/chunks/chunk-EXS5QD7V.js +2 -0
- package/dist/chunks/chunk-FOCHNNP3.js +2 -0
- package/dist/chunks/{chunk-VNLSP22M.js → chunk-HEPGGURG.js} +2 -2
- package/dist/chunks/chunk-INNFAVT3.js +2 -0
- package/dist/chunks/chunk-JEELIABM.js +2 -0
- package/dist/chunks/chunk-KNF2GPJV.js +2 -0
- package/dist/chunks/chunk-L4ZS7MAX.js +2 -0
- package/dist/chunks/{chunk-7D7FBLWD.js → chunk-LZAB4M7P.js} +2 -2
- package/dist/chunks/chunk-LZTDYQRS.js +3 -0
- package/dist/chunks/{chunk-AS2XTRHH.js → chunk-MTSU2QHB.js} +2 -2
- package/dist/chunks/{chunk-5NW4WT4F.js → chunk-MXRN2G7O.js} +2 -2
- package/dist/chunks/chunk-OFDD4GTZ.js +2 -0
- package/dist/chunks/chunk-OOHFFLMY.js +2 -0
- package/dist/chunks/chunk-OOO5AAM7.js +2 -0
- package/dist/chunks/chunk-PJJJR3H6.js +2 -0
- package/dist/chunks/chunk-PVRNAOO7.js +2 -0
- package/dist/chunks/chunk-Q2JLU5YD.js +2 -0
- package/dist/chunks/{chunk-SAFH76DR.js → chunk-QCQBK5AC.js} +2 -2
- package/dist/chunks/chunk-RXK4KSKH.js +2 -0
- package/dist/chunks/chunk-UC3YYJHM.js +4 -0
- package/dist/chunks/chunk-UPACHZ4F.js +2 -0
- package/dist/chunks/{chunk-DXSVV47D.js → chunk-VCXPGCA4.js} +2 -2
- package/dist/chunks/chunk-VFL4GGYT.js +2 -0
- package/dist/chunks/chunk-VL72MQOQ.js +2 -0
- package/dist/chunks/chunk-VSV5QGXX.js +2 -0
- package/dist/chunks/{chunk-U6RXYALO.js → chunk-WMEF5XWO.js} +2 -2
- package/dist/chunks/chunk-X6JS6ZZB.js +2 -0
- package/dist/chunks/chunk-YEDVOX5V.js +2 -0
- package/dist/chunks/chunk-ZCTB4N5J.js +3 -0
- package/dist/descriptive.js +2 -2
- package/dist/distributions.js +2 -2
- package/dist/entries/tests.d.ts +5 -0
- package/dist/entries/tests.js +5 -0
- package/dist/entries/timeseries.d.ts +11 -0
- package/dist/entries/timeseries.js +11 -0
- package/dist/linalg.js +2 -2
- package/dist/meta/metabin.d.ts +32 -0
- package/dist/meta/metabin.js +137 -0
- package/dist/meta/metaextra.d.ts +153 -0
- package/dist/meta/metaextra.js +290 -0
- package/dist/meta/metagen.d.ts +124 -0
- package/dist/meta/metagen.js +263 -0
- package/dist/meta/metaother.d.ts +87 -0
- package/dist/meta/metaother.js +342 -0
- package/dist/meta/netmeta.d.ts +256 -0
- package/dist/meta/netmeta.js +547 -0
- package/dist/mixed.js +3 -4
- package/dist/models/glmFamily.js +4 -1
- package/dist/models/metaAnalysis.d.ts +4 -0
- package/dist/models/metaAnalysis.js +100 -18
- package/dist/multivariate.js +2 -2
- package/dist/numerics.js +2 -2
- package/dist/regression.js +2 -2
- package/dist/rstats.js +20 -18
- package/dist/special.js +2 -2
- package/dist/tests.js +15 -15
- package/dist/timeseries/acf.js +5 -2
- package/dist/timeseries/arima.d.ts +154 -0
- package/dist/timeseries/arima.js +1007 -0
- package/dist/timeseries/autoArima.d.ts +70 -0
- package/dist/timeseries/autoArima.js +191 -0
- package/dist/timeseries/ets.d.ts +158 -0
- package/dist/timeseries/ets.js +883 -0
- package/dist/timeseries/forecastArima.d.ts +136 -0
- package/dist/timeseries/forecastArima.js +432 -0
- package/dist/timeseries/forecastDispatch.d.ts +83 -0
- package/dist/timeseries/forecastDispatch.js +130 -0
- package/dist/timeseries/forecastSimple.d.ts +177 -0
- package/dist/timeseries/forecastSimple.js +371 -0
- package/dist/timeseries/forecastUtils.d.ts +260 -0
- package/dist/timeseries/forecastUtils.js +619 -0
- package/dist/timeseries/holtWinters.d.ts +65 -0
- package/dist/timeseries/holtWinters.js +193 -0
- package/dist/timeseries/input.d.ts +8 -0
- package/dist/timeseries/input.js +27 -0
- package/dist/timeseries/ocsbCritical.d.ts +2 -0
- package/dist/timeseries/ocsbCritical.js +6 -0
- package/dist/timeseries/scale.d.ts +16 -0
- package/dist/timeseries/scale.js +48 -0
- package/dist/timeseries/statsTs.d.ts +128 -0
- package/dist/timeseries/statsTs.js +456 -0
- package/dist/timeseries/stl.d.ts +131 -0
- package/dist/timeseries/stl.js +489 -0
- package/dist/timeseries/tseries.d.ts +110 -0
- package/dist/timeseries/tseries.js +369 -0
- package/dist/timeseries.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/chunk-2S45NNTL.js +0 -2
- package/dist/chunks/chunk-4JFGT4PN.js +0 -2
- package/dist/chunks/chunk-4JRJU5F5.js +0 -2
- package/dist/chunks/chunk-6ZGEYAFC.js +0 -2
- package/dist/chunks/chunk-BJ5WAL2C.js +0 -2
- package/dist/chunks/chunk-CEOSH3H2.js +0 -2
- package/dist/chunks/chunk-CMNKXRZF.js +0 -3
- package/dist/chunks/chunk-CNJLPH6W.js +0 -2
- package/dist/chunks/chunk-FELX2TZZ.js +0 -2
- package/dist/chunks/chunk-G4B2SQR6.js +0 -4
- package/dist/chunks/chunk-HPIZAWMT.js +0 -2
- package/dist/chunks/chunk-I5XUWUEV.js +0 -2
- package/dist/chunks/chunk-JLFRYDYO.js +0 -2
- package/dist/chunks/chunk-JXKHFSGK.js +0 -2
- package/dist/chunks/chunk-LBU73UMS.js +0 -2
- package/dist/chunks/chunk-LSZTDKIB.js +0 -2
- package/dist/chunks/chunk-M5J3DHXB.js +0 -2
- package/dist/chunks/chunk-NWNJEAKI.js +0 -2
- package/dist/chunks/chunk-QVE7V5UG.js +0 -2
- package/dist/chunks/chunk-RMGEIU4Z.js +0 -2
- package/dist/chunks/chunk-TVU4N6BA.js +0 -2
- package/dist/chunks/chunk-W4EITKLJ.js +0 -2
- package/dist/chunks/chunk-XJMBX6A2.js +0 -2
- package/dist/chunks/chunk-YZ6SBFFG.js +0 -2
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { type MstlResult } from "./stl.js";
|
|
2
|
+
import type { ArimaResult } from "./arima.js";
|
|
3
|
+
/**
|
|
4
|
+
* One row of {@link accuracy}.
|
|
5
|
+
*
|
|
6
|
+
* @category Time series
|
|
7
|
+
*/
|
|
8
|
+
export interface AccuracyRow {
|
|
9
|
+
ME: number;
|
|
10
|
+
RMSE: number;
|
|
11
|
+
MAE: number;
|
|
12
|
+
MPE: number;
|
|
13
|
+
MAPE: number;
|
|
14
|
+
MASE: number;
|
|
15
|
+
ACF1: number;
|
|
16
|
+
TheilU?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Accuracy measures (forecast's `accuracy()`): ME, RMSE, MAE, MPE, MAPE, MASE (scaled by the training data's mean
|
|
20
|
+
* |y_t - y_{t-m}|), ACF1 of the errors; for a test set also Theil's U.
|
|
21
|
+
* Equivalent to `forecast::accuracy()` in R.
|
|
22
|
+
*
|
|
23
|
+
* @category Time series
|
|
24
|
+
*/
|
|
25
|
+
export declare function accuracy(training: {
|
|
26
|
+
y: readonly number[];
|
|
27
|
+
fitted: readonly number[];
|
|
28
|
+
}, options?: {
|
|
29
|
+
frequency?: number;
|
|
30
|
+
test?: {
|
|
31
|
+
y: readonly number[];
|
|
32
|
+
forecast: readonly number[];
|
|
33
|
+
};
|
|
34
|
+
}): {
|
|
35
|
+
training: AccuracyRow;
|
|
36
|
+
test?: AccuracyRow;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Moving-average smoother (forecast's `ma()`): order k, centred (a 2 x k average) for even k when `centre`. Equivalent to `forecast::ma()` in R.
|
|
40
|
+
*
|
|
41
|
+
* @category Time series
|
|
42
|
+
*/
|
|
43
|
+
export declare function ma(x: readonly number[], order: number, options?: {
|
|
44
|
+
centre?: boolean;
|
|
45
|
+
}): number[];
|
|
46
|
+
/**
|
|
47
|
+
* Fourier terms (forecast's `fourier()`): S_k = sin(2 pi k t / m), C_k = cos(2 pi k t / m) for k = 1..K, t = 1..n (or
|
|
48
|
+
* n + 1..n + h), the sine dropped at k = m / 2; columns named "S1-12", "C1-12", ...
|
|
49
|
+
* Equivalent to `forecast::fourier()` in R.
|
|
50
|
+
*
|
|
51
|
+
* @category Time series
|
|
52
|
+
*/
|
|
53
|
+
export declare function fourier(options: {
|
|
54
|
+
frequency: number;
|
|
55
|
+
K: number;
|
|
56
|
+
n: number;
|
|
57
|
+
h?: number;
|
|
58
|
+
}): {
|
|
59
|
+
names: string[];
|
|
60
|
+
columns: number[][];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Seasonal dummies (forecast's `seasonaldummy()`): m - 1 columns, the last period omitted; `start` the cycle position (1-based) of the first row. Equivalent to `forecast::seasonaldummy()` in R.
|
|
64
|
+
*
|
|
65
|
+
* @category Time series
|
|
66
|
+
*/
|
|
67
|
+
export declare function seasonaldummy(options: {
|
|
68
|
+
frequency: number;
|
|
69
|
+
n: number;
|
|
70
|
+
start?: number;
|
|
71
|
+
h?: number;
|
|
72
|
+
}): number[][];
|
|
73
|
+
/**
|
|
74
|
+
* Days in each month or quarter (forecast's `monthdays()`). Equivalent to `forecast::monthdays()` in R.
|
|
75
|
+
*
|
|
76
|
+
* @category Time series
|
|
77
|
+
*/
|
|
78
|
+
export declare function monthdays(options: {
|
|
79
|
+
startYear: number;
|
|
80
|
+
startPeriod?: number;
|
|
81
|
+
n: number;
|
|
82
|
+
frequency?: 12 | 4;
|
|
83
|
+
}): number[];
|
|
84
|
+
/**
|
|
85
|
+
* Easter Sunday of year Y (anonymous Gregorian algorithm) as [month, day]. Not an R function.
|
|
86
|
+
*
|
|
87
|
+
* @category Time series
|
|
88
|
+
*/
|
|
89
|
+
export declare function easterSunday(Y: number): [number, number];
|
|
90
|
+
/**
|
|
91
|
+
* The Easter holidays in each month or quarter (forecast's `easter()`): the share of Good Friday .. Easter Sunday (..
|
|
92
|
+
* Monday with `easterMon`) falling in the period, rounded to two decimals (as R). Departs from R for quarterly data
|
|
93
|
+
* with `easterMon` when the holidays span two quarters: R's shares are shifted there (it warns about a replacement
|
|
94
|
+
* length; log 91), rStats.js gives each quarter its share.
|
|
95
|
+
* Equivalent to `forecast::easter()` in R.
|
|
96
|
+
*
|
|
97
|
+
* @category Time series
|
|
98
|
+
*/
|
|
99
|
+
export declare function easter(options: {
|
|
100
|
+
startYear: number;
|
|
101
|
+
startPeriod?: number;
|
|
102
|
+
n: number;
|
|
103
|
+
frequency?: 12 | 4;
|
|
104
|
+
easterMon?: boolean;
|
|
105
|
+
}): number[];
|
|
106
|
+
/**
|
|
107
|
+
* Trading days in each month or quarter (forecast's `bizdays()`): weekdays minus the holidays of the financial centre
|
|
108
|
+
* ("New York" (NYSE, default), "London", "NERC", "Toronto", "Zurich"; the rules of log 30-32).
|
|
109
|
+
* Equivalent to `forecast::bizdays()` in R.
|
|
110
|
+
*
|
|
111
|
+
* @category Time series
|
|
112
|
+
*/
|
|
113
|
+
export declare function bizdays(options: {
|
|
114
|
+
startYear: number;
|
|
115
|
+
startPeriod?: number;
|
|
116
|
+
n: number;
|
|
117
|
+
frequency?: 12 | 4;
|
|
118
|
+
finCenter?: "New York" | "London" | "NERC" | "Toronto" | "Zurich";
|
|
119
|
+
}): number[];
|
|
120
|
+
/**
|
|
121
|
+
* The Diebold-Mariano test with the Harvey-Leybourne-Newbold correction (forecast's `dm.test()`): d = |e1|^power -
|
|
122
|
+
* |e2|^power, its variance from the autocovariances up to h - 1 (over n), t(n - 1).
|
|
123
|
+
* Equivalent to `forecast::dm.test()` in R.
|
|
124
|
+
*
|
|
125
|
+
* @category Time series
|
|
126
|
+
*/
|
|
127
|
+
export declare function dmTest(e1: readonly number[], e2: readonly number[], options?: {
|
|
128
|
+
alternative?: "two.sided" | "less" | "greater";
|
|
129
|
+
h?: number;
|
|
130
|
+
power?: number;
|
|
131
|
+
}): {
|
|
132
|
+
statistic: number;
|
|
133
|
+
parameter: number;
|
|
134
|
+
pValue: number;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Cross-validation and information criteria of a linear model (forecast's `CV()`): CV = mean((e / (1 - h_ii))^2), AIC =
|
|
138
|
+
* n log(SSE/n) + 2(k + 2), AICc, BIC, adjusted R^2 (k = the number of predictors).
|
|
139
|
+
* Equivalent to `forecast::CV()` in R.
|
|
140
|
+
*
|
|
141
|
+
* @category Time series
|
|
142
|
+
*/
|
|
143
|
+
export declare function cvLm(x: readonly (readonly number[])[], y0: readonly number[]): {
|
|
144
|
+
CV: number;
|
|
145
|
+
AIC: number;
|
|
146
|
+
AICc: number;
|
|
147
|
+
BIC: number;
|
|
148
|
+
AdjR2: number;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* The Ljung-Box test of a model's residuals (forecast's `checkresiduals()`, without the plots): lag = min(2m, n/5) for
|
|
152
|
+
* seasonal data or min(10, n/5), at least df + 3, df = the number of ARMA coefficients (0 for plain residuals).
|
|
153
|
+
* Equivalent to `forecast::checkresiduals()` in R.
|
|
154
|
+
*
|
|
155
|
+
* @category Time series
|
|
156
|
+
*/
|
|
157
|
+
export declare function checkresiduals(residuals: readonly number[], options?: {
|
|
158
|
+
frequency?: number;
|
|
159
|
+
df?: number;
|
|
160
|
+
}): {
|
|
161
|
+
statistic: number;
|
|
162
|
+
parameter: number;
|
|
163
|
+
pValue: number;
|
|
164
|
+
lag: number;
|
|
165
|
+
};
|
|
166
|
+
/** The number of ARMA coefficients of a fit (for checkresiduals' df). */
|
|
167
|
+
export declare function armaCoefficients(fit: ArimaResult): number;
|
|
168
|
+
/**
|
|
169
|
+
* Time series cross-validation (forecast's `tsCV()`): for each origin t the forecast errors of y_{t+1..t+h} from the fit
|
|
170
|
+
* to y_1..y_t, stored in row t (NaN where unavailable).
|
|
171
|
+
* Equivalent to `forecast::tsCV()` in R.
|
|
172
|
+
*
|
|
173
|
+
* @category Time series
|
|
174
|
+
*/
|
|
175
|
+
export declare function tsCV(y: readonly number[], forecastFun: (y: number[], h: number) => readonly number[], options?: {
|
|
176
|
+
h?: number;
|
|
177
|
+
}): number[][];
|
|
178
|
+
/**
|
|
179
|
+
* The (p, d, q) or (p, d, q, P, D, Q, frequency) of an ARIMA fit (forecast's `arimaorder()`). Equivalent to `forecast::arimaorder()` in R.
|
|
180
|
+
*
|
|
181
|
+
* @category Time series
|
|
182
|
+
*/
|
|
183
|
+
export declare function arimaorder(fit: ArimaResult): Record<string, number>;
|
|
184
|
+
/**
|
|
185
|
+
* The AR spectrum (stats' `spec.ar()` at n.freq frequencies 0..0.5) of x: var.pred / |1 - sum a_k e^{-2 pi i f k}|^2. Equivalent to R's `spec.ar()`.
|
|
186
|
+
*
|
|
187
|
+
* @category Time series
|
|
188
|
+
*/
|
|
189
|
+
export declare function specAr(x: readonly number[], options?: {
|
|
190
|
+
nFreq?: number;
|
|
191
|
+
}): {
|
|
192
|
+
freq: number[];
|
|
193
|
+
spec: number[];
|
|
194
|
+
order: number;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* The dominant period of a series (forecast's `findfrequency()`): 1 unless the maximum of the AR spectrum of the
|
|
198
|
+
* detrended series exceeds 10; then round(1 / f) at the maximum, or, when the maximum is at the lowest frequency, at
|
|
199
|
+
* the largest value after the spectrum first rises (1 if that is the last frequency).
|
|
200
|
+
* Equivalent to `forecast::findfrequency()` in R.
|
|
201
|
+
*
|
|
202
|
+
* @category Time series
|
|
203
|
+
*/
|
|
204
|
+
export declare function findfrequency(x: readonly number[]): number;
|
|
205
|
+
/**
|
|
206
|
+
* Interpolation of missing values (forecast's `na.interp()`): linear for non-seasonal series (or at most two periods
|
|
207
|
+
* observed); for seasonal series the seasonal component of a robust mstl of a first filling (lm on Fourier terms K =
|
|
208
|
+
* min(5, floor(m/2)) and a polynomial of degree min(6, floor(n/10))), the seasonally adjusted series interpolated
|
|
209
|
+
* linearly.
|
|
210
|
+
* Equivalent to `forecast::na.interp()` in R.
|
|
211
|
+
*
|
|
212
|
+
* @category Time series
|
|
213
|
+
*/
|
|
214
|
+
export declare function naInterp(x: readonly number[], options?: {
|
|
215
|
+
frequency?: number;
|
|
216
|
+
}): number[];
|
|
217
|
+
/**
|
|
218
|
+
* Outliers and their replacements (forecast's `tsoutliers()`): the remainder of seasadj(robust mstl) minus supsmu (or x
|
|
219
|
+
* minus supsmu), points outside [Q1 - 3 IQR, Q3 + 3 IQR], replaced by na.interp with them removed; `iterate` passes
|
|
220
|
+
* (default 2), the union of the flags.
|
|
221
|
+
* Equivalent to `forecast::tsoutliers()` in R.
|
|
222
|
+
*
|
|
223
|
+
* @category Time series
|
|
224
|
+
*/
|
|
225
|
+
export declare function tsoutliers(x: readonly number[], options?: {
|
|
226
|
+
frequency?: number;
|
|
227
|
+
iterate?: number;
|
|
228
|
+
}): {
|
|
229
|
+
index: number[];
|
|
230
|
+
replacements: number[];
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* The series with missing values interpolated and outliers replaced (forecast's `tsclean()`).
|
|
234
|
+
* Equivalent to `forecast::tsclean()` in R.
|
|
235
|
+
*
|
|
236
|
+
* @category Time series
|
|
237
|
+
*/
|
|
238
|
+
export declare function tsclean(x: readonly number[], options?: {
|
|
239
|
+
frequency?: number;
|
|
240
|
+
replaceMissing?: boolean;
|
|
241
|
+
iterate?: number;
|
|
242
|
+
}): number[];
|
|
243
|
+
/**
|
|
244
|
+
* The seasonal component of an {@link mstl} decomposition (forecast's `seasonal()`; zeros without one). Equivalent to `forecast::seasonal()` in R.
|
|
245
|
+
*
|
|
246
|
+
* @category Time series
|
|
247
|
+
*/
|
|
248
|
+
export declare function seasonalComponent(dec: MstlResult): number[];
|
|
249
|
+
/**
|
|
250
|
+
* The trend-cycle component of an {@link mstl} decomposition (forecast's `trendcycle()`). Equivalent to `forecast::trendcycle()` in R.
|
|
251
|
+
*
|
|
252
|
+
* @category Time series
|
|
253
|
+
*/
|
|
254
|
+
export declare function trendcycle(dec: MstlResult): number[];
|
|
255
|
+
/**
|
|
256
|
+
* The remainder component of an {@link mstl} decomposition (forecast's `remainder()`). Equivalent to `forecast::remainder()` in R.
|
|
257
|
+
*
|
|
258
|
+
* @category Time series
|
|
259
|
+
*/
|
|
260
|
+
export declare function remainder(dec: MstlResult): number[];
|