Skip to contents

Recursively generates VAR data from initial values, coefficients, and residuals. Optimised for maximum performance and memory efficiency.

Usage

fgenerateVARdata(y, p, c, beta, residuals)

Arguments

y

T x N matrix of initial/historical endogenous variables.

p

Integer lag order of the VAR model.

c

Integer indicator for intercept (1 if included, 0 otherwise).

beta

Coefficient matrix: (Np+c) x N if c = 1, or Np x N if c = 0.

residuals

(T-p) x N matrix of residuals/shocks to add.

Value

T x N matrix of generated VAR data. The first p rows are copied from y; the remaining T-p rows are generated recursively.

Details

The recursion follows: $$y_t = c + A_1 y_{t-1} + \cdots + A_p y_{t-p} + e_t$$

Examples

if (FALSE) { # \dontrun{
y_init    <- matrix(rnorm(200), ncol = 2)
beta      <- matrix(rnorm(10), 5, 2)
residuals <- matrix(rnorm(190), 95, 2)
y_new     <- fgenerateVARdata(y_init, p = 2, c = 1, beta, residuals)
} # }