setar.sim {tsDyn}R Documentation

Simulation and bootstrap of Treshold Autoregressive model

Description

Simulate or bootstrap a Threshold VAR

Usage

setar.sim(data,B, setarObject, n=200, lag=1, trend=TRUE, nthresh=0, thDelay=0, Thresh, type=c("boot", "simul", "check"), starting=NULL, rand.gen = rnorm, innov = rand.gen(n, ...),...)

Arguments

data univariate time series
B vector of coefficients to simulate
setarObject Object of class linear or setar to be bootstrapped
n Number of observations to create when type="simul"
Thresh The threshold value(s). Vector of length nthresh
nthresh number of threshold (see details)
lag Number of lags to include in each regime
type Whether a bootstrap or simulation is to employ. See details
trend If a trend should be included in the model
thDelay 'time delay' for the threshold variable (as multiple of embedding time delay d).
starting Starting values when a simulation with given parameter matrix is made
rand.gen optional: a function to generate the innovations.
innov an optional times series of innovations. If not provided, rand.gen is used.
... additional arguments for rand.gen. Most usefully, the standard deviation of the innovations generated by rnorm can be specified by sd.

Details

This function offers the possibility to generate series following a TAR from two approaches: bootstrap or simulation. When the data is given, one can use a simple residual bootstrap or simulate a serie from the parameter matrix and with normal distributed residuals (with variance pre-specified). The choice "check" is just there to check the function: one should obtain the same values as the given values. Please report if different. When the parameter matrix is given, there is only the possibility to simulate series. The starting values (of length equal to the number of lags) can be given. The user should take care for the choice of the starting values and parameters values, since it is not sure that the simulated values will cross the threshold even once.

Value

a list with the simulated/bootstraped data and the parameter matrix used.

Author(s)

Matthieu Stigler

References

TODO

See Also

TODO

Examples

##Simulation of a TAR with 1 threshold
sim<-setar.sim(B=c(2.9,-0.4,-0.1,-1.5, 0.2,0.3),lag=2, type="simul", nthresh=1, Thresh=2, starting=c(2.8,2.2))$serie
mean(ifelse(sim>2,1,0)) #approximation of values over the threshold

#check the result
selectSETAR(sim, m=2)

##Bootstrap a TAR with two threshold (three regimes)
sun<-(sqrt(sunspot.year+1)-1)*2
setar.sim(data=sun,nthresh=2,n=500, type="boot", Thresh=c(6,9))$serie

##Check the bootstrap
cbind(setar.sim(data=sun,nthresh=2,n=500, type="check", Thresh=c(6,9))$serie,sun)

[Package tsDyn version 0.7-1 Index]