TVECM.sim: Simulation and bootstrap a VECM or bivariate TVECM

View source: R/TVECM.gen.R

TVECM.simR Documentation

Simulation and bootstrap a VECM or bivariate TVECM

Description

Estimate or bootstraps a multivariate Threshold VAR

Usage

TVECM.sim(
  B,
  n = 200,
  lag = 1,
  include = c("const", "trend", "none", "both"),
  beta,
  nthresh = 1,
  Thresh,
  starting = NULL,
  innov = rmnorm(n, varcov = diag(1, nrow(B))),
  show.parMat = FALSE,
  returnStarting = FALSE,
  ...
)

VECM.sim(
  B,
  n = 200,
  lag = 1,
  include = c("const", "trend", "none", "both"),
  beta,
  starting = NULL,
  innov = rmnorm(n, varcov = diag(1, nrow(B))),
  show.parMat = FALSE,
  returnStarting = FALSE,
  ...
)

VECM.boot(
  object,
  boot.scheme = c("resample", "resample_block", "wild1", "wild2", "check"),
  seed = NULL,
  ...
)

TVECM.boot(
  object,
  boot.scheme = c("resample", "resample_block", "wild1", "wild2", "check"),
  seed = NULL,
  ...
)

Arguments

B

Simulation: Matrix of coefficients to simulate

n

Simulation: Number of observations to simulate.

beta

The cointegrating value

Thresh, nthresh, lag, include

Simulation: parameters for the VECM/TVECM to simulate. See TVECM for their description.

starting

Simulation: Starting values (same length as lag = 1)

innov

Simulation: time series of innovations/residuals.

show.parMat

Logical. Whether to show how the parameter matrix B is interpreted.

returnStarting

Logical. Whether to return the starting values.

...

additional arguments for the unexported TVECM.gen.

object

Object computed by function TVECM or linear VECM

boot.scheme

Bootstrap: which resampling scheme to use for the residuals. See resample_vec.

seed

Bootstrap: seed used in the resampling

Details

This function offers the possibility to generate series following a VECM/TVECM from two approaches: bootstrap or simulation. VECM.sim is just a wrapper for TVECM.sim.

When the argument matrix is given, on can only simulate a VECM (nthresh=0) or TVECM (nthresh=1 or 2). One can have a specification with constant ("const"), "trend", "both" or "none" (see argument include). Order for the parameters is ECT/include/lags for VECM and ECT1/include1/lags1/ECT2/include2/lags2 for TVECM. To be sure that once is using it correctly, setting show.parMat = TRUE will show the matrix of parameters together with their values and names.

The argument beta is the cointegrating value on the right side of the long-run relationship, and hence the function use the vector (1,-beta). The innov argument specifies the innovations. It should be given as a matrix of dim nxk, (here n does not include the starting values!), by default it uses a multivariate normal distribution, with covariance matrix specified by varcov.

The starting values (of dim lags x k) can be given through argument starting. The user should take care for their choice, since it is not sure that the simulated values will cross the threshold even once. Notice that only one cointegrating value is allowed. User interested in simulating a VECM with more cointegrating values should do use the VAR representation and use TVAR.sim.

The second possibility is to bootstrap series. This is done on a object generated by TVECM (or VECM). A simple residual bootstrap is done, or one can simulate a series with the same parameter matrix and with normal distributed residuals (with variance pre-specified), corresponding to Monte-carlo simulations.

One can alternatively give only the series, and then the function will call internally TVECM.

Value

A matrix with the simulated/bootstrapped series.

Author(s)

Matthieu Stigler

See Also

VECM or TVECM to estimate the VECM or TVECM. Similar TVAR.sim and TVAR.boot for TVAR, VAR.sim and VAR.boot for VAR models estimated with lineVar models.

Examples



###reproduce example in Enders (2004, 2 edition) p. 350, 
# (similar example in Enders (2010, 3 edition) 301-302). 

if(require(mnormt)){
#see that the full "VAR" coefficient matrix is:
 A <- matrix(c(-0.2, 0.2, 0.2, -0.2), byrow=TRUE, ncol=2)

# but this is not the input of VECM.sim. You should decompose into the a and b matrix:
 a<-matrix(c(-0.2, 0.2), ncol=1)
 b<-matrix(c(1,-1), nrow=1)

# so that:
 a%*%b

# The a matrix is the input under argument B, while the b matrix is under argument beta: 
# (the other zeros in B are for the not-specified lags)
 innov<-rmnorm(100, varcov=diag(2))
 Bvecm <- rbind(c(-0.2, 0,0), c(0.2, 0,0))
 vecm1 <- VECM.sim(B=Bvecm, beta=1,n=100, lag=1,include="none", innov=innov)
 ECT <- vecm1[,1]-vecm1[,2]

#add an intercept as in panel B
 Bvecm2 <- rbind(c(-0.2, 0.1,0,0), c(0.2,0.4, 0,0))
 vecm2 <- VECM.sim(B=Bvecm2,  n=100,beta=1, lag=1,include="const", innov=innov)

 par(mfrow=c(2,1))
 plot(vecm1[,1], type="l", main="Panel a: no drift or intercept", ylab="", xlab="")
 lines(vecm1[,2], lty=2)
 plot(vecm2[,1], type="l", main="Panel b: drift terms (0.1)", ylab="", xlab="")
 lines(vecm2[,2], lty=2)
}
##Bootstrap a TVAR with 1 threshold (two regimes)
data(zeroyld)
TVECMobject <- TVECM(zeroyld, nthresh=1, lag=1, ngridBeta=20, ngridTh=20, plot=FALSE, trace = FALSE)
TVECM.boot(TVECMobject)

##Check the bootstrap: do we get original series, when not resampling residuals?
TVECM.boot.check <- TVECM.boot(TVECMobject, boot.scheme = "check")
all.equal(as.data.frame(TVECM.boot.check), zeroyld)


tsDyn documentation built on Feb. 16, 2023, 6:57 p.m.