Skip to contents

This function generates synthetic time series data from a Vector Autoregressive (VAR) model with exogenous variables.

Usage

SimVARExo(time, burn_in, constant, coef, chol_cov, exo_mat, exo_coef)

Arguments

time

Integer. Number of time points to simulate.

burn_in

Integer. Number of burn-in observations to exclude before returning the results.

constant

Numeric vector. The constant term vector of length k, where k is the number of variables.

coef

Numeric matrix. Coefficient matrix with dimensions k by (k * p). Each k by k block corresponds to the coefficient matrix for a particular lag.

chol_cov

Numeric matrix. The Cholesky decomposition of the covariance matrix of the multivariate normal noise. It should have dimensions k by k.

exo_mat

Numeric matrix. Matrix of exogenous covariates with dimensions time + burn_in by x. Each column corresponds to a different exogenous variable.

exo_coef

Numeric vector. Coefficient matrix with dimensions k by x associated with the exogenous covariates.

Value

Numeric matrix containing the simulated time series data with dimensions k by time, where k is the number of variables and time is the number of observations.

See also

Other Simulation of Autoregressive Data Functions: BootCI(), BootSE(), SelectVARLasso(), SimVAR(), YXExo(), YX()

Author

Ivan Jacob Agaloos Pesigan

Examples

set.seed(42)
time <- 1000L
burn_in <- 200
k <- 3
p <- 2
constant <- c(1, 1, 1)
coef <- matrix(
  data = c(
    0.4, 0.0, 0.0, 0.1, 0.0, 0.0,
    0.0, 0.5, 0.0, 0.0, 0.2, 0.0,
    0.0, 0.0, 0.6, 0.0, 0.0, 0.3
  ),
  nrow = k,
  byrow = TRUE
)
chol_cov <- chol(diag(3))
exo_mat <- MASS::mvrnorm(
  n = time + burn_in,
  mu = c(0, 0, 0),
  Sigma = diag(3)
)
exo_coef <- matrix(
  data = c(
    0.5, 0.0, 0.0,
    0.0, 0.5, 0.0,
    0.0, 0.0, 0.5
  ),
  nrow = 3
)
y <- SimVARExo(
  time = time,
  burn_in = burn_in,
  constant = constant,
  coef = coef,
  chol_cov = chol_cov,
  exo_mat = exo_mat,
  exo_coef = exo_coef
)
str(y)
#>  num [1:1000, 1:3] 5.03 3.4 2.73 2.89 1.61 ...