Solved – Open source code for factor-augmented VAR (FAVAR) model

factor analysisfactor-rotationpcatime seriesvector-autoregression

I am looking for an open source package (R, Python, Julia) that has an implemented FAVAR (factor-augmented VAR) class for time-series prediction problem.

I've already tried to use several solutions I could find on the Internet:

https://rdrr.io/github/joergrieger/bvar/src/R/favar.r – this class focused on computing impulse responses, rather than obtaining forecast $\hat y_{T+1|T}$

https://pythonhosted.org/pymaclab/#api-documentation – have problems while installing this package on Python, still unsure if FAVAR class in this package is the thing I need, since there is no package documentation

https://sites.google.com/site/hmumtaz77/code – also found this list of MATLAB codes, one of them for classical FAVAR, however not for prediction purpose

Also tried several Julia modules. All I managed find was implemented for computing impulse responses.

Popular Python packages like PyFlux, Statsmodels does not have FAVAR model, unfortunately.

Ideally it should work like
from magic_package.models import FAVAR
model = FAVAR.fit({args})
y_hat = model.predict(h=12)

but I will be glad to consider all options you can suggest me.

Best Answer

Here one can find R-language replication of the model described in the paper Bernanke, Boivin and Eliasz (2005). It took me some time to understand PCA in details, cover some basic VAR topics to be able to rewrite in R original matlab procedure (at "2step" directory).

In order to use FAVAR one should specify some parameters that goes at the begining of the file.

In short, for time-series prediction problem algorithm is simple. One should retrieve the first K principal components from informational series $X_t$: $\hat C(F_t,Y_t)$. Then estimate standard VAR model in $(\hat C(F_t,Y_t)',Y_t')$.