VARsim | R Documentation |
This function simulates VAR(p) series. For quick use, the function can use the estimated
model returned by VARfit
or vars::VAR
as
the DGP (Data Generating Process), if passed to the fittedModel
argument.
VARsim(N = 200, K = 2, p = 1, const = TRUE, trend = FALSE, exogen = NULL,
coef = NULL, dist = "normal", Ystart = NULL, errors = NULL, fittedModel = NULL)
N |
The length of the series. |
K |
The number of series/equations. |
p |
The lag length of the VAR(p). |
const |
if |
trend |
if |
exogen |
a matrix of exogenous variables. Should either have |
coef |
a matrix of coefficients.
E.g. a 2 dimensional VAR(2) with a constant, a trend and one exogenous variable must be entered in the following order (the same as returned by
|
dist |
the distribution of the error terms (currently only |
Ystart |
a |
errors |
(optional) a matrix of error terms. If supplied, |
fittedModel |
(optional) either an object of class |
an N
x K
matrix of the simulated VAR(p
).
# Simulates from a fitted DGP:
fit <- VARfit(y = VodafoneCDS, p = 1, const = TRUE)
y <- VARsim(fittedModel = fit)
VARfit(y = y, p = 1, const = TRUE)
# Simulates from user given parameters.
# Includes an exogenous variable:
VARcoef <- matrix(c(1, 2,
1, 0.5,
0.1, 0.3,
0.2, 0.5),
ncol = 2, byrow = TRUE)
exo <- matrix(rnorm(500))
y <- VARsim(N = 500, K = 2, p = 1, const = TRUE,
trend = FALSE, exogen = exo,
coef = VARcoef, dist = "normal")
VARfit(y = y, p = 1, const = TRUE, exogen = exo)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.