Skip to content

A powerful & convenient package for a two-step estimation method of the Factor augmented VAR (FAVAR) model, which is mainly based on RATS 10.0 .

Notifications You must be signed in to change notification settings

lyx66/Factor-augmented-vector-autoregressive-FAVAR-WINRATS-code-package-

Repository files navigation

Factor-augmented-vector-autoregressive-(FAVAR)-WIN-RATS-code-package

by Yingxin LIN


Introduction

Fig.1 IRF comparation: baseline (5 Factors+FFR) vs 3 Factors+FFR

IRF results comparation-baseline(5 factors) vs 3 factors

Note: FFR (Federal funds rate) is the proxy variable of Monetary Policy and the only one observable factor in FAVAR model.
Fig.2 Impulse response to MP schock of FFR and other 19 Macroeconomic variables in Xdata (7 lags)

Impulse response of FRR and other 19 Macroeconomic variables in Xdata to MP schock

  • Why I write this package?
      Although there has been a opensource MATLAB package for a Bayesian likelihood methods and Gibbs sampling estimation for FAVAR model yet, that is, the FAVAR MATLAB package written by Gary Koop, it has the disadvantages of large time-consuming due to sampling estimation, inflexible result output process and even some bugs. In order to apply FAVAR in my own research, I have written this RATS code package.
  • Compared with the MATLAB package, some superiorities of FAVAR_TWO_STEPS_LYX are listed as below:
     1. Less running time-comsumption.
     2. The program only needs to run once to output the impulse response with error band and variance decomposition results of all series in both xdata.xlsx and ydata.xlsx.
     3. The result of generalized variance decomposition is available.
     4. Almost no bugs.
     5. It is simple to modify this RATS package if you want to apply it to your own reaserch.
  • I also provided a Python code ( i.g. Draw IRF.ipynb ) in the file-list to show the IRF results outputed by RATS package.

Files in package FAVAR_TWO_STEPS_LYX

  • Main code.rpf
  • verd_lyx.src    - get variance matrix of forecast error
  • mcgraphirf_lyx.src - get median value and error band of IRF
  • kilianbootsetup.src - two-stages boostrap for IRF error band, based on Kilian(1998).

Quick Start

By adjusting the following parameters in Main code.rpf, it is easy to change the purpose of the package:

  • ny - Number of Observable Factors.
  • keyvars - Number of xdata.xlsx series whose IRF and variance decomposition to MP shock you are intrested in.
  • nf - Number of Latent factors.
  • ndraws - Number of draws in two-stages boostrap (for error band of IRF).
  • usegirf - Whether use Generalized variance decomption or not. when usegirf = 0 , choleky decomposition is used; On the contrary, if usegirf = 1 , generalized variance decomption will be applied.

Latent factors obtained by PCA should be rotated as below, since "slow-moving" series in xdata by assumption are not affected contemporaneously by FFR.

dec vect[series] PC_new(nf)
dofor i_ = 1 to nf
   linreg(NOPRINT) PC(i_) /
   # constant fyff PC_slow(1) to PC_slow(nf)
   set PC_new(i_) = PC(i_){0} - %BETA(2) * fyff{0}
end dofor i_

Environment

  • FAVAR model: Windows RATS 10.0
  • Graph for IRF: Python 3.8

Files loaded

Two '.xlsx' files loaded by main code are listed as below:

File # of series Details
ydata.xlsx 1 The proxy variable of monetary policy, that is, the only one observable factor in FAVAR model
xdata.xlsx 119 Macroeconomic data sets, containing information on real-output, employment, interest rate, exchange rate, price level and financial asset price, etc.

Outputs

Tips

  • When running the Main code.rpf, all the other files which is also ziped in FAVAR_TWO_STEPS_LYX should be in the same working directory with it, as well as ydata.xlsx and xdata.xlsx.
  • For more technical details about two-step estimation method of FAVAR model and my package, it's beneficial to read the working-paper version of Bernanke et al. (2005), which was published in 2004.

Copyright notice

Enjoy(。^▽^) ! (...and extend/modify) 😊

About

A powerful & convenient package for a two-step estimation method of the Factor augmented VAR (FAVAR) model, which is mainly based on RATS 10.0 .

Topics

Resources

Stars

Watchers

Forks