| simtar | R Documentation |
This function simulates multivariate time series generated by a user-specified Threshold Autoregressive (TAR) model.
simtar(
n,
k = 2,
ars = ars(),
Intercept = TRUE,
trend = c("none", "linear", "quadratic"),
nseason = NULL,
parms,
delay = 0,
thresholds = NULL,
t.series = NULL,
ex.series = NULL,
dist = c("Gaussian", "Student-t", "Hyperbolic", "Laplace", "Slash",
"Contaminated normal", "Skew-Student-t", "Skew-normal"),
skewness = NULL,
extra = NULL,
setar = NULL,
Verbose = TRUE
)
n |
A positive integer specifying the length of the simulated output series. |
k |
A positive integer specifying the dimension of the multivariate output series. |
ars |
A list defining the TAR model structure, composed of four elements: the number
of regimes ( |
Intercept |
An optional logical indicating whether an intercept term is included in each regime. |
trend |
An optional character string specifying the degree of deterministic time
trend to be included in each regime. Available options are a linear trend
( |
nseason |
An optional integer, greater than or equal to 2, specifying the number of
seasonal periods. When provided, |
parms |
A list with one sublist per regime. Each sublist contains two matrices: the first matrix corresponds to the location parameters, and the second matrix corresponds to the scale parameters of the model. |
delay |
An optional non-negative integer specifying the delay parameter of the
threshold series. By default, |
thresholds |
A numeric vector of length |
t.series |
A matrix containing the values of the threshold series. |
ex.series |
A matrix containing the values of the multivariate exogenous series. |
dist |
An optional character string specifying the multivariate distribution chosen
to model the noise process. Supported options include Gaussian
( |
skewness |
An optional numeric vector specifying the skewness parameters of the noise distribution, when applicable. |
extra |
An optional value specifying the extra parameter of the noise distribution, when required. |
setar |
An optional positive integer indicating which component of the output
series is used as the threshold variable. By default, |
Verbose |
An optional logical indicating whether a description of the simulated
TAR model should be printed. By default, |
A data.frame containing the simulated multivariate output series, and, if
specified, the threshold series and multivariate exogenous series.
Vanegas, L.H. and Calderón, S.A. and Rondón, L.M. (2025) Bayesian estimation of a multivariate tar model when the noise process distribution belongs to the class of gaussian variance mixtures. International Journal of Forecasting.
###### Simulation of a trivariate TAR model with two regimes
n <- 2000
k <- 3
myars <- ars(nregim=2,p=c(1,2))
Z <- as.matrix(arima.sim(n=n+max(myars$p),list(ar=c(0.5))))
probs <- sort((0.6 + runif(myars$nregim-1)*0.8)*c(1:(myars$nregim-1))/myars$nregim)
dist <- "Student-t"; extra <- 6
parms <- list()
for(j in 1:myars$nregim){
np <- 1 + myars$p[j]*k
parms[[j]] <- list()
parms[[j]]$location <- c(ifelse(runif(np*k)<=0.5,1,-1)*rbeta(np*k,shape1=4,shape2=16))
parms[[j]]$location <- matrix(parms[[j]]$location,np,k)
parms[[j]]$scale <- rgamma(k,shape=1,scale=1)*diag(k)
}
thresholds <- quantile(Z,probs=probs)
out1 <- simtar(n=n, k=k, ars=myars, parms=parms, thresholds=thresholds,
t.series=Z, dist=dist, extra=extra)
str(out1)
fit1 <- mtar(~ Y1 + Y2 + Y3 | Z, data=out1, ars=myars, dist=dist,
n.burn=2000, n.sim=3000, n.thin=2)
summary(fit1)
###### Simulation of a trivariate VAR model
n <- 2000
k <- 3
myars <- ars(nregim=1,p=2)
dist <- "Slash"; extra <- 2
parms <- list()
for(j in 1:myars$nregim){
np <- 1 + myars$p[j]*k
parms[[j]] <- list()
parms[[j]]$location <- c(ifelse(runif(np*k)<=0.5,1,-1)*rbeta(np*k,shape1=4,shape2=16))
parms[[j]]$location <- matrix(parms[[j]]$location,np,k)
parms[[j]]$scale <- rgamma(k,shape=1,scale=1)*diag(k)
}
out2 <- simtar(n=n, k=k, ars=myars, parms=parms, dist=dist, extra=extra)
str(out2)
fit2 <- mtar(~ Y1 + Y2 + Y3, data=out2, ars=myars, dist=dist,
n.burn=2000, n.sim=3000, n.thin=2)
summary(fit2)
n <- 5000
k <- 3
myars <- ars(nregim=2,p=c(1,2))
dist <- "Laplace"
parms <- list()
for(j in 1:myars$nregim){
np <- 1 + myars$p[j]*k
parms[[j]] <- list()
parms[[j]]$location <- c(ifelse(runif(np*k)<=0.5,1,-1)*rbeta(np*k,shape1=4,shape2=16))
parms[[j]]$location <- matrix(parms[[j]]$location,np,k)
parms[[j]]$scale <- rgamma(k,shape=1,scale=1)*diag(k)
}
out3 <- simtar(n=n, k=k, ars=myars, parms=parms, delay=2,
thresholds=-1, dist=dist, setar=2)
str(out3)
fit3 <- mtar(~ Y1 + Y2 + Y3, data=out3, ars=myars, dist=dist,
n.burn=2000, n.sim=3000, n.thin=2, setar=2)
summary(fit3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.