Estimating a Dynamic Threshold Model

Suppose you want to estimate a time series model with threshold effects. Let’s work with this model: yt=α+β1yt1+β2yt2+β3δ1tyt1+β4δ2tyt2+εt This can be done using the tstools package in one of two ways.

Begin by simulating some data and loading the tstools package.

library(tstools)
set.seed(100)
y <- ts(rnorm(500))

Threshold I

The most common way to set up a threshold model is based on the regressors. δ1t=1 if yt1 is above a threshold and δ2t=1 if yt2 is above a (potentially different) threshold.

If we want to use zero as the threshold for both yt1 and yt2, you can do:

rhs <- thrlags(y, 1:2, 0.0)
fit <- tsreg(y, rhs)

If you want to use a different threshold for each variable, you’ll need to send a vector of threshold values. Let’s say the threshold for yt1 is 0 and the threshold for yt1 is 0.02. Then we’d have

rhs <- thrlags(y, 1:2, c(0.0, 0.02))
fit <- tsreg(y, rhs)

Threshold II

You can also send a logical vector or matrix directly to thrlags. It will use that vector/matrix as the dummy variable. If you send a vector, it will apply that vector to each variable.

d <- y > 0.0
rhs <- thrlags(y, 1:2, d)
fit <- tsreg(y, rhs)

Stratified Sampling

You need to be concerned with bias resulting from stratified sampling if you create the dummy variables based on the dependent variable in the regression. This is a form of selection bias that can cause your results to be uninteresting, particularly to journal referees.

Last updated: July 31, 2017