VarBayes

model.VarBayes(
    self,
    data,
    lag=1,
    n_chain=1,
    n_iter=1000,
    n_burn=None,
    n_thin=1,
    bayes_config=SsvsConfig(),
    cov_config=LdltConfig(),
    intercept_config=InterceptConfig(),
    fit_intercept=True,
    minnesota=True,
    verbose=False,
    n_thread=1,
)

Bayesian Vector Autoregressive Model

Fits Bayesian VAR model.

Parameters

Name Type Description Default
data array - like Time series data of which columns indicate the variables required
lag int VAR lag, by default 1 1
n_chain int Number of MCMC chains, by default 1 1
n_iter int Number of MCMC total iterations, by default 1000 1000
n_burn int MCMC burn-in (warm-up), by default floor(n_iter / 2) None
n_thin int Thinning every n_thin-th iteration, by default 1 1
bayes_config _BayesConfig Prior configuration, by default SsvsConfig() SsvsConfig()
cov_config (LdltConfig, SvConfig) Prior configuration for covariance matrix, by default LdltConfig() 'LdltConfig'
intercept_config InterceptConfig Prior configuration for constant term, by default InterceptConfig() InterceptConfig()
fit_intercept bool Include constant term in the model, by default True True
minnesota bool If True, apply Minnesota-type group structure, by default True True
verbose bool If True, print progress bar for MCMC, by default False False
n_thread int Number of OpenMP threads, by default 1 1

Attributes

Name Type Description
coef_ ndarray VHAR coefficient matrix.
intercept_ ndarray VHAR model constant vector.
n_features_in_ int Number of variables.

References

.. [1] Carriero, A., Chan, J., Clark, T. E., & Marcellino, M. (2022). Corrigendum to “Large Bayesian vector autoregressions with stochastic volatility and non-conjugate priors” [J. Econometrics 212 (1)(2019) 137–154]. Journal of Econometrics, 227(2), 506-512. .. [2] Chan, J., Koop, G., Poirier, D., & Tobias, J. (2019). Bayesian Econometric Methods (2nd ed., Econometric Exercises). Cambridge: Cambridge University Press. .. [3] Cogley, T., & Sargent, T. J. (2005). Drifts and volatilities: monetary policies and outcomes in the post WWII US. Review of Economic Dynamics, 8(2), 262–302. .. [4] Gruber, L., & Kastner, G. (2022). Forecasting macroeconomic data with Bayesian VARs: Sparse or dense? It depends! arXiv. .. [5] Huber, F., Koop, G., & Onorante, L. (2021). Inducing Sparsity and Shrinkage in Time-Varying Parameter Models. Journal of Business & Economic Statistics, 39(3), 669–683. .. [6] Korobilis, D., & Shimizu, K. (2022). Bayesian Approaches to Shrinkage and Sparse Estimation. Foundations and Trends® in Econometrics, 11(4), 230–354. .. [7] Ray, P., & Bhattacharya, A. (2018). Signal Adaptive Variable Selector for the Horseshoe Prior. arXiv.

Methods

Name Description
expand_forecast Expanding-window forecasting
fit Conduct MCMC and compute posterior mean
predict ‘n_ahead’-step ahead forecasting
roll_forecast Rolling-window forecasting

expand_forecast

model.VarBayes.expand_forecast(
    n_ahead,
    test,
    level=0.05,
    stable=False,
    sparse=False,
    med=False,
    sv=True,
)

Expanding-window forecasting

Parameters

Name Type Description Default
n_ahead int Forecast next n_ahead time point. required
test array - like Test set to forecast required
level float Level for credible interval, by default .05 0.05
stable bool Filter stable coefficient draws, by default True False
sparse bool Apply restriction to forecasting, by default False False
med bool Use median instead of mean to get point forecast, by default False False
sv bool Use SV term in case of SV model, by default True True

Returns

Name Type Description
dict Density forecasting results - “forecast” (ndarray): Posterior mean of forecasting - “se” (ndarray): Standard error of forecasting - “lower” (ndarray): Lower quantile of forecasting - “upper” (ndarray): Upper quantile of forecasting - “lpl” (float): Average log-predictive likelihood

fit

model.VarBayes.fit()

Conduct MCMC and compute posterior mean

Returns

Name Type Description
self object An instance of the estimator.

predict

model.VarBayes.predict(
    n_ahead,
    level=0.05,
    stable=False,
    sparse=False,
    med=False,
    sv=True,
)

‘n_ahead’-step ahead forecasting

Parameters

Name Type Description Default
n_ahead int Forecast until next n_ahead time point. required
level float Level for credible interval, by default .05 0.05
stable bool Filter stable coefficient draws, by default True False
sparse bool Apply restriction to forecasting, by default False False
med bool Use median instead of mean to get point forecast, by default False False
sv bool Use SV term in case of SV model, by default True True

Returns

Name Type Description
dict Density forecasting results - “forecast” (ndarray): Posterior mean of forecasting - “se” (ndarray): Standard error of forecasting - “lower” (ndarray): Lower quantile of forecasting - “upper” (ndarray): Upper quantile of forecasting

roll_forecast

model.VarBayes.roll_forecast(
    n_ahead,
    test,
    level=0.05,
    stable=False,
    sparse=False,
    med=False,
    sv=True,
)

Rolling-window forecasting

Parameters

Name Type Description Default
n_ahead int Forecast next n_ahead time point. required
test array - like Test set to forecast required
level float Level for credible interval, by default .05 0.05
stable bool Filter stable coefficient draws, by default True False
sparse bool Apply restriction to forecasting, by default False False
med bool Use median instead of mean to get point forecast, by default False False
sv bool Use SV term in case of SV model, by default True True

Returns

Name Type Description
dict Density forecasting results - “forecast” (ndarray): Posterior mean of forecasting - “se” (ndarray): Standard error of forecasting - “lower” (ndarray): Lower quantile of forecasting - “upper” (ndarray): Upper quantile of forecasting - “lpl” (float): Average log-predictive likelihood