VharBayes

model.VharBayes(
    self,
    data,
    week=5,
    month=22,
    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='longrun',
    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
week int VHAR weekly order, by default 5 5
month int VHAR monthly order, by default 22 22
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 str Minnesota-type group structure - “no”: Not use the group structure - “short”: BVAR-minnesota structure - “longrun”: BVHAR-minnesota structure 'longrun'
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.

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.VharBayes.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.VharBayes.fit()

Conduct MCMC and compute posterior mean

Returns

Name Type Description
self object An instance of the estimator.

predict

model.VharBayes.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.VharBayes.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