A C++-based R implementation of the
two-step estimation procedure for a (linear Gaussian) Sparse Dynamic
Factor Model (SDFM) as outlined in Franjic and Schweikert (2024).
The TwoStepSDFM package provides a fast implementation
of the Kalman Filter and Smoother (hereinafter KFS, see Koopman and
Durbin, 2000) to estimate factors in a mixed-frequency SDFM framework,
explicitly accounting for cross-sectional correlation in the measurement
error. The KFS is initialized using results from Sparse Principal
Components Analysis (SPCA) by Zou and Hastie (2006) in a preliminary
step. This approach generalizes the two-step estimator for approximate
dynamic factor models by Giannone, Reichlin, and Small (2008) and Doz,
Giannone, and Reichlin (2011). For more details see Franjic and
Schweikert (2024).
simFM()
function provides a flexible framework to simulate mixed-frequency data
with ragged edges from an approximate DFM.noOfFactors() function uses the Onatski (2009) procedure to
estimate the number of factors efficiently while providing good finite
sample performance.twoStepSDFM() function provides a fast, memory-efficient,
and convenient implementation of the two-step estimator outlined in
Franjic and Schweikert (2024).crossVal() function provides a fast and parallel
cross-validation wrapper to retrieve the optimal hyper-parameters using
time-series cross-validation (Hyndman and Athanasopoulos 2018) with
random hyper-parameter search (Bergstra and Bengio 2012).nowcast()
function is a highly convenient prediction function for backcasts,
nowcasts, and forecasts of multiple targets. It automatically takes care
of all issues arising with mixed-frequency data and ragged edges.nowcast() function is also able to produce predictions of a
dense DFM according to Giannone, Reichlin, and Small (2008). The
function twoStepDenseDFM() additionally exposes an
estimation procedure for the dense two-step estimator.sparsePCA() exposes the
internal C++-backed SPCA routine in R. This
provides access to a fast and memory-efficient SPCA estimation routine
as implemented by Zou and Hastie (2020) in pure R.kalmanFilterSmoother() function exposes the internal
C++-backed KFS routine.C++
code into R (Eddelbuettel and François, 2011). Rcpp CRAN
repositoryEigen linear algebra library into R (Bates and
Eddelbuettel, 2013). RcppEigen CRAN
repositoryRcpp and RcppEigen can be downloaded from
CRAN or directly installed from within R by calling
install.packages("...").
To install the package itself, a short R script is
provided (see PackageBuilder.R). The package currently only
compiles with the g++/gcc compiler.
For a quick step-by-step user guide of the main features, see the package vignette.
License: GPL v3
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
To Contribute:
If you have any questions or need assistance, please open an issue on the GitHub repository or contact us via email.