Package 'TAR'

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

Help Index


Identify the autoregressive orders for a log-normal TAR model given the number of regimes and thresholds.

Description

This function identify the autoregressive orders for a log-normal TAR model given the number of regimes and thresholds.

Usage

ARorder.lognorm(Z, X, l, r, k_Max = 3, k_Min = 0, n.sim = 500,
  p.burnin = 0.3, n.thin = 1)

Arguments

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

Details

The log-normal TAR model is given by

logXt=a0(j)+i=1kjai(j)logXti+h(j)etlog X_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}log X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for some jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The identified autoregressive orders with posterior probabilities

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

simu.tar.lognorm, ARorder.norm

Examples

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

Identify the autoregressive orders for a Gaussian TAR model given the number of regimes and thresholds.

Description

This function identify the autoregressive orders for a TAR model with Gaussian noise process given the number of regimes and thresholds.

Usage

ARorder.norm(Z, X, l, r, k_Max = 3, k_Min = 0, n.sim = 500,
  p.burnin = 0.3, n.thin = 1)

Arguments

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

Details

The TAR model is given by

Xt=a0(j)+i=1kjai(j)Xti+h(j)etX_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The identified autoregressive orders with posterior probabilities

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

simu.tar.norm

Examples

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

Estimate a log-normal TAR model using Least Square method given the structural parameters.

Description

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.

Usage

LS.lognorm(Z, X, l, r, K)

Arguments

Z

The threshold series

X

The series of interest

l

The number of regimes.

r

The vector of thresholds for the series {Zt}\{Z_t\}.

K

The vector containing the autoregressive orders of the ll regimes.

Details

The TAR model is given by

logXt=a0(j)+i=1kjai(j)logXti+h(j)etlog X_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}log X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights.

Value

The function returns the autoregressive coefficients matrix theta and variance weights H. Rows of the matrix theta represent regimes

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

simu.tar.norm

Examples

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)

Estimate a Gaussian TAR model using Least Square method given the structural parameters.

Description

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.

Usage

LS.norm(Z, X, l, r, K)

Arguments

Z

The threshold series

X

The series of interest

l

The number of regimes.

r

The vector of thresholds for the series {Zt}\{Z_t\}.

K

The vector containing the autoregressive orders of the ll regimes.

Details

The TAR model is given by

Xt=a0(j)+i=1kjai(j)Xti+h(j)etX_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights.

Value

The function returns the autoregressive coefficients matrix theta and variance weights HH. Rows of the matrix theta represent regimes

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

simu.tar.norm

Examples

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))

Estimate a TAR model using Gibbs Sampler given the structural parameters.

Description

This function estimate a TAR model using Gibbs Sampler given the structural parameters, i.e. the number of regimes, thresholds and autoregressive orders.

Usage

Param.lognorm(Z, X, l, r, K, n.sim = 500, p.burnin = 0.2, n.thin = 3)

Arguments

Z

The threshold series

X

The series of interest

l

The number of regimes.

r

The vector of thresholds for the series {Zt}\{Z_t\}.

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

Details

The TAR model is given by

Xt=a0(j)+i=1kjai(j)Xti+h(j)etX_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The function returns the autoregressive coefficients matrix theta and variance weights HH. Rows of the matrix theta represent regimes

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

LS.norm

Examples

# 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)

Estimate a Gaussian TAR model using Gibbs Sampler given the structural parameters.

Description

This function estimate a Gaussian TAR model using Gibbs Sampler given the structural parameters, i.e. the number of regimes, thresholds and autoregressive orders.

Usage

Param.norm(Z, X, l, r, K, n.sim = 500, p.burnin = 0.2, n.thin = 3)

Arguments

Z

The threshold series

X

The series of interest

l

The number of regimes.

r

The vector of thresholds for the series {Zt}\{Z_t\}.

K

The vector containing the autoregressive orders of the ll 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

Details

The TAR model is given by

Xt=a0(j)+i=1kjai(j)Xti+h(j)etX_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The function returns the autoregressive coefficients matrix theta and variance weights HH. Rows of the matrix theta represent regimes

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

LS.norm

Examples

# 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)

Identify the number of regimes and the corresponding thresholds for a log-normal TAR model.

Description

This function identify the number of regimes and the corresponding thresholds for a log-normal TAR model.

Usage

reg.thr.lognorm(Z, X, n.sim = 500, p.burnin = 0.2, n.thin = 1)

Arguments

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

Details

The TAR model is given by

logXt=a0(j)+i=1kjai(j)logXti+h(j)etlog X_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}log X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The function returns the identified number of regimes with posterior probabilities and the thresholds with credible intervals.

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

LS.norms

Examples

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

Identify the number of regimes and the corresponding thresholds for a Gaussian TAR model.

Description

This function identify the number of regimes and the corresponding thresholds for a TAR model with Gaussian noise process.

Usage

reg.thr.norm(Z, X, n.sim = 500, p.burnin = 0.2, n.thin = 1)

Arguments

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

Details

The TAR model is given by

Xt=a0(j)+i=1kjai(j)Xti+h(j)etX_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The function returns the identified number of regimes with posterior probabilities and the thresholds with credible intervals.

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

LS.norm

Examples

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

Simulate a series from a log-normal TAR model with Gaussian distributed error for positive valued time series.

Description

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 {Zt}\{Z_t\}

Usage

simu.tar.lognorm(Z, l, r, K, theta, H)

Arguments

Z

The threshold series

l

The number of regimes.

r

The vector of thresholds for the series {Zt}\{Z_t\}.

K

The vector containing the autoregressive orders of the ll regimes.

theta

The matrix of autoregressive coefficients of dimension l×maxKl\times\max{K}. jj-th row contains the autoregressive coefficients of regime jj.

H

The vector containing the variance weights of the ll regimes.

Details

The TAR model is given by

Xt=a0(j)+i=1kjai(j)Xti+h(j)etX_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The time series {Xt}\{X_t\}.

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

simu.tar.norm

Examples

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)

Simulate a series from a TAR model with Gaussian distributed error.

Description

This function simulates a serie from a TAR model with Gaussian distributed error given the parameters of the model from a given threshold process {Zt}\{Z_t\}

Usage

simu.tar.norm(Z, l, r, K, theta, H)

Arguments

Z

The threshold series

l

The number of regimes.

r

The vector of thresholds for the series {Zt}\{Z_t\}.

K

The vector containing the autoregressive orders of the l regimes.

theta

The matrix of autoregressive coefficients of dimension l×maxKl\times\max{K}. jj-th row contains the autoregressive coefficients of regime jj.

H

The vector containing the variance weights of the ll regimes.

Details

The TAR model is given by

Xt=a0(j)+i=1kjai(j)Xti+h(j)etX_t=a_0^{(j)} + \sum_{i=1}^{k_j}a_i^{(j)}X_{t-i}+h^{(j)}e_t

when Zt(rj1,rj]Z_t\in (r_{j-1},r_j] for som jj (j=1,,lj=1,\cdots,l). the {Zt}\{Z_t\} is the threshold process, ll is the number of regimes, kjk_j is the autoregressive order in the regime jj. ai(j)a_i^{(j)} with i=0,1,,kji=0,1,\cdots,k_j denote the autoregressive coefficients, while h(j)h^{(j)} denote the variance weights. {et}\{e_t\} is the Gaussian white noise process N(0,1)N(0,1).

Value

The time series {Xt}\{X_t\}.

Author(s)

Hanwen Zhang <hanwenzhang at usantotomas.edu.co>

References

Nieto, F. H. (2005), Modeling Bivariate Threshold Autoregressive Processes in the Presence of Missing Data. Communications in Statistics. Theory and Methods, 34; 905-930

See Also

simu.tar.norm

Examples

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)