DFMResult#
- class cultivars.multivariate.large_dim.dynamic_factor.DFMResult(*, panel, series_names, factors, loadings, means, scales, variance_shares, idiosyncratic, criterion_values, n_factors)[source]#
A fitted dynamic factor model: loadings, a factor VAR, and the split.
The estimates of the two-step model on the standardized panel \(x_t = (y_t - \bar y) / s\),
\[x_t = \Lambda F_t + e_t, \qquad F_t = \sum_{i=1}^{p} A_i F_{t-i} + u_t,\]with \(\Lambda\) the first \(r\) orthonormal right singular vectors of the standardized panel, \(F_t\) its projection onto them, and the VAR fitted to \(F_t\) by least squares without an intercept (the scores have mean zero by construction). The factor VAR is a complete fitted result of its own – forecast it, decompose it, feed it to
Spillover– while this result owns the mapping between the panel and the factor space: the loadings, the standardization that was undone, the idiosyncratic remainders and the share of variance the factors carry.Note
The factor space is identified, the basis is not: any rotation of \((\Lambda, F_t)\) by an orthogonal \(r \times r\) matrix leaves
common_component,r_squaredandforecastunchanged, so individual factors carry no structural names. Because the loadings are orthonormal and the standardized columns have unit variance, the mean ofr_squaredover the series equalsvariance_shares.sum()exactly. A constant column is standardized with scale 1 (not 0), contributes nothing to the factors, and reports anr_squaredof 1 because its remainder is identically zero; read such a value as “nothing to explain”, not “fully explained”.- Variables:
panel – The observed
(nobs, n_series)panel.series_names – One label per series.
factors – The fitted VAR on the estimated factors, a full
VARResultwith variablesf1 ... fr.loadings –
(n_series, r)orthonormal loadings on the standardized panel; the factor space is identified, the basis is not.means –
(n_series,)series means removed before extraction.scales –
(n_series,)series standard deviations divided out.variance_shares –
(r,)share of the standardized panel’s variance each component explains.idiosyncratic –
(nobs, n_series)standardized-panel remainders after the common component.criterion_values – Bai-Ng
ICp2at each candidate count – empty when the caller fixed the count, so the audit trail matches what was actually decided.n_factors – The factor count estimated with.
See also
References
Stock, J. H., & Watson, M. W. (2002). Forecasting using principal components from a large number of predictors. Journal of the American Statistical Association, 97(460), 1167-1179.
Bai, J., & Ng, S. (2002). Determining the number of factors in approximate factor models. Econometrica, 70(1), 191-221.
Example
Two persistent factors loaded onto thirty noisy series; the count is recovered, the common component tracks the truth, and the factor VAR is a full result:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> f = np.zeros((200, 2)) >>> for t in range(1, 200): ... f[t] = 0.7 * f[t - 1] + rng.standard_normal(2) >>> lam = rng.standard_normal((30, 2)) >>> panel = f @ lam.T + 1.5 * rng.standard_normal((200, 30)) >>> res = DFM(panel, order=1).fit() >>> res.n_factors, res.n_series, res.nobs, res.loadings.shape (2, 30, 200, (30, 2)) >>> bool(np.allclose(res.loadings.T @ res.loadings, np.eye(2))) True >>> truth = f @ lam.T >>> bool(np.corrcoef(res.common_component[:, 0], truth[:, 0])[0, 1] > 0.9) True >>> res.factors.names, res.factors.order, res.criterion_values.shape (('f1', 'f2'), 1, (8,)) >>> bool(abs(np.mean(list(res.r_squared().values())) - res.variance_shares.sum()) < 1e-12) True
Attributes#
The observed |
|
One label per series, in column order. |
|
The fitted VAR on the factor scores, variables ``f1 . |
|
|
|
|
|
|
|
|
|
|
|
Bai-Ng |
|
The factor count the model was estimated with. |
|
The factors' reconstruction of the panel, in original units. |
|
Number of series in the panel. |
|
Panel length. |