Skip to content

This shows how to estimate a DFM with a 2-step estimator of Doz et. al. (2011)

Notifications You must be signed in to change notification settings

Soybilgen/2_Step_Estimator_DFM

Repository files navigation

These functions estimate a DFM with a 2-step estimator of Doz et. al. (2011).

These functions are based on the MATLAB functions of Giannone et. al. (2008).

Simple Introduction

Let us define as our standardized variables. Then, the factor model has the following representation:

where is an matrix of factor loadings, is the idiosyncratic component, represents the unobserved common factors following a vector autoregression process (VAR) as follows:

where is an matrix of full rank with , are matrices of autoregressive coefficients, and is the dimensional vector of common shocks, which follows a white-noise process.

Set of equations defined above is estimated using the two step estimation procedure of Doz et. al. (2011) as follows:

  1. All variables are standardized in the first step.
  2. First principal components are extracted from the balanced part of the data set where all observations are present and obtain the initial factor estimates and parameters using the function ricSW(z, q, r, p). represents the balanced part of the data set.
  3. Before moving to the Kalman smoother part, the ragged edge part of the data set are incorporated into the procedure by assigning an extremely large value to the variance of the idiosyncratic component where there is missing observations and replacing missing values in with arbitrary values.
  4. Factors are re-estimated using one run of the Kalman filter function kalman_filter_diag(y, A, C, Q, R, init_x, init_V, model) and one run of the Kalman smoother function kalman_smoother_diag(y, A, C, Q, R, init_x, init_V, model) while incorporating the unbalanced part of the data set.

Simple Example

Load FRED-MD Data Set

load(url("https://github.com/Soybilgen/2_Step_Estimator_DFM/raw/master/Example.RData"))

Load necessary functions

source("https://github.com/raw/Soybilgen/2_Step_Estimator_DFM/master/FactorExtraction.R")
source("https://github.com/raw/Soybilgen/2_Step_Estimator_DFM/master/center.R")
source("https://github.com/raw/Soybilgen/2_Step_Estimator_DFM/master/kalman_filter_diag.R")
source("https://github.com/raw/Soybilgen/2_Step_Estimator_DFM/master/kalman_smoother_diag.R")
source("https://github.com/raw/Soybilgen/2_Step_Estimator_DFM/master/kalman_update_diag.R")
source("https://github.com/raw/Soybilgen/2_Step_Estimator_DFM/master/ricSW.R")
source("https://github.com/raw/Soybilgen/2_Step_Estimator_DFM/master/smooth_update.R")

Load necessary packages

install.packages("pracma") # Numeric Analysis Package
install.packages("RSpectra") # Solvers for Large-Scale Eigenvalue and SVD Problems

Determine the DFM specification

q <- 2 # dynamic factors
r <- 5 # static factors
p <- 4 # VAR lag

Estimate the DFM and obtain dynamic factors

result <- FactorExtraction(x, q, r, p)
Dynamic_Factors <- result$F

References

Doz, C., Giannone, D., & Reichlin, L. (2011). A two-step estimator for large approximate dynamic factor models based on Kalman filtering. Journal of Econometrics, 164(1), 188-205.

Giannone, D., Reichlin, L., & Small, D. (2008). Nowcasting: The real-time informational content of macroeconomic data. Journal of Monetary Economics, 55(4), 665-676.

About

This shows how to estimate a DFM with a 2-step estimator of Doz et. al. (2011)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages