| Title: | Burn-in-Free Simulation and Analysis of Gaussian VARMA Models |
|---|---|
| Description: | Simulates Gaussian vector autoregressive-moving-average time-series models without a burn-in period by drawing startup shocks from their model-implied conditional distribution. Also provides model test cases, autocovariances, spectral radii, and impulse responses. |
| Authors: | Kristján Jónasson [aut, cre] |
| Maintainer: | Kristján Jónasson <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-09-16 06:27:59 UTC |
| Source: | https://github.com/cran/varmapack |
Compute sample autocovariance matrices up to a specified lag for a numeric time-series matrix with variables in rows and observations in columns.
varmapack_autocov(X, maxlag, norm = "ML")varmapack_autocov(X, maxlag, norm = "ML")
X |
Numeric |
maxlag |
Largest lag to compute, between zero and |
norm |
Either |
An r by r by maxlag + 1 array. Its k + 1 plane estimates
Cov(x_t, x_{t-k}).
X <- rbind(1:10, (1:10)^2) varmapack_autocov(X, maxlag = 2)X <- rbind(1:10, (1:10)^2) varmapack_autocov(X, maxlag = 2)
Convert a covariance matrix or sequence of autocovariance matrices to correlations using the marginal standard deviations at lag zero.
varmapack_cov2corr(cov)varmapack_cov2corr(cov)
cov |
A finite numeric |
A numeric array with the same dimensions as cov. Lag-zero
diagonal entries are exactly one. Other entries are not clipped to
[-1,1].
cov <- array(c(4, 3, 3, 9, 2, 6, -3, 1.5), dim = c(2, 2, 2)) varmapack_cov2corr(cov)cov <- array(c(4, 3, 3, 9, 2, 6, -3, 1.5), dim = c(2, 2, 2)) varmapack_cov2corr(cov)
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.
varmapack_model(A = NULL, B = NULL, C = NULL, Sig, mu = NULL)varmapack_model(A = NULL, B = NULL, C = NULL, Sig, mu = NULL)
A |
Autoregressive coefficient matrices as an |
B |
Moving-average coefficient matrices as an |
C |
Exogenous coefficient matrices as an |
Sig |
|
mu |
Optional |
A VarmapackModel object.
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$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.
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)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)
Create a built-in named testcase or an unnamed random, deterministic, or spectral-radius-controlled VARMA testcase.
varmapack_testcase( which = "random", p = NULL, q = NULL, r = NULL, rho = 0, rng = NULL )varmapack_testcase( which = "random", p = NULL, q = NULL, r = NULL, rho = 0, rng = NULL )
which |
A built-in testcase name, a one-based built-in testcase index,
or one of |
p, q, r
|
Required AR order, MA order, and series dimension for unnamed testcases. |
rho |
Target spectral radius when |
rng |
Optional |
A VarmapackModel object.
model <- varmapack_testcase("smallARMA1") model <- varmapack_testcase("rho", p = 3, q = 1, r = 2, rho = 0.8)model <- varmapack_testcase("smallARMA1") model <- varmapack_testcase("rho", p = 3, q = 1, r = 2, rho = 0.8)
List named VARMA testcases
varmapack_testcases()varmapack_testcases()
A data frame with columns index, name, p, q, and r.
varmapack_testcases()varmapack_testcases()