kats.models.bayesian_var module¶

Bayesian estimation of Vector Autoregressive Model using Minnesota prior on the coefficient matrix. This version is useful for regularization when they are too many coefficients to be estimated.

Implementation inspired by the following two articles/papers:

https://www.mathworks.com/help/econ/normalbvarm.html#mw_4a1ab118-9ef3-4380-8c5a-12b848254117 http://apps.eui.eu/Personal/Canova/Articles/ch10.pdf (page 5)

class kats.models.bayesian_var.BayesianVAR(data: kats.consts.TimeSeriesData, params: kats.models.bayesian_var.BayesianVARParams)[source]¶

Bases: Generic[kats.models.model.ParamsType]

Model class for bayesian VAR

This class provides fit, predict, and plot methods for bayesian VAR model

data¶

the input time series data as TimeSeriesData

params¶

the parameter class defined with BayesianVARParams

fit()None[source]¶

Fit Bayesian VAR model

plot()None[source]¶

Plot forecasted results from Bayesian VAR model

predict(steps: int, include_history=False, verbose=False)Dict[str, kats.consts.TimeSeriesData][source]¶

Predict with the fitted VAR model

Parameters
  • steps – Number of time steps to forecast

  • include_history – return fitted values also

Returns

Disctionary of predicted results for each metric. Each metric result has following columns: time, fcst, fcst_lower, and fcst_upper Note confidence intervals of forecast are not yet implemented.

class kats.models.bayesian_var.BayesianVARParams(p: int = 5, phi_0: float = 0.02, phi_1: float = 0.25, phi_2: float = 20, phi_3: float = 3)[source]¶

Bases: kats.consts.Params

Parameter class for Bayesian VAR model

p¶

Historical lag to use

Type

int

Below parameters are hyperparameters in the covariance matrix for coefficient prior.
See page 5 in http

//apps.eui.eu/Personal/Canova/Articles/ch10.pdf for more details.

phi_0¶

tightness on the variance of the first lag

Type

float

phi_1¶

relative tightness of other variables

Type

float

phi_2¶

relative tightness of the exogenous variables

Type

float

phi_3¶

decay with lag is parameterized as lag^phi_3

Type

float