varmapack_model: Create a VARMA or VARMAX model

View source: R/model.R

varmapack_modelR Documentation

Create a VARMA or VARMAX model

Description

Create a model object for simulation of a Gaussian VAR, VMA, VARMA, or VARMAX time series. The object stores model parameters and provides a ⁠$sim()⁠ method for generating one or more independent series.

Usage

varmapack_model(A = NULL, B = NULL, C = NULL, Sig, mu = NULL)

Arguments

A

Autoregressive coefficient matrices as an r by r matrix or an r by r by p array. NULL gives no autoregressive terms.

B

Moving-average coefficient matrices as an r by r matrix or an r by r by q array. NULL gives no moving-average terms.

C

Exogenous coefficient matrices as an r by d matrix or an r by d by s array. NULL gives a VARMA model rather than VARMAX.

Sig

r by r innovation covariance matrix.

mu

Optional r vector or r by nmu matrix of time-series means. The last mean vector repeats for the rest of each series. Means are not supported for VARMAX models.

Value

A VarmapackModel object.

Simulation

model$sim(length, nrep = 1L, X0 = NULL, z = NULL, rng = NULL, return_shocks = FALSE) simulates nrep independent series of the supplied length.

For VARMA models, X0 is optional. If provided, it is an r by nX0 matrix or an r by nX0 by nrep array. Its second dimension must be at least max(p, q), and its third dimension, when present, must be 1 or nrep. Nonstationary VARMA models require X0; with MA terms, Sig must be positive definite and startup shocks are conditioned on the residual equations implied by the supplied history.

For VARMAX models, z is required. X0 has the same form and its second dimension must be at least max(p, q, s - 1). It may be omitted when this minimum is zero. The exogenous input z is a d by length matrix or a d by length by nrep array. Its third dimension, when present, must be 1 or nrep.

Pass a randompack::randompack_rng() object through rng to control the random stream. When it is omitted, Varmapack uses a temporary randomized default Randompack generator. With return_shocks = FALSE, the result is an r by length by nrep array. With return_shocks = TRUE, it is a list with components X and E, each with that shape.

Model analysis

model$acvf(maxlag) returns theoretical VARMA autocovariances, model$psi(maxlag) returns impulse-response matrices, and model$irf(maxlag) returns orthogonalized impulse-response matrices. model$specrad() and model$ma_specrad() return the AR and MA spectral radii, respectively. Theoretical autocovariances are not available for VARMAX models with exogenous terms.

Examples

A <- matrix(c(0.4, 0.1, -0.2, 0.3), 2, 2)
model <- varmapack_model(A = A, Sig = diag(2))
X <- model$sim(100)

rng <- randompack::randompack_rng()
rng$seed(123)
X <- model$sim(100, nrep = 3, rng = rng)


varmapack documentation built on Nov. 19, 2026, 5:09 p.m.