| Type: | Package |
| Title: | Burn-in-Free Simulation and Analysis of Gaussian VARMA Models |
| Version: | 0.1.1 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.0.0) |
| Imports: | R6, randompack (≥ 0.1.10) |
| LinkingTo: | randompack |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.2 |
| URL: | https://github.com/jonasson2/varmapack |
| BugReports: | https://github.com/jonasson2/varmapack/issues |
| NeedsCompilation: | yes |
| Packaged: | 2026-09-01 05:31:26 UTC; jonasson |
| Author: | Kristján Jónasson [aut, cre] |
| Maintainer: | Kristján Jónasson <jonasson@hi.is> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-12 07:10:03 UTC |
Varmapack: Exact-Start Simulation of Gaussian VARMA Models
Description
An R interface to the Varmapack C library for simulation and analysis of Gaussian VAR, VMA, VARMA, and VARMAX models.
Author(s)
Maintainer: Kristján Jónasson jonasson@hi.is
See Also
-
vignette("getting-started", package = "varmapack")for a tutorial. -
vignette("mathematical-description", package = "varmapack")for the mathematical description.
Sample autocovariances of an observed series
Description
Compute sample autocovariance matrices up to a specified lag for a numeric time-series matrix with variables in rows and observations in columns.
Usage
varmapack_autocov(X, maxlag, norm = "ML")
Arguments
X |
Numeric |
maxlag |
Largest lag to compute, between zero and |
norm |
Either |
Value
An r by r by maxlag + 1 array. Its k + 1 plane estimates
Cov(x_t, x_{t-k}).
Examples
X <- rbind(1:10, (1:10)^2)
varmapack_autocov(X, maxlag = 2)
Convert covariances to correlations
Description
Convert a covariance matrix or sequence of autocovariance matrices to correlations using the marginal standard deviations at lag zero.
Usage
varmapack_cov2corr(cov)
Arguments
cov |
A finite numeric |
Value
A numeric array with the same dimensions as cov. Lag-zero
diagonal entries are exactly one. Other entries are not clipped to
[-1,1].
Examples
cov <- array(c(4, 3, 3, 9, 2, 6, -3, 1.5), dim = c(2, 2, 2))
varmapack_cov2corr(cov)
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 |
B |
Moving-average coefficient matrices as an |
C |
Exogenous coefficient matrices as an |
Sig |
|
mu |
Optional |
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)
Create a VARMA testcase model
Description
Create a built-in named testcase or an unnamed random, deterministic, or spectral-radius-controlled VARMA testcase.
Usage
varmapack_testcase(
which = "random",
p = NULL,
q = NULL,
r = NULL,
rho = 0,
rng = NULL
)
Arguments
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 |
Value
A VarmapackModel object.
Examples
model <- varmapack_testcase("smallARMA1")
model <- varmapack_testcase("rho", p = 3, q = 1, r = 2, rho = 0.8)
List named VARMA testcases
Description
List named VARMA testcases
Usage
varmapack_testcases()
Value
A data frame with columns index, name, p, q, and r.
Examples
varmapack_testcases()