Skip to content

Structural Dynamic Factor is a repository focused on the development and analysis of structural dynamic factor models used in econometrics and time series analysis.

Notifications You must be signed in to change notification settings

g-arruda/Structural_dynamic_factor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Structural Dynamic Factor Model

This repository implements a Structural Dynamic Factor Model (SDFM) based on the methodology of Alessio and Kerssenfischer (2019). The model provides a framework for analyzing macroeconomic time series data through the lens of dynamic factors.

Overview

The SDFM approach combines dimension reduction techniques with structural analysis to identify economic shocks and analyze their propagation through the economy. The implementation follows these main steps:

  1. Factor Selection: Determining the optimal number of static and dynamic factors using Bai & Ng (2002) criteria and Amengual & Watson (2007) method.
  2. Factor Estimation: Extracting static factors via Principal Component Analysis and dynamic factors through VAR residuals.
  3. Impulse Response Analysis: Computing and visualizing the responses of economic variables to structural shocks.

Key Components

The repository is organized into the following main components:

  • 📄 factor_estimation.R: Contains functions for factor selection and estimation, including:

    • bai_ng_criteria(): Implementation of Bai & Ng information criteria.
    • amengual_watson(): Method for determining dynamic factors.
    • estimate_dfm(): Main function for estimating the dynamic factor model.
  • 📄 impulse_response.R: Functions for impulse response analysis:

    • compute_irf_dfm(): Calculates impulse responses with bootstrap confidence intervals.
    • plot_irf(): Visualizes impulse response functions.

Methodology

The model works by:

  1. Standardizing the data using first differences.
  2. Extracting static factors through PCA.
  3. Fitting a VAR model to the static factors with Kilian bias correction.
  4. Identifying dynamic factors from VAR residuals.
  5. Computing impulse response functions through bootstrapping.

Example

# Load required functions
source("R/factor_estimation.R")
source("R/impulse_responde.R")

# Load and preprocess data
data <- readr::read_csv("data/processed/final_data.csv") |>
  dplyr::select(-ref.date) |>
  tidyr::drop_na() |>
  as.matrix()

# Determine optimal number of factors
bai_ng <- bai_ng_criteria(data, standardize = TRUE)
amengual <- amengual_watson(data, r = 7, p = 1, scale = TRUE)

# Estimate the model
r <- 7  # number of static factors
q <- 5  # number of dynamic factors
p <- 1  # VAR lag order
dfm_results <- estimate_dfm(data, r, q, p)

# Compute impulse responses
irf_results <- compute_irf_dfm(dfm_results, h = 50, nboot = 800)

# Plot responses for selected variables
response_vars <- list(
  "Variable 1" = 1,
  "Variable 2" = 2
)
plot_irf(irf_results, response_vars, shock = 1)

References

  • Alessi, L., & Kerssenfischer, M. (2019). The response of asset prices to monetary policy shocks: Stronger than thought. Journal of Applied Econometrics, 34(5), 661-672.
  • Bai, J., & Ng, S. (2002). "Determining the Number of Factors in Approximate Factor Models Econometrica, 70(1), 191-221.
  • Amengual, D., & Watson, M. W. (2007). "Consistent Estimation of the Number of Dynamic Factors in a Large N and T Panel." Journal of Business & Economic Statistics, 25(1), 91-96.
  • Stock, J. H., & Watson, M. W. (2016). "Dynamic Factor Models, Factor-Augmented Vector Autoregressions, and Structural Vector Autoregressions in Macroeconomics." Handbook of Macroeconomics, 2, 415-525.

About

Structural Dynamic Factor is a repository focused on the development and analysis of structural dynamic factor models used in econometrics and time series analysis.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages