Skip to content

cran/TwoStepSDFM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TwoStepSDFM

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).

Introduction

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).

Main Features

  • Fast Model Simulation: The simFM() function provides a flexible framework to simulate mixed-frequency data with ragged edges from an approximate DFM.
  • Estimation of the Number of Factors: The noOfFactors() function uses the Onatski (2009) procedure to estimate the number of factors efficiently while providing good finite sample performance.
  • Fast Model Estimation: The twoStepSDFM() function provides a fast, memory-efficient, and convenient implementation of the two-step estimator outlined in Franjic and Schweikert (2024).
  • Fast Hyper-Parameter Cross-Validation: The 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).
  • Fast Model Prediction: The 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.
  • Compatibility: All functions take advantage of C++ for enhanced speed and memory-efficiency.

Side Features

  • Fast dense DFM estimation and prediction: The 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.
  • Fast SPCA: 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.
  • Fast Kalman Filter and Smoother: The kalmanFilterSmoother() function exposes the internal C++-backed KFS routine.

Prerequisites

  • Rcpp: A package for integrating C++ code into R (Eddelbuettel and François, 2011). Rcpp CRAN repository
  • RcppEigen: A package for integrating the Eigen linear algebra library into R (Bates and Eddelbuettel, 2013). RcppEigen CRAN repository
  • GCC compiler (version 5.0 or later) GCC Website.

Installation

Compile from scratch

Rcpp 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.

Usage

For a quick step-by-step user guide of the main features, see the package vignette.

License

License: GPL v3

(C) 2024-2026 Domenic Franjic

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

To Contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Commit your changes with descriptive messages.
  4. Push to your fork and submit a pull request.

Support

If you have any questions or need assistance, please open an issue on the GitHub repository or contact us via email.

Contact

  • Name: Domenic Franjic
  • Institution: University of Hohenheim
  • Department: Econometrics and Statistics, Core Facility Hohenheim
  • E-Mail: franjic@uni-hohenheim.de

References

Papers

Books

  • Hyndman, Rob J., and George Athanasopoulos (2018). Forecasting: Principles and Practice (3rd ed.). OTexts Melbourne.

Software / Packages

About

❗ This is a read-only mirror of the CRAN R package repository. TwoStepSDFM — Estimate a Sparse Mixed Frequency Gaussian Factor Model Using a Two-Step Procedure

Resources

Stars

Watchers

Forks

Packages