There are quite a few R packages available for nonlinear time series analysis, but sometimes you need to code your own models. Here is a simple example to show how it can be done. The model is a first order threshold autoregression: where is a Gaussian white noise series with variance . The following function will generate...