Estimating a Dynamic Threshold Model
Suppose you want to estimate a time series model with threshold effects. Let’s work with this model:
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.
If we want to use zero as the threshold for both
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
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