Dynamic Factors¶
-
class
dismalpy.ssm.dynamic_factor.
DynamicFactor
(endog, k_factors, factor_order, exog=None, error_order=0, error_var=False, error_cov_type='diagonal', enforce_stationarity=True, **kwargs)[source]¶ Dynamic factor model
Parameters: endog : array_like
The observed time-series process \(y\)
exog : array_like, optional
Array of exogenous regressors for the observation equation, shaped nobs x k_exog.
k_factors : int
The number of unobserved factors.
factor_order : int
The order of the vector autoregression followed by the factors.
error_cov_type : {‘scalar’, ‘diagonal’, ‘unstructured’}, optional
The structure of the covariance matrix of the observation error term, where “unstructured” puts no restrictions on the matrix, “diagonal” requires it to be any diagonal matrix (uncorrelated errors), and “scalar” requires it to be a scalar times the identity matrix. Default is “diagonal”.
error_order : int, optional
The order of the vector autoregression followed by the observation error component. Default is None, corresponding to white noise errors.
error_var : boolean, optional
Whether or not to model the errors jointly via a vector autoregression, rather than as individual autoregressions. Has no effect unless error_order is set. Default is False.
enforce_stationarity : boolean, optional
Whether or not to transform the AR parameters to enforce stationarity in the autoregressive component of the model. Default is True.
**kwargs
Keyword arguments may be used to provide default values for state space matrices or for Kalman filtering options. See Representation, and KalmanFilter for more details.
See also
dismalpy.ssm.mlemodel.MLEModel
,dismalpy.ssm.kalman_smoother.KalmanSmoother
,dismalpy.ssm.kalman_filter.KalmanFilter
,dismalpy.ssm.representation.Representation
Notes
The dynamic factor model considered here is in the so-called static form, and is specified:
\[\begin{split}y_t & = \Lambda f_t + B x_t + u_t \\ f_t & = A_1 f_{t-1} + \dots + A_p f_{t-p} + \eta_t \\ u_t & = C_1 u_{t-1} + \dots + C_1 f_{t-q} + \varepsilon_t\end{split}\]where there are k_endog observed series and k_factors unobserved factors. Thus \(y_t\) is a k_endog x 1 vector and \(f_t\) is a k_factors x 1 vector.
\(x_t\) are optional exogenous vectors, shaped k_exog x 1.
\(\eta_t\) and \(\varepsilon_t\) are white noise error terms. In order to identify the factors, \(Var(\eta_t) = I\). Denote \(Var(\varepsilon_t) \equiv \Sigma\).
Options related to the unobserved factors:
- k_factors: this is the dimension of the vector \(f_t\), above. To exclude factors completely, set k_factors = 0.
- factor_order: this is the number of lags to include in the factor evolution equation, and corresponds to \(p\), above. To have static factors, set factor_order = 0.
Options related to the observation error term \(u_t\):
- error_order: the number of lags to include in the error evolution equation; corresponds to \(q\), above. To have white noise errors, set error_order = 0 (this is the default).
- error_cov_type: this controls the form of the covariance matrix \(\Sigma\). If it is “dscalar”, then \(\Sigma = \sigma^2 I\). If it is “diagonal”, then \(\Sigma = \text{diag}(\sigma_1^2, \dots, \sigma_n^2)\). If it is “unstructured”, then \(\Sigma\) is any valid variance / covariance matrix (i.e. symmetric and positive definite).
- error_var: this controls whether or not the errors evolve jointly according to a VAR(q), or individually according to separate AR(q) processes. In terms of the formulation above, if error_var = False, then the matrices :math:C_i` are diagonal, otherwise they are general VAR matrices.
References
[R1] Lutkepohl, Helmut. 2007. New Introduction to Multiple Time Series Analysis. Berlin: Springer. Attributes
exog (array_like, optional) Array of exogenous regressors for the observation equation, shaped nobs x k_exog. k_factors (int) The number of unobserved factors. factor_order (int) The order of the vector autoregression followed by the factors. error_cov_type ({‘diagonal’, ‘unstructured’}) The structure of the covariance matrix of the error term, where “unstructured” puts no restrictions on the matrix and “diagonal” requires it to be a diagonal matrix (uncorrelated errors). error_order (int) The order of the vector autoregression followed by the observation error component. error_var (boolean) Whether or not to model the errors jointly via a vector autoregression, rather than as individual autoregressions. Has no effect unless error_order is set. enforce_stationarity (boolean, optional) Whether or not to transform the AR parameters to enforce stationarity in the autoregressive component of the model. Default is True.
-
class
dismalpy.ssm.dynamic_factor.
DynamicFactorResults
(model, params, smoother_results, cov_type='opg', cov_kwds=None, **kwargs)[source]¶ Class to hold results from fitting an DynamicFactor model.
Parameters: model : DynamicFactor instance
The fitted model instance
See also
dismalpy.ssm.mlemodel.MLEResults
,dismalpy.ssm.kalman_smoother.SmootherResults
,dismalpy.ssm.kalman_filter.FilterResults
,dismalpy.ssm.representation.FrozenRepresentation
Attributes
specification (dictionary) Dictionary including all attributes from the DynamicFactor model instance. coefficient_matrices_var (array) Array containing autoregressive lag polynomial coefficient matrices, ordered from lowest degree to highest. -
coefficients_of_determination
()[source]¶ Coefficients of determination (\(R^2\)) from regressions of individual estimated factors on endogenous variables.
Returns: coefficients_of_determination : array
A k_endog x k_factors array, where coefficients_of_determination[i, j] represents the \(R^2\) value from a regression of factor j and a constant on endogenous variable i.
See also
Notes
Although it can be difficult to interpret the estimated factor loadings and factors, it is often helpful to use the cofficients of determination from univariate regressions to assess the importance of each factor in explaining the variation in each endogenous variable.
In models with many variables and factors, this can sometimes lend interpretation to the factors (for example sometimes one factor will load primarily on real variables and another on nominal variables).
-
factors
¶ Estimates of unobserved factors Returns ——- out: Bunch
Has the following attributes:
- filtered: a time series array with the filtered estimate of
the component
- filtered_cov: a time series array with the filtered estimate of
the variance/covariance of the component
- offset: an integer giving the offset in the state vector where
this component begins
-
plot_coefficients_of_determination
(endog_labels=None, fig=None, figsize=None)[source]¶ Plot the coefficients of determination
Parameters: endog_labels : boolean, optional
Whether or not to label the endogenous variables along the x-axis of the plots. Default is to include labels if there are 5 or fewer endogenous variables.
fig : Matplotlib Figure instance, optional
If given, subplots are created in this figure instead of in a new figure. Note that the grid will be created in the provided figure using fig.add_subplot().
figsize : tuple, optional
If a figure is created, this argument allows specifying a size. The tuple is (width, height).
See also
Notes
Produces a k_factors x 1 plot grid. The i`th plot shows a bar plot of the coefficients of determination associated with factor `i. The endogenous variables are arranged along the x-axis according to their position in the endog array.
-