simtar {mtarm} | R Documentation |
Simulation of multivariate time series according to a TAR model
Description
This function simulates multivariate time series according to a user-specified TAR model.
Usage
simtar(
n,
k = 2,
ars = list(p = 1),
Intercept = TRUE,
parms,
delay = 0,
thresholds = 0,
t.series,
ex.series,
dist = "gaussian",
extra
)
Arguments
n |
a positive integer value indicating the length of the desired output series. |
k |
a positive integer value indicating the dimension of the desired output series. |
ars |
a list composed of three objects, namely: |
Intercept |
an (optional) logical variable. If |
parms |
a list with as many sublists as regimes in the user-specified TAR model. Each sublist is composed of two matrices. The first corresponds to location parameters, while the second corresponds to scale parameters. |
delay |
an (optional) non-negative integer value indicating the delay in the threshold series. |
thresholds |
a vector with |
t.series |
a matrix with the values of the threshold series. |
ex.series |
a matrix with the values of the multivariate exogenous series. |
dist |
an (optional) character string which allows the user to specify the multivariate
distribution to be used to describe the behavior of the noise process. The
available options are: Gaussian ("Gaussian"), Student- |
extra |
a value indicating the value of the extra parameter of the noise process distribution, if any. |
Value
a data.frame
containing the output series, threshold series (if any), and multivariate exogenous series (if any).
Examples
###### Simulation of a trivariate TAR model with two regimes
n <- 2000
k <- 3
ars <- list(p=c(1,2))
Z <- as.matrix(arima.sim(n=n+max(ars$p),list(ar=c(0.5))))
Intercept <- TRUE
parms <- list()
for(i in 1:length(ars$p)){
np <- Intercept + ars$p[i]*k
parms[[i]] <- list()
parms[[i]]$location <- c(ifelse(runif(np*k)<=0.5,1,-1)*rbeta(np*k,shape1=4,shape2=16))
parms[[i]]$location <- matrix(parms[[i]]$location,np,k)
parms[[i]]$scale <- rgamma(k,shape=1,scale=1)*diag(k)
}
thresholds <- quantile(Z,probs=seq(1,length(ars$p)-1)/length(ars$p))
out1 <- simtar(n=n,k=k,ars=ars,Intercept=Intercept,parms=parms,
thresholds=thresholds,t.series=Z,dist="Student-t",extra=6)
str(out1)
###### Simulation of a trivariate VAR model
n <- 2000
k <- 3
ars <- list(p=2)
Intercept <- TRUE
parms <- list()
for(i in 1:length(ars$p)){
np <- Intercept + ars$p[i]*k
parms[[i]] <- list()
parms[[i]]$location <- c(ifelse(runif(np*k)<=0.5,1,-1)*rbeta(np*k,shape1=4,shape2=16))
parms[[i]]$location <- matrix(parms[[i]]$location,np,k)
parms[[i]]$scale <- rgamma(k,shape=1,scale=1)*diag(k)
}
out2 <- simtar(n=n,k=k,ars=ars,Intercept=Intercept,parms=parms,
dist="Slash",extra=2)
str(out2)