Please note that I am NOT an expert in time series analysis. Therefore, I am not the ideal person to answer the technical questions on this topic. Please consider (1) raising your question on stackoverflow, (2) sending emails to the developer of related R packages, (3) joining related email groups, etc.
The method of estimating Threshold of Time Series Data has been developed by R. This post shows how to use the method by adopting two packages. First, I would like to highlight Bruce Hansen’s work in this field.
Bruce E. Hansen
Programs — Threshold Models
“Inference when a nuisance parameter is not identified under the null hypothesis.” Econometrica, (1996). [Download].
“Inference in TAR models.” Studies in Nonlinear Dynamics and Econometrics, (1997). [Download].
“Threshold effects in non-dynamic panels: Estimation, testing and inference.” Journal of Econometrics, (1999). [Download].
“Testing for Linearity.” Journal of Economic Surveys, (1999). [Download].
“Sample splitting and threshold estimation.” Econometrica, (2000). [Download].
“Threshold Autoregression with a Unit Root.” Econometrica (2001), with Mehmet Caner. [Download].
“How responsive are private transfers to income? Evidence from a laissez-faire economy.”
with Donald Cox and Emmanuel Jimenez, Journal of Public Economics, (2004), 88, 2193-2219. [Download].
“Testing for two-regime threshold cointegration in vector error correction models,” with Byeongseon Seo, Journal of Econometrics (2002). [Download].
“Instrumental Variable Estimation of a Threshold Model”, with Mehmet Caner, Econometric Theory, (2004), 20, 813-843. [Download].
# Chengjun WANG # @anu, 20120320 #~~~~~~~~~~~~~~~~urca~~~~~~~~~~~~~~~~~~~~~~~~~# # The first step is Unit root and cointegration Analysis (urca) # install.packages("urca") # load the package library(urca) # see the data which is used as an example data(denmark) data(finland) #~~~~~~~~~~~~~~~threshold model using tsDyn~~~~~~~~~~~~~~~~~~~~~~~# # install.packages("tsDyn") # load the package of tsDyn library(tsDyn) # models in this package availableModels()  "linear" "nnetTs" "setar" "lstar" "star" "aar" "lineVar"  "VECM" "TVAR" "TVECM" #fit an AAR model: mod #Summary data informations: summary(mod) #Diagnostic plots: plot(mod) # STAR model fitting with automatic selection of the number # of regimes based on LM tests. mod.star mod.star addRegime(mod.star) # Estimate a multivariate Threshold VAR ?TVAR # ask r to introduce about TVAR data(zeroyld) data TVAR(data, lag=2, nthresh=2, thDelay=1, trim=0.1, mTh=1, plot=TRUE) TVAR.LRtest(data, lag=2, mTh=1,thDelay=1:2, nboot=3, plot=FALSE, trim=0.1, test="1vs") # The one threshold (two regimes) gives a value of 10.698 for the # threshold and 1 for the delay. Conditional on this values, the search # for a second threshold (three regimes) gives 8.129. Starting from this # values, a full grid search finds the same values and confims the first # step estimation. ##simulate VAR as in Enders 2004, p 268 B1var1ts.plot(var1, type="l", col=c(1,2)) B2varcovvar2ts.plot(var2, type="l", col=c(1,2)) ##Simulation of a TVAR with 1 threshold Bsim #estimate the new serie TVAR(sim, lag=1, dummyToBothRegimes=TRUE) ##Bootstrap a TVAR with two threshold (three regimes) data(zeroyld) serieTVAR.sim(data=serie,nthresh=2, type="boot",mTh=1, Thresh=c(7,9)) ##Check the bootstrap cbind(TVAR.sim(data=serie,nthresh=2, type="check",mTh=1, Thresh=c(7,9)),serie) # Estimate a Threshold Vector Error Correction model (VECM) # Hansen, B. and Seo, B. (2002), Testing for two-regime threshold cointegration in vector error-correction models, Journal of Econometrics, 110, pages 293 - 318 data(zeroyld) data ##Estimate a TVECM (we use here minimal grid, it should be usually much bigger!) tv print(tv) summary(tv) #Obtain diverse infos: AIC(tv) BIC(tv) res.tv #export the equations as Latex: toLatex(tv)