11.1 Vector Autoregressive (VAR) model for time-series data
Mathematical representation
where:
- the model contains endogenous variables (s)
- the model is estimated using observations ()
- is an vector, which contains the values of the endogenous variables at time
- is a vector, which contains the values of the exogenous variables (common to all equations) at time
- is an matrix of parameters associated with the exogenous variables
- is an matrix of parameters,
- in total, there are slope parameters to be estimated (in all s)
- is an vector of errors at time , which follows a multivariate Normal distribution with mean and precision matrix
With time observations, an equivalent representation of the model is:
where:
and:
In this representation the endogenous variables are expanded over the columns of and the time observations are stacked one under the other.
Yet another representation is:
where:
- is the obtained by stacking the columns of
- is the obtained by stacking the columns of
- is the vector obtained by stacking the columns of
In this representation the data are first stacked over time and then by variable.
Priors
Parameter | Probability density function | Default hyperparameters |
, | ||
, | ||
Syntax
where:
- y1, y2, …, yM are the names of the endogenous variables, as they appear in the dataset used for estimation
- w1 w2 wK is a list of the exogenous variable names, as they appear in the dataset used for estimation; these variables will be included in all equations, but if there is need to restrict the model so that of any of them do not appear in an equation, this can be achieved by restricting the associated parameters in the prior; when a constant term is to be included in the model, this must be requested explicitly
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 ( vector); the default value is |
"P" | precision matrix of the prior for ( symmetric and positive-definite matrix); the default value is |
"V" | scale matrix of the prior for ( symmetric and positive-definite matrix); the default value is |
"n" | degrees-of-freedom parameter of the prior for (real number greater than or equal to ); the default value is |
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 (truefalse); 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 (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 ) |
ym$yl_tms, | vectors containing the draws from the posterior of the parameters associated with the lags of the endogenous variables for (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 ) |
Omega_i_j | vectors containing the draws from the posterior of the unique elements of ; because is symmetric, only of its elements are stored (instead of all elements); i and j index the row and column of , respectively, at which the corresponding element is located |
Omega | 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):
- diagnostics()
- test()
- pmp()
- forecast()
- irf()
Examples
Example 1
myData.constant = 1;
set_ts( time, "dataset"=myData);
varm( {y1,y2,y3} ~ constant w );
Example 2
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).