BayES BayES

11.1 Vector Autoregressive (VAR) model for time-series data

Mathematical representation

yt = A0wt + j=1pA jytj + 𝜀t,𝜀t N 0,Ω1

where:

With T time observations, an equivalent representation of the model is:

Y = XA + E

where:

YTp×M = yp+1 yp+2 yT ETp×M = 𝜀p+1 𝜀p+2 𝜀T AMp+K×M = A0 A1 Ap

and:

XTp×K+Mp = wp+1 yp yp1 y1 wp+2 yp+1 yp y2 wT yT1 yT2 yTp

In this representation the endogenous variables are expanded over the columns of Y and the time observations are stacked one under the other.

Yet another representation is:

y = IM Xα + 𝜀,𝜀 N 0, Ω IM 1

where:

In this representation the data are first stacked over time and then by variable.

Priors




Parameter Probability density function Default hyperparameters



α p α = |P|12 2πL2 exp 1 2 αmP αm m = 0 L, P = 0.001 IL
Ω p Ω = |Ω|nM1 2 |V1|n2 2nM2ΓMn 2 exp 1 2 tr V1Ω n = M2, V = 100 M IM



Syntax

[<model name> = ] varm( { y1, y2, , yM } [ ~w1 w2 …wK ] [, <options> ] );

where:

PIC Before using the varm() function the dataset used for estimation must be declared as a time-series dataset using the set_ts() function (see section B.13).

The optional arguments for the vector autoregressive model are:1

Specification of lags


"lags"

a vector of integers (either row or column vector) indicating the lags of the endogenous variables to be included in the right-hand side of the model; for example, if this vector is set equal to [1, 4, 9], then the 1st, 4th and 9th lags are included; the default value is 1, in which case, only the first lag of all endogenous are included

Gibbs parameters


"chains"

number of chains to run in parallel (positive integer); the default value is 1

"burnin"

number of burn-in draws per chain (positive integer); the default value is 10000

"draws"

number of retained draws per chain (positive integer); the default value is 20000

"thin"

value of the thinning parameter (positive integer); the default value is 1

"seed"

value of the seed for the random-number generator (positive integer); the default value is 42

Hyperparameters


"m"

mean vector of the prior for α (L ×1 vector); the default value is 0L

"P"

precision matrix of the prior for α (L ×L symmetric and positive-definite matrix); the default value is 0.001 IL

"V"

scale matrix of the prior for Ω (M ×M symmetric and positive-definite matrix); the default value is 100 M IM

"n"

degrees-of-freedom parameter of the prior for Ω (real number greater than or equal to M); the default value is M2

Dataset and log-marginal likelihood


"dataset"

the id value of the dataset that will be used for estimation; the default value is the first dataset in memory (in alphabetical order)

"logML_CJ"

boolean indicating whether the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood should be calculated (true|false); the default value is false

Reported Parameters




α

variable_name

vector of parameters associated with the exogenous variables and the lags of the endogenous variables; these are broken into groups according to the equation in which the variables appear and the parameters associated with the exogenous variables are listed first




Stored values and post-estimation analysis
If a left-hand-side id value is provided when a VAR model is created, then the following results are saved in the model item and are accessible via the ‘.’ operator:

Samples

a matrix containing the draws from the posterior of α (across all equations, starting from the first equation) and the unique elements of Ω

ym$w1,,ym$wK

vectors containing the draws from the posterior of the parameters associated with the exogenous variables w1,,wK, for m = 1,2,,M (the names of these vectors are the names of the exogenous variables that were included in the model, prepended by ym$, where ym is the name of the dependent variable in equation m)

ym$yl_tms,

vectors containing the draws from the posterior of the parameters associated with the lags of the endogenous variables for m,l = 1,2,,M (the names of these vectors are the names of the exogenous variables, appended by _tms, where s is the sth lag, and prepended by ym$, where ym is the name of the dependent variable in equation m)

Omega_i_j

vectors containing the draws from the posterior of the unique elements of Ω; because Ω is symmetric, only M1M 2 + M of its elements are stored (instead of all M2 elements); i and j index the row and column of Ω, respectively, at which the corresponding element is located

Omega

M ×M matrix that stores the posterior mean of Ω

logML

the Lewis & Raftery (1997) approximation of the log-marginal likelihood

logML_CJ

the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood; this is available only if the model was estimated with the "logML_CJ"=true option

nchains

the number of chains that were used to estimate the model

nburnin

the number of burn-in draws per chain that were used when estimating the model

ndraws

the total number of retained draws from the posterior ( =chains draws)

nthin

value of the thinning parameter that was used when estimating the model

nseed

value of the seed for the random-number generator that was used when estimating the model

Additionally, the following functions are available for post-estimation analysis (see section B.14):

Examples

Example 1

myData = import("$BayESHOME/Datasets/dataset6.csv", ","); 
myData.constant = 1; 
set_ts( time, "dataset"=myData); 
 
varm( {y1,y2,y3} ~ constant w );

Example 2

myData = import("$BayESHOME/Datasets/dataset6.csv", ","); 
myData.constant = 1; 
set_ts( time, "dataset"=myData); 
 
myModel = varm( {y1,y2,y3} ~ constant w ); 
 
forecast( "horizon"=10, "model"=myModel ); 
 
irf( "horizon"=20, "model"=myModel );

1Optional arguments are always given in option-value pairs (eg. "chains"=3).

Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis