gen_var {bvartools} | R Documentation |
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,
tvp = FALSE,
sv = FALSE,
fcst = NULL,
iterations = 50000,
burnin = 5000
)
Arguments
data |
a time-series object of endogenous variables. |
p |
an integer vector of the lag order (default is |
exogen |
an optional time-series object of external regressors. |
s |
an optional integer vector of the lag order of the external regressors (default is |
deterministic |
a character specifying which deterministic terms should
be included. Available values are |
seasonal |
logical. If |
structural |
logical indicating whether data should be prepared for the estimation of a structural VAR model. |
tvp |
logical indicating whether the model parameters are time varying. |
sv |
logical indicating whether time varying error variances should be estimated by employing a stochastic volatility algorithm. |
fcst |
integer. Number of observations saved for forecasting evaluation. |
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:
where
is a K-dimensional vector of endogenous variables,
is a
coefficient matrix of contemporaneous endogenous variables,
is a
coefficient matrix of endogenous variables,
is an M-dimensional vector of exogenous regressors and
its corresponding
coefficient matrix.
is an N-dimensional vector of deterministic terms and
its corresponding
coefficient matrix.
is the lag order of endogenous variables,
is the lag
order of exogenous variables, and
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.
If tvp
is TRUE
, the respective coefficients
of the above model are assumed to be time varying. If sv
is TRUE
,
the error covariance matrix is assumed to be time varying.
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
|
model |
A list of model specifications. |
References
Chan, J., Koop, G., Poirier, D. J., & Tobias, J. L. (2019). Bayesian Econometric Methods (2nd ed.). Cambridge: University Press.
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")