Monthly Forecasting of the Dollar to the Ruble Exchange Rate with Adaptive Kalman Filter

: The goal: to develop a model that allows you to forecast the dollar to the ruble exchange rate for a month ahead based on macroeconomic data, published at monthly intervals. Proposed structural model of the dynamics of the ruble and dollar masses that determine the exchange rate, depending on changes in foreign exchange reserves, the balance of foreign trade, the monetary base, the MICEX index, the price of oil. With the help of the Kalman filter (KF), the model parameters, the dynamics of the money masses were estimated, and forecasting of the dollar exchange rate was done. Monthly data were used from the beginning of 2015 to mid-2017. The estimation of the capacity of dollar market was found in about half the capacity of the MICEX index funds. Average error of forecasts, based on information available one step before the forecasted moments (RMSEA) was 1.99. Adaptive form of KF was developed when, similarly to the EM algorithm, the phases of KF estimation in the window and minimization of average prediction error to determine the optimal estimates for the system model parameters in this moment are sequentially alternated. With this RMSEA became 1.39.


Introduction
Many studies have been devoted to the forecasting of exchange rates [1,2]; in particular, a model of daily forecasting has been proposed in [3]. In this paper, an attempt is made to build monthly forecasts. Particularly, such forecasts are necessary when investing in Dual Currency Deposits. Of course, the changes in the dollar-ruble exchange rate, especially short-term ones, are greatly influenced by information shocks and crises, so a relatively quiet period was chosen for the training of the model and its testing from the end of 2014 to mid-2017. Further in the article t -the moments of the beginning of the months, take the values from 0 to T-1 that is from January 1, 2015 to May 1, 2017 (total T = 29 months). (1)

Model and Data
We will assume that changes in these masses depend on changes in the following macroeconomic variables. 1 1 Here all the differences are backward base in a narrow definition (includes cash issued by the Bank of Russia (including balances in cash departments of credit institutions) and balances on accounts of mandatory reserves for funds borrowed by credit institutions in the national currency deposited with the Bank of Russia) bn., t B -the price of a barrel of oil $, t Ca -cash currency and deposits included in the item "International reserve assets and other liquidity in foreign currency of the Russian Federation" $ trillion, t Sais the monthly balance of the trade balance of the "Foreign Trade of the Russian Federation with goods" $ bn. All these data, as well as the exchange rate t Y -"Nominal rates of foreign currencies to the ruble (rubles per unit of foreign currency)" are available on the Bank of Russia website http: / /www.cbr.ru. See Table 1. The inclusion of precisely these control actions is dictated by common sense, their availability and the results of some selections for the best description. The estimation of the multiple correlation coefficient of the change in the dollar exchange rate Y ∆ with all the controls B ∆ (it is equal to the coefficient of determination 2 R in the regression analysis) was 0.6447. The Wilks-Bartlett criterion rejects the hypothesis of pairwise independence of all these six values with a significance level of 0.0037.

Kalman Filter
The Kalman filter is widely used in studies both in macroeconomics [4,5,6] and microeconomics [7].
Logarithm (1) to obtain a linear connection of the proper value of the output quantity with the components of the state vector. The lower case letters denote the logarithms of the corresponding quantities. Taking logarithms (2) and (3), imply that ln(1 ) + ≈ x x at small x. As shown by numerical experiments with these data, it is useful to introduce a "cobweb" cycle in the supply of rubles and dollars to the exchange market. As is known, the volume of the next delivery would necessarily be between the two previous ones. For this, in the logarithmic equations (2) and (3) in right hand parts replace Then, similarly to [8], we have a model of the system in the state space State vector The estimation of the vector of model parameters Here 1| t t y + is the forecast at time t of the logarithm of the dollar rate at the next moment. Tl is the initial moment, Tu is the final moment of the training (fit) window.
Then, using the estimated parameters ˆR MSE θ , starting with the last state estimate, its covariance matrix and t u , all at the moment Tu, perform at moments t from Tu + 1 to T-1 (getting t y and t u ) the Kalman filter forecasting for a month ahead. The root-mean-square error of adequacy characterizes the average error of these forecasts  1%. Thus if we assume that exactly this money is transferred from the stock market to the foreign exchange market, then the capacity of the dollar market is half the capacity of the MICEX index funds.
The achieved RMSE = 1.93 S. To check the adequacy of the model remains 7 pairs of forecasts + the actual dollar rate (from 22 to 28). RMSEA, obviously, is not expected to be less than RMSE and was equal to 1.99 S. See Figure 1.

The observed rate of USD / RUR (solid curve), adjusted to it the forecast for information a month ago (point curve -training), the forecast for the estimated model (dashed curve).
It can be seen that the dashed curve unduly reflects large fluctuations in the exchange rate, which were during the training period and are associated with specific causes for that time.
In practical forecasting, it is natural to become attached to the data of the most recent period, including the moment of forecasting. Therefore, perform training from Tl = 16 to Tu = T-2 = 27, i.e. take into account the last rate observation available   It is interesting to compare the adequacy of forecasting for this model and the model proposed in [3]. If in that model (with the replacement of the time interval from day to month) we use the data of this work, then at Tl = 0 and Tu = 20 RMSE = 4.36, RMSEA = 2.15.

Adaptive Kalman Filter
Often the parameters of the system vary with time, so the task arises of their adaptive estimation and use. Note that sometimes this dynamics of the system parameters is a central (main) interest. In this paper, we propose the idea of a possible solution of this problem. The basic idea is similar to the EM method [9], when the phases of estimation and minimization are sequentially alternated. The algorithm is as follows.
1. The state estimate and its covariance matrix are assumed at time t = 0, and also w -the number of window points (width) of the primary estimation of the (vector) parameter θ . x + + and forecast 1| t v t v y + + + of the output quantity is collected from the moment i + v up to the last moment of the available data T-1. Since the last one w y is used to estimate the parameters in the primary window, the final prediction 1| t v t v y + + + must be considered as independent not earlier than at the moment t + v ≥ w, and since min t = i, then i + v ≥ w. Let us apply this adaptive KF to improve the RMSEA of dollar-ruble exchange rate in the range t = 22,..., 28. If we now choose w = 17, i = 14, v = 3, then RMSEA is 1.39 S. This v turned out to be the best, that is, the best predictions were obtained with the adjustment of the parameters from the data of the last 3 moments preceding the moment of forecasting. See Figure 4, which shows the observed data and forecasts on information at the time of the month before.   The application of this adaptive KF to other economic problems can be found in [10].

Conclusion
A method is proposed for forecasting the exchange rate through the modeling of the monetary masses behavior of two respective currencies participating in the exchange.
Along with the use of conventional KF, an adaptive extension of KF has been developed and applied, in which forecasts are made with model parameters optimized for the immediately preceding window. It gives more adequate (outof-sample) forecasts and reveals the dynamics of economic systems inner structure.