An Online Vector Error Correction Model for Exchange Rates Forecasting
Total Page:16
File Type:pdf, Size:1020Kb
An Online Vector Error Correction Model for Exchange Rates Forecasting Paola Arce1, Jonathan Antognini1, Werner Kristjanpoller2 and Luis Salinas1;3 1Departamento de Informatica,´ Universidad Tecnica´ Federico Santa Mar´ıa, Valpara´ıso, Chile 2Departamento de Industrias, Universidad Tecnica´ Federico Santa Mar´ıa, Valpara´ıso, Chile 3CCTVal, Universidad Tecnica´ Federico Santa Mar´ıa, Valpara´ıso, Chile Keywords: Vector Error Correction Model, Online Learning, Financial Forecasting, Foreign Exchange Market. Abstract: Financial time series are known for their non-stationary behaviour. However, sometimes they exhibit some stationary linear combinations. When this happens, it is said that those time series are cointegrated.The Vector Error Correction Model (VECM) is an econometric model which characterizes the joint dynamic behaviour of a set of cointegrated variables in terms of forces pulling towards equilibrium. In this study, we propose an Online VEC model (OVECM) which optimizes how model parameters are obtained using a sliding window of the most recent data. Our proposal also takes advantage of the long-run relationship between the time series in order to obtain improved execution times. Our proposed method is tested using four foreign exchange rates with a frequency of 1-minute, all related to the USD currency base. OVECM is compared with VECM and ARIMA models in terms of forecasting accuracy and execution times. We show that OVECM outperforms ARIMA forecasting and enables execution time to be reduced considerably while maintaining good accuracy levels compared with VECM. 1 INTRODUCTION librium. In finance, many economic time series are revealed to be stationary when they are differentiated In finance, it is common to find variables with long- and cointegration restrictions often improves fore- run equilibrium relationships. This is called cointe- casting (Duy and Thoma, 1998). Therefore, VECM gration and it reflects the idea of that some set of vari- has been widely adopted. ables cannot wander too far from each other. Coin- In finance, pair trading is a very common exam- tegration means that one or more linear combinations ple of cointegration application (Herlemont, 2003) of these variables are stationary even though individ- but cointegration can also be extended to a larger set ually they are not (Engle and Granger, 1987). Fur- of variables (Mukherjee and Naka, 1995),(Engle and thermore, the number of cointegration vectors reflects Patton, 2004). how many of these linear combinations exist. Some Both VECM and VAR model parameters are ob- models, such as the Vector Error Correction (VECM), tained using ordinary least squares (OLS) method. take advantage of this property and describe the joint Since OLS involves many calculations, the parame- behaviour of several cointegrated variables. ter estimation method is computationally expensive VECM introduces this long-run relationship when the number of past values and observations in- among a set of cointegrated variables as an error cor- creases. Moreover, obtaining cointegration vectors is rection term. VECM is a special case of the vector also an expensive routine. autorregresive model (VAR) model. VAR model ex- Recently, online learning algorithms have been presses future values as a linear combination of vari- proposed to solve problems with large data sets be- ables past values. However, VAR model cannot be cause of their simplicity and their ability to update used with non-stationary variables. VECM is a lin- the model when new data is available. The study pre- ear model but in terms of variable differences. If sented by (Arce and Salinas, 2012) applied this idea cointegration exists, variable differences are station- using ridge regression. ary and they introduce an error correction term which There are several popular online methods adjusts coefficients to bring the variables back to equi- such as perceptron (Rosenblatt, 1958), passive- Arce P., Antognini J., Kristjanpoller W. and Salinas L.. 193 An Online Vector Error Correction Model for Exchange Rates Forecasting. DOI: 10.5220/0005205901930200 In Proceedings of the International Conference on Pattern Recognition Applications and Methods (ICPRAM-2015), pages 193-200 ISBN: 978-989-758-077-2 Copyright c 2015 SCITEPRESS (Science and Technology Publications, Lda.) ICPRAM2015-InternationalConferenceonPatternRecognitionApplicationsandMethods aggressive (Crammer et al., 2006), stochastic gradient In other words, a set of I(1) variables is said to descent (Zhang, 2004), aggregating algorithm (Vovk, be cointegrated if a linear combination of them exists 2001) and the second order perceptron (Cesa-Bianchi which is I(0). et al., 2005). In (Cesa-Bianchi and Lugosi, 2006), an in-deph analysis of online learning is provided. 2.2 Vector Autorregresive Models In this paper, we propose an online formulation of the VECM called Online VECM (OVECM). OVECM VECM is a special case of VAR model and both de- is a lighter version of VECM which considers only a scribe the joint behaviour of a set of variables. sliding window of the most recent data and introduces VAR(p) model is a general framework to describe matrix optimizations in order to reduce the number of the behaviour of a set of l endogenous variables as operations and therefore execution times. OVECM a linear combination of their last p values. These l also takes into account the fact that cointegration vec- variables at time t are represented by the vector yt as tor space doesn’t experience large changes with small follows: changes in the input data. > OVECM is later compared against VECM and yt = y1;t y2;t ::: yl;t ; ARIMA models using four currency rates from the where y corresponds to the time series j evaluated foreign exchange market with 1-minute frequency. j;t at time t. VECM and ARIMA models were used in an itera- The VAR(p) model describes the behaviour of a tive way in order to allow fair comparison. Execu- dependent variable in terms of its own lagged values tion times and forecast performance measures MAPE, and the lags of the others variables in the system. The MAE and RMSE were used to compare all methods. model with p lags is formulated as the following: Model effectiveness is focused on out-of-sample forecast rather than in-sample fitting. This criteria y = f y + ··· + f y + c + e ; (2) allows the OVECM prediction capability to be ex- t 1 t−1 p t−p t pressed rather than just explaining data history. where t = p + 1;:::N, f1;:::;fp are l × l matrices of The next sections are organized as follows: sec- real coefficients, ep+1;:::;eN are error terms, c is a tion 2 presents the VAR and VECM, the OVECM al- constant vector and N is the total number of samples. gorithm proposed is presented in section 3. Section 4 The VAR matrix form of equation (2) is: gives a description of the data used and the tests car- ried on to show accuracy and time comparison of our B = AX + E; (3) proposal against the traditional VECM and section 5 where: includes conclusions and a proposal for future study. > 2 yp ::: yN−13 6yp−1 ::: yN−27 6 . 7 A = 6 . .. 7 ; 2 BACKGROUND 6 . 7 4 y1 ::: yN−p5 2.1 Integration and Cointegration 1 ::: 1 2 3> A time series y is said to be integrated of order d if B = 4yp+1 ::: yN5 ; after differentiating the variable d times, we get an I(0) process, more precisely: 2 3> (1 − L)dy ∼ I(0); X = 4 f1 ··· fp c 5 ; where I(0) is a stationary time series and L is the lag operator: 2 3> E = 4ep+1 ::: eN5 : (1 − L)y = Dy = yt − yt−1 8t 1 l Let yt = fy ;:::;y g be a set of l stationary time Equation (3) can be solved using ordinary least series I(1) which are said to be cointegrated if a vector > l squares estimation. b = [b(1);:::;b(l)] 2 R exists such that the time series, > 1 l Zt := b yt = b(1)y + ··· + b(l)y ∼ I(0): (1) 194 AnOnlineVectorErrorCorrectionModelforExchangeRatesForecasting 2 > > 3> 2.3 VECM b yp ··· b yN−1 6 Dyp ··· DyN−1 7 6 7 VECM is a special form of a VAR model for I(1) vari- A = 6 . .. 7 ; (5) ables that are also cointegrated (Banerjee, 1993). It 6 . 7 6 Dy ··· Dy 7 is obtained by replacing the form Dyt = yt − yt−1 in 4 2 N−p+15 equation (2). VECM is expressed in terms of differ- 1 ··· 1 ences, has an error correction term and the following 2 3> form: B = 4Dyp+1 ::: DyN5 ; (6) p−1 ∗ Dyt = Wyt−1 + ∑ fi Dyt−i + c + et ; (4) 2 3> | {z } i=1 Error correction term ∗ ∗ X = 4 a f1 ··· fp−1 c5 ; (7) ∗ where coefficients matrices W and fi are function of matrices fi (shown in equation (2)) as follows: 2 3> p ∗ E = 4ep+1 ::: eN 5 (8) fi := − ∑ f j j=i+1 W := −(I − f1 − ··· − fp) VAR and VECM parameters shown in equation (3) can be solved using standard regression tech- The matrix W has the following properties (Johansen, niques, such as ordinary least squares (OLS). 1995): • If W = 0 there is no cointegration 2.4 Ordinary Least Squares Method • If rank(W) = l i.e full rank, then the time series are not I(1) but stationary When A is singular, solution to equation (3) is given by the ordinary least squares (OLS) method. OLS • If rank( ) = r; 0 < r < l then, there is coin- W consists of minimizing the sum of squared errors or tegration and the matrix can be expressed as W equivalently minimizing the following expression: W = ab>, where a and b are (l × r) matrices and rank(a) = rank(b) = r. 2 min kAX − Bk2 The columns of b contains the cointegration vec- X tors and the rows of a correspond with the ad- for which the solution Xˆ is well-known: justed vectors.