Description Usage Arguments Details Value Author(s) Examples
Bayesian estimation and onestepahead forecasting for tworegime TAR model, as well as monitoring MCMC convergence. One may want to allow for higherorder AR models in the different regimes. Parsimonious subset AR could be assigned in each regime in the BAYSTAR function rather than a full AR model (i.e. the autoregressive orders could be not a continuous series).
1 2  BAYSTAR(x, lagp1, lagp2, Iteration, Burnin, constant, d0,
step.thv, thresVar, mu01, v01, mu02, v02, v0, lambda0, refresh,tplot)

x 
A vector of time series. 
lagp1 
A vector of nonzero autoregressive lags for the lower regime (regime one).
For example, an AR model with p1=3 in lags 1,3, and 5 would be set
as 
lagp2 
A vector of nonzero autoregressive lags for the upper regime (regime two). 
Iteration 
The number of MCMC iterations. 
Burnin 
The number of burnin iterations for the sampler. 
constant 
The intercepts include in the model for each regime, if 
d0 
The maximum delay lag considered. (Default: 
step.thv 
Step size of tuning parameter for the MetropolisHasting algorithm. 
thresVar 
A vector of time series for the threshold variable. (if missing, the series x is used.) 
mu01 
The prior mean of phi in regime one. This setting can be a scalar or a column vector with dimension equal to the number of phi. If this sets a scalar value, then the prior mean for all of phi are this value. (Default: a vector of zeros) 
v01 
The prior covariance matrix of phi in regime one. This setting can either be a scalar or a square matrix with dimensions equal to the number of phi. If this sets a scalar value, then prior covariance matrix of phi is that value times an identity matrix. (Default: a diagonal matrix are set to 0.1) 
mu02 
The prior mean of phi in regime two. This setting can be a scalar or a column vector with dimension equal to the number of phi. If this sets a scalar value, then the prior mean for all of phi are this value. (Default: a vector of zeros) 
v02 
The prior covariance matrix of phi in regime two. This setting can either be a scalar or a square matrix with dimensions equal to the number of phi. If this sets a scalar value, then prior covariance matrix of phi is that value times an identity matrix. (Default: a diagonal matrix are set to 0.1) 
v0 

lambda0 

refresh 
Each 
tplot 
Trace plots and ACF plots for all parameter estimates. (Default: 
Given the maximum AR orders p1 and p2, the tworegime SETAR(2:p1;p2) model is specified as:
x_{t} = ( φ _0^{(1)} + φ _1^{(1)} x_{t  1} + … + φ _{p1 }^{(1)} x_{t  p1 } + a_t^{(1)} ) I( z_{td} <= th) + ( φ _0^{(2)} + φ _1^{(2)} x_{t  1} + … + φ _{p2 }^{(2)} x_{t  p2 } + a_t^{(2)} I( z_{td} > th)
where is the threshold value for regime switching; is the threshold variable; is the delay lag of threshold variable; and the error term , , for each regime is assumed to be an i.i.d. Gaussian white noise process with mean zero and variance . I(A) is an indicator function. Event A will occur if I(A)=1 and otherwise if I(A)=0. One may want to allow parsimonious subset AR model in each regime rather than a full AR model.
A list of output with containing the following components:
mcmc 
All MCMC iterations. 
posterior 
The initial 
coef 
Summary Statistics of parameter estimation based on the final sample of ( 
residual 
Residuals from the estimated model. 
lagd 
The mode of time delay lag of the threshold variable. 
DIC 
The deviance information criterion (DIC); a Bayesian method for model comparison (Spiegelhalter et al, 2002) 
Cathy W. S. Chen, Edward M.H. Lin, F.C. Liu, and Richard Gerlach
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  set.seed(989981)
## Set the true values of all parameters
nob< 200 ## No. of observations
lagd< 1 ## delay lag of threshold variable
r< 0.4 ## r is the threshold value
sig.1< 0.8; sig.2< 0.5 ## variances of error distributions for two regimes
p1< 2; p2< 1 ## No. of covariate in two regimes
ph.1< c(0.1,0.4,0.3) ## mean coefficients for regime 1
ph.2< c(0.2,0.6) ## mean coefficients for regime 2
lagp1<1:2
lagp2<1:1
yt< TAR.simu(nob,p1,p2,ph.1,ph.2,sig.1,sig.2,lagd,r,lagp1,lagp2)
## Total MCMC iterations and burnin iterations
Iteration < 500
Burnin < 200
## A RW (random walk) MH algorithm is used in simulating the threshold value
## Step size for the RW MH
step.thv< 0.08
out < BAYSTAR(yt,lagp1,lagp2,Iteration,Burnin,constant=1,step.thv=step.thv,tplot=TRUE)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.