Forecasting of realised volatility with the random forests algorithm
Abstract
EconStor is a publication server for scholarly economic literature, provided as a non-commercial public service by the ZBW.
Full text
Luong, Chuong; Dokučaev, Nikolaj G. Article Forecasting of realised volatility with the random forests algorithm Journal of Risk and Financial Management Provided in Cooperation with: MDPI – Multidisciplinary Digital Publishing Institute, Basel Suggested Citation: Luong, Chuong; Dokučaev, Nikolaj G. (2018) : Forecasting of realised volatility with the random forests algorithm, Journal of Risk and Financial Management, ISSN 1911-8074, MDPI, Basel, Vol. 11, Iss. 4, pp. 1-15, https://doi.org/10.3390/jrfm11040061 This Version is available at: https://hdl.handle.net/10419/238927 Standard-Nutzungsbedingungen: Die Dokumente auf EconStor dürfen zu eigenen wissenschaftlichen Zwecken und zum Privatgebrauch gespeichert und kopiert werden. Sie dürfen die Dokumente nicht für öffentliche oder kommerzielle Zwecke vervielfältigen, öffentlich ausstellen, öffentlich zugänglich machen, vertreiben oder anderweitig nutzen. Sofern die Verfasser die Dokumente unter Open-Content-Lizenzen (insbesondere CC-Lizenzen) zur Verfügung gestellt haben sollten, gelten abweichend von diesen Nutzungsbedingungen die in der dort genannten Lizenz gewährten Nutzungsrechte. Terms of use: Documents in EconStor may be saved and copied for your personal and scholarly purposes. You are not to copy documents for public or commercial purposes, to exhibit the documents publicly, to make them publicly available on the internet, or to distribute or otherwise use the documents in public. If the documents have been made available under an Open Content Licence (especially Creative Commons Licences), you may exercise further usage rights as specified in the indicated licence. https://creativecommons.org/licenses/by/4.0/
Journal of Risk and Financial Management Article Forecasting of Realised Volatility with the Random Forests Algorithm Chuong Luong and Nikolai Dokuchaev * School of Electrical Engineering, Computing and Mathematical Sciences, Curtin University, GPO Box U1987, Perth 6845, Western Australia, Australia; [email protected] *Correpondence: [email protected] Received: 8 September 2018; Accepted: 9 October 2018; Published: 11 October 2018 Abstract: The paper addresses the forecasting of realised volatility for financial time series using the heterogeneous autoregressive model (HAR) and machine learning techniques. We consider an extended version of the existing HAR model with included purified implied volatility. For this extended model, we apply the random forests algorithm for the forecasting of the direction and the magnitude of the realised volatility. In experiments with historical high frequency data, we demonstrate improvements of forecast accuracy for the proposed model. Keywords: realised volatility; heterogeneous autoregressive model; purified implied volatility; classification; random forests; machine learning 1. Introduction In this paper, the estimation of historical volatility is considered for financial time series generated by stock prices and indexes. This estimation is a necessary step for the volatility forecast which is crucial for the pricing of financial derivatives and for optimal portfolio selection. The methods of estimation and forecast of volatility have been intensively studied (see, e.g., the references in Andersen and Bollerslev (1997) and in De Stefani et al. (2017); Dokuchaev (2014)). In pricing of derivatives, option traders use volatility as the input for determining the value of an option using underlying models such as the Black–Scholes’ (Black and Scholes 1973) and Heston’s (1993) option pricing models. Hence, being able to forecast the direction and magnitude of the future volatility on different time horizons will provide advantages in terms of pricing risks and the development of trading strategies. There is an enormous body of research on modelling and forecasting volatility. Engle (1982) and Bollerslev (1986) first proposed the ARCH model and the GARCH model for forecasting volatility. These models have been extended in a number of directions based on the empirical evidences that the volatility process is non-linear, asymmetry, and has a long memory. Such extensions can be referred to EGARCH—Nelson (1991), GJR-GARCH—Glosten et al. (1993), AGARCH—Engle (1990), and TGARCH—Zakoian (1994). However, studies have found that those models cannot describe the whole-day volatility information well enough because they were developed within low-frequency time sequences. With the appearance of high-frequency data, Andersen et al. (2003) introduced a new volatility measure. This proxy was known as realized volatility (RV). In comparison with the GARCH-type measures, realised volatility is preferred as it is a model-free measure. Hence, it provides convenience for calculation. In addition, the realised volatility takes high-frequency data into consideration and exhibits the long memory property. There have been many forecasting models that have been developed to predict the realised volatility. Among those models, the heterogeneous autogressive model for realised volatility (HAR) by Corsi (2003) is one to name. The HAR-RV model was developed J. Risk Financial Manag. 2018,11, 61; doi:10.3390/jrfm11040061 www.mdpi.com/journal/jrfm
J. Risk Financial Manag. 2018,11, 61 2 of 15 in accordance with the heterogeneous market hypothesis proposed by Muller et al. (1997) and the long memory character of realised volatility by Andersen et al. (2003) . Empirical studies have shown that the HAR model has high forecasting performance for future volatility, especially for out-of-sample data with different time horizons (Corsi 2003;Khan 2011). Another commonly used volatility measure is the implied volatility. The implied volatility is often derived from the observed market option prices and is regarded as the fear gauge Whaley (2000). The implied volatility fluctuates with stock movement, strike price, interest rate, time-to-maturity, and option price. To reduce the impact of stock price movement, a so-called “purified” implied volatility was introduced in Luong and Dokuchaev (2014). In the present paper, we show that that this volatility measure contains some information about the future volatility. To produce rules for prediction for the classes and the regression of the outcome variables, classification and regression tree models and other machine learning techniques have been developed in the literature (see the references in De Stefani et al. (2017)). This paper explores the related random forests algorithm to improve the forecasting of realised volatility in the machine learning setting. This algorithm is constructed to predict both the direction and the magnitude of realised volatility, based on the HAR model framework with the inclusion of the purified implied volatility. The paper is structured as follows. In Section 2, we provide the background of the volatility measures, the classical HAR model, and the random forests algorithm. We then discuss our proposed model and methodology and their results in Section 3. Section 4provides discussion of the study, and we conclude the results of this study in Section 5. 2. Materials and Methods 2.1. Random Forests Algorithm Breiman (2001) introduced the random forests (RF) algorithm as an ensemble approach that can also be thought of as a form of nearest neighbour predictor. The random forest starts with a standard machine learning technique called “decision trees”. We provide a brief summary of this algorithm in this section. 2.1.1. Decision Trees The decision trees algorithm is an approach that uses a set of binary rules to calculate a target class or value. Different from predictors like linear or polynomial regression where a single predictive formula is supposed to hold over the entire data space, decision trees aim to sub-divide the data into multiple partitions using a recursive method, and then fit simple models to each cell of the partition. Each decision tree has three levels: •Root nodes: entry points to a collection of data; • Inner nodes: a set of binary questions where each child node is available for every possible answer; •Leaf nodes: respond to the decision to take if reached. For example, in order to predict a response or class Y from inputs X1 , X2 , ..., Xn , a binary tree is constructed based on the information from each input. At the internal nodes in the tree, a test to one of the inputs is run for a given criterion with logical outcomes: TRUE or FALSE . Depending on the outcome, a decision is drawn to the next sub-branches corresponding to the TRUE or FALSE response. Eventually, a final prediction outcome is obtained at the leaf node. This prediction aggregates or averages all of the training data points which reach that leaf. Figure 1illustrates the binary tree concept. Algorithm 1describes how a decision tree can be constructed using CART from ( Breiman et al. 1984 ). This algorithm is computationally simple and quick to fit the data. In addition, as it requires no parametric, no formal distributional assumptions are required. However, one of the main disadvantages of tree-based models is that they exhibit instability and high variance, i.e., a small
J. Risk Financial Manag. 2018,11, 61 3 of 15 change in the data can result in a very different series of split, or over-fitting. To overcome such a major issue, we used an alternative ensemble approach known as the random forests algorithm. Algorithm 1: Classification And Regression Trees - CART algorithm for building decision trees. 1: Let Nbe the root node with all available data. 2: Find the feature Fand threshold value Tthat split the samples assigned to Ninto subsets ITRUE and IFALSE, to maximise the label purity within these subsets. 3: Assign the pair (F, T) to N. 4: If I(s)is too small to be split, attach a ‘child’ leaf node to LTRUE and LFALSE to Nand assign the leaves with the most present label in ITRUE and IFALSE, respectively. If subset I(s)is large enough to be split, attach child nodes NTRUE and NFALSE to N, and then assign I(s)to them, respectively. 5: Repeat steps 2–4for the new nodes N=NTRUE and N=NFALSE until the new subsets can no longer be split. Algorithm 1 CART algorithm for building decision trees. 1: Let Nbe the root node with all available data. 2: Find the feature Fand threshold value Tthat split the samples assigned to Ninto subsets IT RUE and IF ALSE , to maximise the label purity within these subsets. 3: Assign the pair (F, T) to N. 4: If I(s)are too small to be split, attach a ‘child’ leaf nodes LT RUE and LF ALSE to Nand assign the leaves with the most present label in IT RUE and IF ALSE respectively. If subset I(s)are large enough to be split, attach child nodes NT RUE and NF ALSE to N, then assign I(s)to them respectively. 5: Repeat step 2 - 4 for the new node N=NT RUE and N=NF ALSE until the new subsets can no longer be split. ROOT Q1.1 Q1.2 Q1.1.1 Q1.1.2 Decision A Decision B Decision C Decision D Decision E Decision F TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE Figure 1: A binary tree - starts from the root node, multiple criteria are selected based on the information from each input. A decision is drawn at a particular leaf, i.e. Decision D, if all criteria along its path “==” are satisfied . Random forests84 A random forest can be considered as a collection or ensemble of simple decision trees that are selected85 randomly. It belongs to the class of so-called bootstrap aggregation or bagging technique which aims86 to reduce the variance of an estimated prediction function. Particularly, a number of decision trees87 are constructed and random forests will either “vote” for the best decision (classification problems) or88 “average” the predicted values (regression problems). Here, each tree in the collection is formed by89 firstly selecting at random, at each node, a small group of input coordinates (also called features or90 variables hereafter) to split on and, secondly, by calculating the best split based on these features in the91 training set. The tree is grown using CART algorithm to maximum size, without pruning. Using random92 forests can lead to significant improvement in prediction accuracy (i.e. better ability to predict new data93 cases) in comparisons with a single decision tree as discussed in the previous section. Algorithm 2 from94 4 Figure 1. A binary tree—starting from the root node, multiple criteria are selected based on the information from each input. A decision is drawn at a particular leaf, i.e., Decision D, if all criteria along its path “==” are satisfied. 2.1.2. Random Forests A random forest can be considered to be a collection or ensemble of simple decision trees that are selected randomly. It belongs to the class of so-called bootstrap aggregation or bagging technique which aims to reduce the variance in an estimated prediction function. Particularly, a number of decision trees are constructed and random forests will either “vote” for the best decision (classification problems) or “average” the predicted values (regression problems). Here, each tree in the collection is formed by firstly selecting, at random, at each node, a small group of input coordinates (also called features or variables hereafter) to split on and secondly, by calculating the best split based on these features in the training set. The tree is grown using the CART algorithm to maximum size, without pruning. The use of random forests can lead to significant improvements in prediction accuracy (i.e., better ability to predict new data cases) in comparison with a single decision tree, as discussed in the previous section. Algorithm 2from Breiman (2001) details how the random forests can be constructed. For m= 1, the algorithm uses random splitter selection. m can also be set to the total number of predictor variables which is known as Breiman’s bagger parameter (Breiman 2001). In this paper, we set mas equal to the maximum number of variables of interest used in the proposed model. Applications of the random forests algorithm can be found in machine learning, pattern recognitions, bio-infomatics, and big data modelling. Recently, a number of financial literatures have applied the random forests algorithm to the forecasting of stock prices as well as in developing the investment strategies found in Theofilatos et al. (2012) and Qin et al. (2013). Here, we introduce an application of the random forests algorithm involving the forecasting of the realised volatility.
J. Risk Financial Manag. 2018,11, 61 4 of 15 Algorithm 2: Random forests 1: Draw a number of bootstrap samples from the original data (ntree) to be grown. 2: Sample N cases at random with replacement to create a subset of the data. The subset is then split into in-bag and out-of-bag samples at a selected ratio (i.e., 7:3). 3: At each node, for a preselected number m,mpredictor variables (mtry) are chosen at random from all the predictor variables. 4: The predictor variable that provides the best split, according to some objective function, is used to build a binary split on that node. 5: At the next node, choose another m variables at random from all predictor variables. 6: Repeat 3–5until all nodes are grown. 2.2. Volatility Measures Volatility, often measured by the standard deviation or variance of returns from a financial security or market index, is an important component of asset allocation, risk management, and pricing derivatives. In this section, we discuss the two measures of volatility known as the realised volatility and the purified implied volatility. 2.2.1. Realised Volatility The realised volatility measure was proposed by Andersen et al. (2003) in 2003 based on the use of high frequency data. Let S(t) represent the asset price which is observed at equally-spaced discrete points within a given time interval [t−δ , t] , where 0 ⩽t−δ⩽t⩽T , s(t) = log S(t) and r(t , δ) = s(t)−s(t−δ) . We assume that S(t)is represented by the following Ito equation ds(t) = µ(t)dt +σ(t)dW(t), 0 ⩽t⩽T, (1) where W(t) is a standard Brownian process, µ(t) and σ(t) are predictable processes with σ(t) being the standard deviation of ds(t) and independent of dW(t) . Therefore, the processes µ(t) and σ(t) represent the instantaneous conditional mean and volatility of the return. Hence, r(t,δ) = s(t)−s(t−δ) = Zt t−δµ(τ)dτ+Zt t−δσ(τ)W(t). (2) Following this result, let us assume that the time interval [t−δ , t] is observed evenly at 4 steps in discrete time. The realised volatility (RV) of S(t)can be estimated by RVt−δ,t=v u u tM−1 ∑ j=0 r2 t−j4, (3) where rt−j4=s(t−j4)−s(t−(j+ 1 )4) , 4=1 M , and M is the number of observations within that time interval. 2.2.2. The Purified Implied Volatility The implied volatility is often known as the ex-ante measure of volatility, and is derived from either the Black–Scholes’ options pricing model from Black and Scholes (1973) (model-based estimation) or from theoptions market price formula by Carr and Wu (2006) (model-free estimation). Such measures depend on several inputs, such as time-to-expiration, stock price, exercise price, risk-free-rate-of-interest, and observed call/put price. Hence, the implied volatility will vary in accordance with the fluctuations of these inputs. In order to reduce the impact of the stock price
J. Risk Financial Manag. 2018,11, 61 5 of 15 movements, the purified implied volatility (PV) was introduced in Luong and Dokuchaev (2014). The purified implied volatility is derived from the Black–Scholes options pricing model, where the market option prices are replaced by artificial option prices that reduce the impact of the market price from the observed option prices. The paper also shows that the purified implied volatility does contain information about the traditional volatility measure (i.e., the standard deviation of the low-frequency daily returns). In this paper, we include the purified implied volatility as an extended variable of the HAR model. 2.3. Models for Volatility 2.3.1. Heterogeneous Autoregressive Model for Realised Volatility Corsi (2003) (see also Corsi and Reno (2009)) proposed the heterogeneous autoregressive model for realised volatility as an extension of the Heterogenous ARCH (HARCH) class of models analysed by Muller et al. (1997), which recognizes the presence of heterogeneity in the traders. The idea stems from the “Fractal Market Hypothesis” (Peters 1994), “Interacting Agent View” (Lux and Marchesi 1999) and “Mixture of Distribution” hypotheses (Andersen and Bollerslev 1997) in the realised volatility process. It is noted that the definition of realised volatility involves two time parameters: (1) the intraday return interval 4 and (2) the aggregation period one day. For the heterogeneous autoregressive model of realised volatility from Corsi (2003), it is considered that the latent realised volatility is viewed over time horizons longer than one day. The n days historical realised volatility at time t (i.e., RVt−n,t ) is estimated as an average of the daily realised volatility between (t−n) and t . The daily HAR is expressed by RVt,t+1=β0+βDRVt−1,t+βWRVt−5,t+βMRVt−22,t+εt,t+1, (4) where W= 5 days, M= 22 days, and RVt−5,t , RVt−22,t present the average realised volatility of the last 5 days and 22 days, respectively. The HAR model can be extended by including the jump component proposed by Barndorff-Nielsen and Shephard (2001) such that ∑ t−δ⩽τ⩽t J2(τ)≡max{RV(t−δ,t)−BV(t−δ,t), 0}, (5) where BV is the realised bi-power variation Barndorff-Nielsen and Shephard (2004). Hence, the general form of the model is RVt,t+k=β0+βDRVt−1,t+βWRVt−5,t+βMRVt−22,t+βJJt−k,t+εt,t+k. (6) Most recently, the heterogeneous structure was extended with the inclusion of the leverage effect observed by Black (1976)—the asymmetry in the relationship between returns and volatility noticed by Corsi and Reno (2009). For a given period of time, the leverage level at time t is measured as the average aggregated negative and positive returns during that period where r+ t−k,t=1 M M−1 ∑ j=0 rt−j4,tI{rt−k,t,...,rt,t⩾0};r− t−k,t=1 M M−1 ∑ j=0 rt−j4,tI{rt−k,t,...,rt,t⩽0}, with M being the number of observations between t−k , t , and 4 is the time step. Therefore, one would include the leverage effect as a predictor for the realised volatility in the next kdays as follows: RVt,t+k=β0+βDRVt−1,t+βWRVt−5,t+βMRVt−22,t +βJJt−k,t+αPr+ t−k,t+αNr− t−k,t+εt,t+k. (7) Often, the coefficients β0 , βD , βW , βM , βJ , αP , αN are obtained by using the Ordinary-Least-Squares (OLS) estimation for linear regression models.
J. Risk Financial Manag. 2018,11, 61 6 of 15 2.4. The Modified HAR Model for Realised Volatility and Forecasting the Direction We define two states of the world outcome on the volatility direction as “UP” and “DOWN”. Let Dδbe the direction of the realised volatility observed at the time δ, such that Dδ= UP if RVδ RVδ−1 >1, DOWN if RVδ RVδ−1 <1. (8) In order to forecast the direction of realised volatility, a set of predictors (or technical indicators) is used which are derived from the historical price movement of the underlying asset and its realised volatility. Since all available historical information is used, Dδ does not follow a Markov chain. We investigated a number of indicators and through the feature selection process (using variable importance ranking from the random forest algorithm), we found that the following indicators were best for forecasting the realised volatility’s direction. 1. The Average True Range (ATR): The ATR is an indicator that measures volatility by using the high–low range of the daily prices. ATR is based on n-periods and can be calculated on an intraday, daily, weekly, or monthly basis. It is noted that ATR is often used as a proxy for volatility. To estimate ATRt, we are required to compute the “true range” (TR) such that TRδ=max{Hδ−Lδ,|Hδ−Cδ−1|,|L−Cδ−1|}, (9) where Hδ , Lδ , Cδ−1 are the current highest return, the current lowest return, and the previous last return of a selected period, respectively, with absolute values to ensure TRδ is always positive. Hence, the average true range within n-days is ATRδ−n,δ=(n−1)ATRδ−n−1,δ+TRδ n. (10) 2. Close Relative To Daily Range (CRTDR): The location of the last return within the day’s range is a powerful predictor of next-returns. Here, CRTDR is estimated by CRTDRδ=Cδ−Lδ Hδ−Lδ , (11) where, Hδ , Lδ and Cδ are the high, low, and close returns at time δ for a selected time period using high frequency returns. 3. Exponential Moving Average of realised volatility (EMARV): Exponential moving averages reduce the lag effect in time-series by applying more weight to recent prices. The weighting applied to the most recent price depends on the number of periods ( n ) in the moving average and the weighting multiplier (κ). The formula for EMARV of n-periods is as follows: EMARVδ−n,δ=RVδ−κ×EMARVδ−n−1,δ+EMARVδ−n−1,δ. (12) 4. Moving average convergence/divergence oscillator (MACD) measure of realised volatility: The MACD is one of the simplest and most effective momentum indicators. It turns two moving averages into a momentum oscillator by subtracting the longer moving average ( m -days) from the shorter moving average ( n -days). The MACD fluctuates above and below the zero line as the moving averages converge, cross, and diverge. We estimate the MACD for realised volatility as MACDRVδ,m,n=EMARVδ,m−EMARVδ,n. (13)
J. Risk Financial Manag. 2018,11, 61 7 of 15 5. Relative Strength Index for realised volatility (RSIRV): This is also a momentum oscillator that measures the speed and change of volatility movements. We define RSIRV as RSIRVδ−n,δ=1−1 1+RV+ δ−n,δ RV− δ−n,δ , (14) where RV+ δ−n,δ is the average increase in volatility and RV− δ−n,δ is the average decrease in volatility within n-days. The steps that we take to forecast the volatility direction are listed in Algorithm 3. Algorithm 3: Forecasting the direction of realised volatility 1: Obtain the direction of the realised volatility. 2: Compute the above technical indicators for each observation. 3: Split the data into a training set and a testing set. 4: Apply the random forests algorithm to the training set to develop the pattern solution of the realised volatility using the above indicators. 5: Use the solution from Step 4 to predict the direction of the testing set. Figure 2demonstrates a possible decision tree that was built for forecasting the direction of realised volatility Dδ using the above steps. In this example, node #4 can be reached when RSI-RV(5) ⩾ 0.5 and TR(10) < 0.0084, with 19% of the in-sample data falling into this category and 91% of these observations being classified as “DOWN”. Likewise, node #27 is reached when RSI-RV(5) ⩽ 0.5, r+⩾ 0.014, and 0.0049 ⩽TR( 10 )< 0.0072. In random forests, we can construct similar trees but with different structures to classify the direction of the realised volatility based on the information from other predictors. Let b Dt,t+k denote the predicted direction of the realised volatility at time t+k using Algorithm 3. RSI−RV(5) >= 0.5 TR(10) < 0.0084 RSI−RV(22) >= 0.52 Jump >= 0.013 TR(10) < 0.015 ATR−RV(10) >= 0.0097 TR(10) < 0.0072 Leverage (+) >= 0.014 TR(10) < 0.0049 RSI−RV(22) >= 0.48 DOWN .50 .50 100% DOWN .76 .24 42% DOWN .91 .09 19% DOWN .64 .36 23% DOWN .82 .18 10% DOWN .51 .49 13% DOWN .75 .25 4% UP .40 .60 9% UP .49 .51 7% DOWN .75 .25 3% UP .32 .68 4% UP .14 .86 2% UP .31 .69 58% DOWN .51 .49 19% DOWN .82 .18 5% UP .40 .60 14% DOWN .58 .42 6% DOWN .74 .26 4% UP .29 .71 2% UP .28 .72 9% UP .22 .78 39% yes no 1 2 4 5 10 11 22 23 46 92 93 47 3 6 12 13 26 52 53 27 7 Figure 2: A possible decision tree for classyfing the daily realised volatility direction using the technical indicators from the previous day. Figure 2 demonstrates a possible decision tree that was built for forecasting the direction of realised157 volatility Dδusing the above steps. In this example, node #4 can be reached when RSI-RV(5)⩾0.5and158 TR(10) <0.0084, with 19% of the in-sample data falls into this category and 91% of these observations159 are classified as“DOWN”. Likewise, node #27 is reached when RSI-RV(5)⩽0.5,r+⩾0.014 and160 0.0049 ⩽TR(10) <0.0072. In random forests, we can construct similar trees but with different struc-161 tures to classify the direction of the realised volatility based on the information from other predictors.162 Let b Dt,t+kdenote the predicted direction of realised volatility at time t+kusing the Algorithm 3.163 3.2 Forecasting the realised volatility164 To forecast the realised volatility, we consider the heterogeneous autoregression model as discussed in Section 2.3.1. We further include the purified implied volatility and the predicted direction of the future volatility as new predictive variables. Particularly, the model 2.7 is extended to RVt,t+k=β0+βDRVt−1,t +βWRVt−5,t +βMRVt−22,t +βJJt−k,t +α1r+ t−k,t +α2r− t−k,t +γP Vt−k,t+22 +κb Dt,t+k+εt,t+k.(3.8) 10 Figure 2. A possible decision tree for classifying the daily realised volatility direction using the technical indicators from the previous day.
J. Risk Financial Manag. 2018,11, 61 8 of 15 2.5. Forecasting the Realised Volatility—The Proposed Model To forecast the realised volatility, we consider the heterogeneous autoregression model as discussed in Section 2.3.1. We further include the purified implied volatility and the predicted direction of the future volatility as new predictive variables. Particularly, the model (7) is extended to RVt,t+k=β0+βDRVt−1,t+βWRVt−5,t+βMRVt−22,t+βJJt−k,t+α1r+ t−k,t +α2r− t−k,t+γPVt−k,t+22 +κb Dt,t+k+εt,t+k.(15) We also consider the logarithmic form of this model, as the logarithmic of the realised volatility is often believed to be a smoother process. Thus, we model log RV as log RVt,t+k=β0+βDlog RVt−1,t+βWlog RVt−5,t+βMlog RVt−22,t+βJlog (1+Jt−k,t) +α1log |r+ t−1,t|+α2log |r− t−1,t|+γlog(PVt−k,t+22) + κb Dt,t+k+εt,t+k,(16) where k={ 1, 5, 22 } for 1-day, 5-day, and 22-day time horizons. We use log (1+Jt−k,t) instead of log (Jt−k,t) to allow for the cases where Jt−k,t= 0, and the leverage effect is measured by log |r∗ t−1,t| to allow for the average aggregated negative returns. The parameters in models (15) and (16) (HAR-JL-PV-D) are fitted using the random forests regression algorithm. It is important to note that for the in-sample data, we replace b Dt,t+k with the actual direction Dt,t+k to measure the impact of the direction variable on the forecasting of the realised volatility. 3. The results 3.1. Measuring Errors Since the paper focuses on forecasting both the realised volatility’s direction and its magnitude, we used the following measures to compare each model. 3.1.1. Classification Problem In forecasting the direction of the realised volatility, the classification problem consists of only two stages. We measured the accuracy of the forecast as follows. Let us define the following terms • True positive (TP): The number of days that are observed with “DOWN” signals that were correctly predicted. • False positive (FP): The number of days that are observed with “DOWN” signals that were predicted to have “UP” signals. • False negative (FN): The number of days that are observed with “UP” signals that were predicted to have “DOWN” signals. • True negative (TN): The number of days that are observed with “UP” signals that were correctly predicted. •Accuracy: the proportion of the total number of correct predictions Accuracy =TP +TN TP +FP +TN +FN . (17) 3.1.2. Regression Problem We split our data into two subsets: the training (in-sample) data and the test (out-of-sample) data. Since we used the random forests algorithm, we measured the accuracy of the model proposed method for training data and test data separately.
J. Risk Financial Manag. 2018,11, 61 15 of 15 Theofilatos, Konstantinos, Spiros Likothanassis, and Andreas Karathanasopoulos. 2012. Modeling and Trading the EUR/USD Exchange Rate Using Machine Learning Techniques. ETASR—Engineering, Technology & Applied Science Research 2: 269–72. Whaley, Robert E. 2000. The investor fear gauge. The Journal of Portfolio Management 6: 12–17. [CrossRef] Zakoian, Jean-Michel. 1994. Threshold Heteroscedastic Models. Journal of Economic Dynamics and Control 18: 931–55. [CrossRef] c 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).