# 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, [1] the threshold variable (the evolution of which governs different regimes) and [2] 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)) cad.tvar.fund<-cad.tar.sub cad.tvar<-TVAR(include='both',cad.tar.dat, lag=1, nthresh=2, thDelay=1, trim=0.25, mTh=5, plot=F) fx<-as.matrix(fitted(cad.tvar)[1,]) cad.tvar.f.err<-rmse(cad.diff[2:313,1],fx) r<-matrix(regime(cad.tvar)[2:313]) rownames(r)=rownames(cad.diff)[1:312] plot(cex.lab=1,cex.axis=0.75,cad.diff[2:313,1]*100,type='p',xaxt='n',xlab='',ylab='CAD/USD returns',col='black',main='Threshold Vector Autoregression For CAD/USD \n 2 Thresholds and 3 Regimes',cex.main=0.85) grid() lines(fx*100,col='purple') lines(cad.diff[2:313,1]*100,col='black') legend(bty='n','bottomleft',legend=c('Actual','Fitted'),fill=c('black','purple'),ncol=1,cex=1) text(adj=0,col="black",nrow(r)/2+40,min(cad.diff[2:313,1])*100,paste('RMSE :: ',cad.tvar.f.err),font=2,cex=1) par(mai=c(0,0.55,0,0.1)) plot(ylim=c(min(cad.diff[2:313,5])*100,max(cad.diff[2:313,5])*100+0.5),cad.diff[1:313,5]*100,type='l',xaxt='n',xlab='',ylab='Change in Money Supply',cex.axis=0.8,cex.lab=1) abline(h=cad.tvar$model.specific$Thresh[1]*100,col='black',lty='dotted') abline(h=cad.tvar$model.specific$Thresh[2]*100,col='black',lty='dotted') legend(bty='n','bottomright',legend=c('Low Regime','Middle Regime','High Regime'),fill=c('red','blue','green'),ncol=3,cex=1) text(adj=0,col="black",0,max(cad.diff[2:313,5])*100+0.4,'Threshold Variable : Change in Money Supply',font=2,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 a<-auto.arima(cad.diff[1:313,1]) f<-fitted(a)[3:313] arerr<-rmse(cad.diff[3:313,1],f) m<-selectSETAR(cad.diff[1:313,1],m=2,nthresh=2,include='both') s<-setar(cad.diff[1:313,1], m=2, thDelay=0,th=c(-0.000985251,0.002029066)) fx<-fitted(s)[3:313] rm<-rmse(cad.diff[3:313,1],fx) 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<-matrix(regime(s)[3:313]) rownames(r)=rownames(cad.diff)[3:313] plot(cex.lab=1,cex.axis=0.75,cad.diff[3:313,1],type='p',xaxt='n',xlab='',ylab='CAD/USD returns',col='black',main='SETAR(2) VS ARIMA (1,0,0) For CAD/USD \n 2 Thresholds and 3 Regimes',cex.main=0.85) grid() abline(h=m$th[1],col='black',lty='dotted') abline(h=m$th[2],col='black',lty='dotted') lines(f,col='darkorange') lines(fx,col='purple') lines(cad.diff[3:313,1],col='black') 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) text(adj=0,col="black",nrow(r)/2-40,min(ca.orig[3:313,1]),paste('SETAR-RMSE :: ',rm,' ARIMA-RMSE ::',arerr),font=2,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=3:313, labels=rownames(cad.diff)[3:313],las=1,cex.axis=0.8,las=1)

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).

* The same procedures* applied to the GBP/USD currency pair yields the following plots

Compared to linear models for the GBP/USD currency pair,the TVAR model has the lowest RMSE. The optimal threshold variable appears to be the British price index. Again there are 2 thresholds,segmenting the data into 3 regimes, each associated with a different model.

The SETAR model applied to the GBP/USD currency pair produces superior results relative to the ARIMA model but not the BMA technique in the previous post.