VAR.boot: Simulate or bootstrap a VAR model

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/VAR.sim.R

Description

Allow to either simulate from scratch (by providing coefficients) or bootstrap from an estimated VAR model,

Usage

1
2
3
4
5
6
7
VAR.sim(B, n = 200, lag = 1, include = c("const", "trend", "none",
  "both"), starting = NULL, innov = rmnorm(n, varcov = varcov),
  varcov = diag(1, nrow(B)), show.parMat = FALSE, returnStarting = FALSE,
  ...)

VAR.boot(VARobject, boot.scheme = c("resample", "wild1", "wild2", "check"),
  seed, ...)

Arguments

B

Matrix of coefficients.

n

Number of observations to simulate

lag

Number of lags of the VAR to simulate

include

Type of deterministic regressors to include in the VAR to simulate

starting

Starting values (matrix of dimension lag x k) for the VAR to simulate. If not given, set to zero.

innov

Innovations used for in the VAR to simulate. Should be matrix of dim n x k. By default multivariate normal.

varcov

Variance-covariance matrix for the innovations. By default identity matrix.

show.parMat

Logical. Should the parameter matrix be shown? Useful to understand how to give right input

returnStarting

Whether starting values are returned. Default to FALSE

...

Further arguments passed to the underlying (un-exported) VAR.gen function

VARobject

Object of class VAR generated by function lineVar

boot.scheme

The bootstrap scheme. See details.

seed

Optional. Seed for the random resampling function.

Details

For the bootstrap, the function resamples data from a given VAR model generated by lineVar, returning the resampled data. A residual recursive bootstrap is used, where one uses either a simple resampling, or the Wild bootstrap, either with a normal distribution (wild1) or inverting the sign randomly (wild2)

Value

A matrix with the resampled series.

Author(s)

Matthieu Stigler

See Also

lineVar to estimate the VAR. Similar TVECM.sim and TVECM.boot for TVECM, TVAR.sim and TVAR.boot for TVAR models.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## VAR.sim: simulate VAR as in Enders 2004, p 268
B1<-matrix(c(0.7, 0.2, 0.2, 0.7), 2)
var1 <- VAR.sim(B=B1, n=100, include="none")
ts.plot(var1, type="l", col=c(1,2))


B2<-rbind(c(0.5, 0.5, 0.5), c(0, 0.5, 0.5))
varcov<-matrix(c(1,0.2, 0.3, 1),2)
var2 <- VAR.sim(B=B2, n=100, include="const", varcov=varcov)
ts.plot(var2, type="l", col=c(1,2))

## VAR.boot: Bootstrap a VAR 
data(zeroyld)
mod <- lineVar(data=zeroyld,lag=1)
VAR.boot(mod)

tsDyn documentation built on June 4, 2018, 1:04 a.m.