Title: | Bayesian Modeling of Autoregressive Threshold Time Series Models |
---|---|
Description: | Identification and estimation of the autoregressive threshold models with Gaussian noise, as well as positive-valued time series. The package provides the identification of the number of regimes, the thresholds and the autoregressive orders, as well as the estimation of remain parameters. The package implements the methodology from the 2005 paper: Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data <DOI:10.1081/STA-200054435>. |
Authors: | Hanwen Zhang, Fabio H. Nieto |
Maintainer: | Hanwen Zhang <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2025-02-22 02:38:00 UTC |
Source: | https://github.com/cran/TAR |
This function identify the autoregressive orders for a log-normal TAR model given the number of regimes and thresholds.
ARorder.lognorm(Z, X, l, r, k_Max = 3, k_Min = 0, n.sim = 500, p.burnin = 0.3, n.thin = 1)
ARorder.lognorm(Z, X, l, r, k_Max = 3, k_Min = 0, n.sim = 500, p.burnin = 0.3, n.thin = 1)
Z |
The threshold series |
X |
The series of interest |
l |
The number of regimes. |
r |
The vector of thresholds for the series {Z_t}. |
k_Max |
The minimum value for each autoregressive order. The default is 3. |
k_Min |
The maximum value for each autoregressive order. The default is 0. |
n.sim |
Number of iteration for the Gibbs Sampler |
p.burnin |
Percentage of iterations used for burn-in |
n.thin |
Thinnin factor for the Gibbs Sampler |
The log-normal TAR model is given by
when for some
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The identified autoregressive orders with posterior probabilities
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
simu.tar.lognorm, ARorder.norm
set.seed(12345678) Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) #res <- ARorder.lognorm(Z,X,l,r) #res$K.est #res$K.prob
set.seed(12345678) Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) #res <- ARorder.lognorm(Z,X,l,r) #res$K.est #res$K.prob
This function identify the autoregressive orders for a TAR model with Gaussian noise process given the number of regimes and thresholds.
ARorder.norm(Z, X, l, r, k_Max = 3, k_Min = 0, n.sim = 500, p.burnin = 0.3, n.thin = 1)
ARorder.norm(Z, X, l, r, k_Max = 3, k_Min = 0, n.sim = 500, p.burnin = 0.3, n.thin = 1)
Z |
The threshold series |
X |
The series of interest |
l |
The number of regimes. |
r |
The vector of thresholds for the series {Z_t}. |
k_Max |
The minimum value for each autoregressive order. The default is 3. |
k_Min |
The maximum value for each autoregressive order. The default is 0. |
n.sim |
Number of iteration for the Gibbs Sampler |
p.burnin |
Percentage of iterations used for |
n.thin |
Thinnin factor for the Gibbs Sampler |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The identified autoregressive orders with posterior probabilities
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
set.seed(123456789) Z<-arima.sim(n=300,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) #res <- ARorder.norm(Z,X,l,r) #res$K.est #res$K.prob
set.seed(123456789) Z<-arima.sim(n=300,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) #res <- ARorder.norm(Z,X,l,r) #res$K.est #res$K.prob
This function estimate a log-normal TAR model using Least Square method given the structural parameters, i.e. the number of regimes, thresholds and autoregressive orders.
LS.lognorm(Z, X, l, r, K)
LS.lognorm(Z, X, l, r, K)
Z |
The threshold series |
X |
The series of interest |
l |
The number of regimes. |
r |
The vector of thresholds for the series |
K |
The vector containing the autoregressive orders of the |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
The function returns the autoregressive coefficients matrix theta and variance weights H. Rows of the matrix theta represent regimes
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) ts.plot(X) LS.lognorm(Z,X,l,r,K)
Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) ts.plot(X) LS.lognorm(Z,X,l,r,K)
This function estimate a Gaussian TAR model using Least Square method given the structural parameters, i.e. the number of regimes, thresholds and autoregressive orders.
LS.norm(Z, X, l, r, K)
LS.norm(Z, X, l, r, K)
Z |
The threshold series |
X |
The series of interest |
l |
The number of regimes. |
r |
The vector of thresholds for the series |
K |
The vector containing the autoregressive orders of the |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
The function returns the autoregressive coefficients matrix theta and variance weights . Rows of the matrix theta represent regimes
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) LS.norm(Z,X,l,r,c(0,0))
Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) LS.norm(Z,X,l,r,c(0,0))
This function estimate a TAR model using Gibbs Sampler given the structural parameters, i.e. the number of regimes, thresholds and autoregressive orders.
Param.lognorm(Z, X, l, r, K, n.sim = 500, p.burnin = 0.2, n.thin = 3)
Param.lognorm(Z, X, l, r, K, n.sim = 500, p.burnin = 0.2, n.thin = 3)
Z |
The threshold series |
X |
The series of interest |
l |
The number of regimes. |
r |
The vector of thresholds for the series |
K |
The vector containing the autoregressive orders of the l regimes. |
n.sim |
Number of iteration for the Gibbs Sampler |
p.burnin |
Percentage of iterations used for burn-in |
n.thin |
Thinnin factor for the Gibbs Sampler |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The function returns the autoregressive coefficients matrix theta and variance weights . Rows of the matrix theta represent regimes
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
# Example 1, TAR model with 2 regimes #' set.seed(12345678) Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) # res <- Param.lognorm(Z,X,l,r,K) # Example 2, TAR model with 3 regimes Z<-arima.sim(n=300, list(ar=c(0.5))) l <- 3 r <- c(-0.6, 0.6) K <- c(1, 2, 1) theta <- matrix(c(1,0.5,-0.5,-0.5,0.2,-0.7,NA, 0.5,NA), nrow=l) H <- c(1, 1.5, 2) X <- simu.tar.lognorm(Z, l, r, K, theta, H) # res <- Param.lognorm(Z,X,l,r,K)
# Example 1, TAR model with 2 regimes #' set.seed(12345678) Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) # res <- Param.lognorm(Z,X,l,r,K) # Example 2, TAR model with 3 regimes Z<-arima.sim(n=300, list(ar=c(0.5))) l <- 3 r <- c(-0.6, 0.6) K <- c(1, 2, 1) theta <- matrix(c(1,0.5,-0.5,-0.5,0.2,-0.7,NA, 0.5,NA), nrow=l) H <- c(1, 1.5, 2) X <- simu.tar.lognorm(Z, l, r, K, theta, H) # res <- Param.lognorm(Z,X,l,r,K)
This function estimate a Gaussian TAR model using Gibbs Sampler given the structural parameters, i.e. the number of regimes, thresholds and autoregressive orders.
Param.norm(Z, X, l, r, K, n.sim = 500, p.burnin = 0.2, n.thin = 3)
Param.norm(Z, X, l, r, K, n.sim = 500, p.burnin = 0.2, n.thin = 3)
Z |
The threshold series |
X |
The series of interest |
l |
The number of regimes. |
r |
The vector of thresholds for the series |
K |
The vector containing the autoregressive orders of the |
n.sim |
Number of iteration for the Gibbs Sampler |
p.burnin |
Percentage of iterations used for burn-in |
n.thin |
Thinnin factor for the Gibbs Sampler |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The function returns the autoregressive coefficients matrix theta and variance weights . Rows of the matrix theta represent regimes
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
# Example 1, TAR model with 2 regimes Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) # res <- Param.norm(Z,X,l,r,K) # Example 2, TAR model with 3 regimes Z<-arima.sim(n=300, list(ar=c(0.5))) l <- 3 r <- c(-0.6, 0.6) K <- c(1, 2, 1) theta <- matrix(c(1,0.5,-0.5,-0.5,0.2,-0.7,NA, 0.5,NA), nrow=l) H <- c(1, 1.5, 2) X <- simu.tar.norm(Z, l, r, K, theta, H) # res <- Param.norm(Z,X,l,r,K)
# Example 1, TAR model with 2 regimes Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) # res <- Param.norm(Z,X,l,r,K) # Example 2, TAR model with 3 regimes Z<-arima.sim(n=300, list(ar=c(0.5))) l <- 3 r <- c(-0.6, 0.6) K <- c(1, 2, 1) theta <- matrix(c(1,0.5,-0.5,-0.5,0.2,-0.7,NA, 0.5,NA), nrow=l) H <- c(1, 1.5, 2) X <- simu.tar.norm(Z, l, r, K, theta, H) # res <- Param.norm(Z,X,l,r,K)
This function identify the number of regimes and the corresponding thresholds for a log-normal TAR model.
reg.thr.lognorm(Z, X, n.sim = 500, p.burnin = 0.2, n.thin = 1)
reg.thr.lognorm(Z, X, n.sim = 500, p.burnin = 0.2, n.thin = 1)
Z |
The threshold series |
X |
The series of interest |
n.sim |
Number of iteration for the Gibbs Sampler |
p.burnin |
Percentage of iterations used for Burn-in |
n.thin |
Thinnin factor for the Gibbs Sampler |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The function returns the identified number of regimes with posterior probabilities and the thresholds with credible intervals.
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
set.seed(12345678) # Example 1, log-normal TAR model with 2 regimes Z<-arima.sim(n=400,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(-1,0.5,0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.5) #X <- simu.tar.lognorm(Z,l,r,K,theta,H) #res <- reg.thr.lognorm(Z,X) #res$L.est #res$L.prob #res$R.est #res$R.CI
set.seed(12345678) # Example 1, log-normal TAR model with 2 regimes Z<-arima.sim(n=400,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(-1,0.5,0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.5) #X <- simu.tar.lognorm(Z,l,r,K,theta,H) #res <- reg.thr.lognorm(Z,X) #res$L.est #res$L.prob #res$R.est #res$R.CI
This function identify the number of regimes and the corresponding thresholds for a TAR model with Gaussian noise process.
reg.thr.norm(Z, X, n.sim = 500, p.burnin = 0.2, n.thin = 1)
reg.thr.norm(Z, X, n.sim = 500, p.burnin = 0.2, n.thin = 1)
Z |
The threshold series |
X |
The series of interest |
n.sim |
Number of iteration for the Gibbs Sampler |
p.burnin |
Percentage of iterations used for Burn-in |
n.thin |
Thinnin factor for the Gibbs Sampler |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The function returns the identified number of regimes with posterior probabilities and the thresholds with credible intervals.
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
set.seed(12345678) # Example 1, TAR model with 2 regimes Z<-arima.sim(n=300,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) #res <- reg.thr.norm(Z,X) #res$L.est #res$L.prob #res$R.est #res$R.CI
set.seed(12345678) # Example 1, TAR model with 2 regimes Z<-arima.sim(n=300,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA), nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) #res <- reg.thr.norm(Z,X) #res$L.est #res$L.prob #res$R.est #res$R.CI
This function simulates a serie from a log-normal TAR model with Gaussian distributed error given the parameters of the model from a given threshold process
simu.tar.lognorm(Z, l, r, K, theta, H)
simu.tar.lognorm(Z, l, r, K, theta, H)
Z |
The threshold series |
l |
The number of regimes. |
r |
The vector of thresholds for the series |
K |
The vector containing the autoregressive orders of the |
theta |
The matrix of autoregressive coefficients of dimension |
H |
The vector containing the variance weights of the |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The time series .
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
set.seed(12345678) Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) ts.plot(X)
set.seed(12345678) Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,0.5,-0.3,-0.5,-0.7,NA),nrow=l) H <- c(1, 1.3) X <- simu.tar.lognorm(Z,l,r,K,theta,H) ts.plot(X)
This function simulates a serie from a TAR model with Gaussian distributed error given the parameters of the model from a given threshold process
simu.tar.norm(Z, l, r, K, theta, H)
simu.tar.norm(Z, l, r, K, theta, H)
Z |
The threshold series |
l |
The number of regimes. |
r |
The vector of thresholds for the series |
K |
The vector containing the autoregressive orders of the l regimes. |
theta |
The matrix of autoregressive coefficients of dimension |
H |
The vector containing the variance weights of the |
The TAR model is given by
when for som
(
).
the
is the threshold process,
is the number of regimes,
is the autoregressive order in the regime
.
with
denote the autoregressive coefficients, while
denote the variance weights.
is the Gaussian white noise process
.
The time series .
Hanwen Zhang <hanwenzhang at usantotomas.edu.co>
Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930
Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA),nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) ts.plot(X)
Z<-arima.sim(n=500,list(ar=c(0.5))) l <- 2 r <- 0 K <- c(2,1) theta <- matrix(c(1,-0.5,0.5,-0.7,-0.3,NA),nrow=l) H <- c(1, 1.5) X <- simu.tar.norm(Z,l,r,K,theta,H) ts.plot(X)