# Foreign Exchange [Part 3 : Non-Linear Models]

The previous post examined exchange rate predictability (in-sample) in the context of various linear models. Since economic and financial systems are known to traverse structural and behavioural changes, different time series / economic models may be required to explain the empirical data at different times. Non-linear modelling in economic/financial times series presupposes the existence of different states of the world (i.e. regimes) and the possibility of time series dynamics to vary across regimes.

There are generally two ways to test the existence of non-linearity. In the absence of any prior knowledge about non-linear structures in the data, Ramsay’s RESET test, Tsay test and the BDS test could be used to determine their existence. By contrast, if a specific form of non-linearity is suggested by economic or financial theory, it is preferable to test for this perceived structure and construct the requisite model.

In this post the Threshold Vector Autoregressive Model (TVAR) and Self-exciting Threshold Autoregression (SETAR) models will be applied to some subset of the data for GBP and CAD currency pairs. Neither the Multivariate Markov Switching Model nor the Smoothed Transition Autoregressive Regression models (STAR) will be utilised; finding no working packages for the former and the data failing suitability tests with respect to the latter model.

Fitting the TVAR model requires specifying , among other parameters,  the threshold variable (the evolution of which governs different regimes) and  the number of regimes. After looping through various variables in the dataset, the change in money supply and the change in price index appear to yield the best results (lowest rmse) for the CAD and GBP currency pairs respectively. The SETAR model is a special kind of TAR model where the dependent variable is also  the threshold variable.

Since it is basically the same, only the code for the CAD/USD pair is shown.

```#Fundamentals
windows(width=14,height=12)
layout(matrix(c(1,1,2,3,1,1,2,3),nrow=4,ncol=2,byrow=F))
par(mai=c(0,0.55,0.30,0.1))

grid()
lines(fx*100,col='purple')
legend(bty='n','bottomleft',legend=c('Actual','Fitted'),fill=c('black','purple'),ncol=1,cex=1)

par(mai=c(0,0.55,0,0.1))
legend(bty='n','bottomright',legend=c('Low Regime','Middle Regime','High Regime'),fill=c('red','blue','green'),ncol=3,cex=1)

par(mai=c(0.5,0.55,0,0.1))
plot(lwd=1,xaxt='n',ylab='Regime Index',xlab='',cex.axis=0.8,cex.lab=1,r,type='h',col=ifelse(r==1,'red',ifelse(r==2,'blue','green')))
axis(tick=FALSE,1, at=1:312, labels=rownames(r),las=1,cex.axis=0.8,las=1,cex=0.8)
``` The first plot shows the actual CAD/USD returns aswell as the fitted data. Compared to linear models, the RMSE of the TV AR model is clearly superior, providing some support for non-linear models even against the BMA technique. The second plot depicts the evolution of the threshold variable; the dotted horizontal lines representing the 2 thresholds which separate the data into 3 regimes. The final plot depicts the regime to which values of the threshold variable belongs. Each regime is associated with a different model.

Next let’s plot the results for the SETAR model.

```# Setar

f&lt;-fitted(a)[3:313]

fx&lt;-fitted(s)[3:313]

windows(width=14,height=12)
layout(matrix(c(1,1,2,1,1,2),nrow=3,ncol=2,byrow=F))
par(mai=c(0,0.55,0.30,0.1))

r&lt;-matrix(regime(s)[3:313])

grid()
abline(h=m\$th,col='black',lty='dotted')
abline(h=m\$th,col='black',lty='dotted')
lines(f,col='darkorange')
lines(fx,col='purple')
legend(bty='n','bottomleft',legend=c('Actual','Fitted-ARIMA(1,0,0)','Fitted-SETAR(2)','Low Regime','Middle Regime','High Regime'),fill=c('black','darkorange','purple','red','blue','green'),ncol=1,cex=1)

par(mai=c(0.5,0.55,0,0.1))
plot(lwd=1,xaxt='n',ylab='Regime Index',xlab='',cex.axis=0.8,cex.lab=1,r,type='h',col=ifelse(r==1,'red',ifelse(r==2,'blue','green'))) Unlike the previous model, the SETAR specification uses lagged values of the dependent variable itself as the threshold variable. As per usual, the first plot depicts the actual and fitted results. In addition to the SETAR model, an ARIMA (1,0,0) model has also been fitted to show the difference in predictive accuracy between linear and non-linear models that only involve one variable (i.e.CAD/USD returns). According to the RMSE measure, the SETAR clearly outperforms the ARIMA model. It is slightly inferior to the TVAR model above, a result that can be explained by the fact that the TVAR specification is conditioned on more information (i.e. change in Canadian money supply over time).  