simVAR {bigtime}R Documentation

Simulates a VAR(p) with various sparsity patterns

Description

Simulates a VAR(p) with various sparsity patterns

Usage

simVAR(
  periods,
  k,
  p,
  coef_mat = NULL,
  const = rep(0, k),
  e_dist = rnorm,
  init_y = rep(0, k * p),
  max_abs_eigval = 0.8,
  burnin = periods,
  sparsity_pattern = c("none", "lasso", "L1", "hvar", "HLag"),
  sparsity_options = NULL,
  decay = 1/p,
  seed = NULL,
  ...
)

Arguments

periods

Scalar indicating the desired time series length

k

Number of time series

p

Maximum lag number. In case of sparsity_patter="none" this will be the actual number of lags for all variables

coef_mat

Coefficient matrix in companion form. If not provided, one will be simulated

const

Constant term of VAR. Default is zero. Must be either a scalar, in which case it will be broadcasted to a k-vector, or a k-vector

e_dist

Either a function taking argument n indicating the number of variables in the system, or a matrix of dimensions k x (periods+burnin)

init_y

Initial values. Defaults to zero. Expects either a scalar or a vector of length (k*p)

max_abs_eigval

Maximum allowed eigenvalue of companion matrix. Only applicable if coefficient matrix is being simulated

burnin

Number of time points to be used for burnin

sparsity_pattern

The sparsity pattern that should be simulated. Options are: "none" for a dense VAR, "lasso" (or "L1") for a VAR with random zeroes, and "hvar" (or "HLag") for an elementwise hierarchical sparsity pattern

sparsity_options

Named list of additional options for when sparsity pattern is lasso (L1) or hvar (HLag). For lasso (L1) the option num_zero determines the number of zeros. For hvar (HLag), the options zero_min (zero_max) give the minimum (maximum) of zeroes for each variable in each equation, and the option zeroes_in_self (boolean) determines if any of the coefficients of a variable on itself should be zero.

decay

How much smaller should parameters for later lags be. The smaller, the larger will early parameters be w.r.t. later ones.

seed

Seed to be used for the simulation

...

Additional arguments passed to e_dist

Value

Returns an object of S3 class bigtime.simVAR containing the following

Y

Simulated Data

periods

Time series length

k

Number of endogenous variables

p

Maximum lag length; effective lag length might be shorter due to sparsity patterns

coef_mat

Companion form of the coefficient matrix. Will be of dimensions (kp)x(kp). First k rows correspond to the actual coefficient matrix.

is_coef_mat_simulated

TRUE if the coef_mat was simulated, FALSE if it was user provided

const

Constant term

e_dist

Errors used in the construction of the data

init_y

Initial conditions

max_abs_eigval

Maximum eigenvalue to which the companion matrix was constraint

burnin

Burnin period used

sparsity_pattern

Sparsity pattern used

sparsity_options

Extra options for the sparsity patterns used

seed

Seed used for the simulation

Examples

periods <- 200 # time series length
k <- 5 # number of variables
p <- 10 # maximum lag
sparsity_pattern <- "HLag" # HLag sparsity structure
sparsity_options <- list(zero_min = 0, # variables can be included with all lags
                         zero_max = 10, # but some could also include no lags
                         zeroes_in_self = TRUE)
sim <- simVAR(periods=periods, k=k, p=p, sparsity_pattern=sparsity_pattern,
              sparsity_options=sparsity_options, seed = 12345)
summary(sim)

[Package bigtime version 0.2.3 Index]