Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gen_var

Vector Autoregressive Model Input


Description

gen_var produces the input for the estimation of a vector autoregressive (VAR) model.

Usage

gen_var(
  data,
  p = 2,
  exogen = NULL,
  s = NULL,
  deterministic = "const",
  seasonal = FALSE,
  structural = FALSE,
  iterations = 50000,
  burnin = 5000
)

Arguments

data

a time-series object of endogenous variables.

p

an integer vector of the lag order (default is p = 2).

exogen

an optional time-series object of external regressors.

s

an optional integer vector of the lag order of the external regressors (default is s = 2).

deterministic

a character specifying which deterministic terms should be included. Available values are "none", "const" (default) for an intercept, "trend" for a linear trend, and "both" for an intercept with a linear trend.

seasonal

logical. If TRUE, seasonal dummy variables are generated as additional deterministic terms. The amount of dummies depends on the frequency of the time-series object provided in data.

structural

logical indicating whether data should be prepared for the estimation of a structural VAR model.

iterations

an integer of MCMC draws excluding burn-in draws (defaults to 50000).

burnin

an integer of MCMC draws used to initialize the sampler (defaults to 5000). These draws do not enter the computation of posterior moments, forecasts etc.

Details

The function produces the data matrices for vector autoregressive (VAR) models, which can also include unmodelled, non-deterministic variables:

A_0 y_t = ∑_{i=1}^{p} A_i y_{t - i} + ∑_{i=0}^{s} B_i x_{t - i} + C D_t + u_t,

where y_t is a K-dimensional vector of endogenous variables, A_0 is a K \times K coefficient matrix of contemporaneous endogenous variables, A_i is a K \times K coefficient matrix of endogenous variables, x_t is an M-dimensional vector of exogenous regressors and B_i its corresponding K \times M coefficient matrix. D_t is an N-dimensional vector of deterministic terms and C its corresponding K \times N coefficient matrix. p is the lag order of endogenous variables, s is the lag order of exogenous variables, and u_t is an error term.

If an integer vector is provided as argument p or s, the function will produce a distinct model for all possible combinations of those specifications.

Value

An object of class 'bvarmodel', which contains the following elements:

data

A list of data objects, which can be used for posterior simulation. Element Y is a time-series object of dependent variables. Element Z is a time-series object of the regressors and element SUR is the corresponding matrix of regressors in SUR form.

model

A list of model specifications.

References

Lütkepohl, H. (2006). New introduction to multiple time series analysis (2nd ed.). Berlin: Springer.

Examples

# Load data
data("e1") 
e1 <- diff(log(e1))

# Generate model data
data <- gen_var(e1, p = 0:2, deterministic = "const")

bvartools

Bayesian Inference of Vector Autoregressive Models

v0.2.0
GPL (>= 2)
Authors
Franz X. Mohr [aut, cre]
Initial release
2021-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.