Comparing the performance of the Auto-Regressive Integrated Moving Average (ARIMA) method with that of the Recursive Neural Network (RNN) of long-short term memory (LSTM) in forecasting stock price
الموضوعات :Ehsan Taieby sani 1 , Hossein Ameri 2
1 - Department of Finance, Faculty of Financial Sciences, Kharazmi University, Tehran, Iran
2 - Department of Finance, Faculty of Financial Sciences, Kharazmi University, Tehran, Iran
الکلمات المفتاحية: Price gaps, Abnormalities, Heteroscedasticity, Patterns,
ملخص المقالة :
In this research, due to the importance of investing and especially investing in the stock market, we predicted the stock price return on the stock exchange through the Auto-Regressive Integrated Moving Average (ARIMA) and Recursive Neural Network (RNN) of long-short term memory (LSTM). Then, to reduce the risk of decision-making, we compared the predictive power of these two models to determine a better model. The research variable is the stock price of the top 20 (in market cap) companies on the stock exchange for the period of the 11th Feb 2015 to 22th Jan 2022. We considered the data of the last 10 days as experimental data and the previous data as educational data. Initially, we calculated the mean and standard deviation of the prediction error of both models; these criteria had less value for the LSTM recursive neural network model than the ARIMA model. To measure the significance of this difference in predictive power, we used Harvey, Liborne, and New Bold tests. The results showed that in predicting the stock prices of the top 20 companies of the stock exchange, the predictive power of the LSTM recursive neural network model was statistically and significantly higher than the ARIMA model which means better predition of stock prices and higher return for investors. In the end, it is believed that the LSTM model may have the best predictive ability, but it is greatly affected by the data processing.
[1] ElAal, M.M,, Selim, G., Fakhr, W., Stock market trend prediction model for the Egyptian stock market using neural networks and fuzzy logic, InBio-Inspired Computing and Applications: 7th International Conference on Intelligent Computing, ICIC 2011, Zhengzhou, China, August 11-14. 2011; Revised Selected Papers 7 2012: 85-90. Springer Berlin Heidelberg. doi: 10.1007/978-3-642-24553-4_13
[2] Adebiyi, A.A., Adewumi, A.O., Ayo, C.K., Comparison of ARIMA and artificial neural networks models for stock price prediction, Journal of Applied Mathematics, 2014 Mar 5; 2014. doi: 10.1155/2014/614342
[3] AhmadKhanBeygi, S., Abdolvand, N., Stock Price Prediction Modeling Using Artificial Neural Network Approach and Imperialist Competitive Algorithm Based On Chaos Theory, Financial Management Strategy, 2017; 5(3): 27-73. doi: 10.22051/jfm.2017.14635.1319
[4] Ariyo, A.A., Adewumi, A.O., Ayo, C.K., Stock price prediction using the ARIMA model, In2014 UKSim-AMSS 16th international conference on computer modelling and simulation, 2014 Mar 26: 106-112. IEEE.
[5] Babajani, J., Taghva, M., Blue, G., Abdollahi, M., Forecasting Stock Prices In Tehran Stock Exchange Using Recurrent Neural Network Optimized by Artificial Bee Colony Algorithm, Financial Management Strategy, 2019; 7(2): 195-228. doi: 10.22051/jfm.2019.21049.1714
[6] Babu, C.N., Reddy, B.E., Performance comparison of four new ARIMA-ANN prediction models on internet traffic data, Journal of telecommunications and information technology, 2015; (1): 67-75.
[7] Bayat, A., Bagheri, Z., The Predication of Stock Price Using Firely Algorithm, Financial Knowledge of Securities Analysis, 2017; 10(35): 135-145.
[8] Becker, R., Clements A.E., Are combination forecasts of S&P 500 volatility statistically superior?. International Journal of Forecasting, 2008 Jan 1; 24(1):122-33. doi: 10.1016/j.ijforecast.2007.09.001
[9] Engle, RF., Autoregressive conditional heteroscedasticity with estimates of the variance of United Kingdom inflation, Econometrica: Journal of the econometric society, 1982 Jul 1:987-1007. doi: 10.2307/1912773
[10] Freisleben, B., Ripper, K., Volatility estimation with a neural network. InProceedings of the IEEE/IAFE 1997 Computational Intelligence for Financial Engineering (CIFEr), 1997 Mar 24, 177-181. IEEE. doi: 10.1109/CIFER.1997.618932
[11] Hafezi, R., Shahrabi, J., Hadavandi, E., A bat-neural network multi-agent system (BNNMAS) for stock price prediction: Case study of DAX stock price, Applied Soft Computing, 2015 Apr 1; 29: 196-210. doi: 10.1016/j.asoc.2014.12.028
[12] Hajizadeh, E., Seifi, A., Zarandi, MF., Turksen, IB., A hybrid modeling approach for forecasting the volatility of S&P 500 index return, Expert Systems with Applications, 2012 Jan 1; 39(1): 431-6. doi: 10.1016/j.eswa.2011.07.033
[13] Hamid, SA., Iqbal, Z., Using neural networks for forecasting volatility of S&P 500 Index futures prices, Journal of Business Research, 2004 Oct 1; 57(10):1116-25. doi: 10.1016/S0148-2963(03)00043-2
[14] Harvey, D., Leybourne, S., Newbold, P., Testing the equality of prediction mean squared errors, International Journal of forecasting, 1997 Jun 1;13(2): 281-91. doi: 10.1016/S0169-2070(96)00719-4
[15] Hochreiter, S., Schmidhuber, J., Long short-term memory, Neural computation. 1997 Nov 15; 9(8):1735-80. doi: 10.1162/neco.1997.9.8.1735
[16] Kaastra, I., Boyd, M., Designing a neural network for forecasting financial and economic time series. Neurocomputing. 1996 Apr 1;10(3):215-36. doi:10.1016/0925-2312(95)00039-9
[17] Khuat, TT., Le, MH., An application of artificial neural networks and fuzzy logic on the stock price prediction problem. JOIV: International Journal on Informatics Visualization. 2017 Apr 17; 1(2): 40-9.doi: 10.30630/joiv.1.2.20
[18] Laboissiere, L.A., Fernandes, R.A., Lage, G.G., Maximum and minimum stock price forecasting of Brazilian power distribution companies based on artificial neural networks, Applied Soft Computing, 2015 Oct 1; 35: 66-74. doi:10.1016/j.asoc.2015.06.005
[19] Lei, L., Wavelet neural network prediction method of stock price trend based on rough set attribute reduction, Applied Soft Computing, 2018 Jan 1;62:923-32. doi: 10.1016/j.asoc.2017.09.029
[20] Ma, Q., Comparison of ARIMA, ANN and LSTM for stock price prediction. InE3S Web of Conferences, 2020; 218: 01026. EDP Sciences.
[21] Monajemi, S.A. H., Abzari, M., Shavazi, R., A., Predicting stock prices in the stock market using fuzzy neural network and genetic algorithms and comparing it with an artificial neural network, Quantitative economics (Economic studies), 2009. doi: 10.22055/jqe.2009.10697
[22] Mpofu, N., Forecasting stock prices using a weightless neural network, Journal of Sustainable Development in Africa, 2006; 8(1): 115-9.
[23] Nasirzadeh, F., Evaluating the ability of data mining models to predict stock prices, Eleventh National Accounting Conference of Iran. 2012
[24] Roh, TH., Forecasting the volatility of stock price index, Expert Systems with Applications. 2007 Nov 1; 33(4): 916-22. doi:10.1016/j.eswa.2006.08.001
[25] Schöneburg, E., Stock price prediction using neural networks: A project report. Neurocomputing. 1990 Jun 1; 2(1): 17-27. doi: 10.1016/0925-2312(90)90013-H
[26] Selvin, S., Vinayakumar, R., Gopalakrishnan, E.A., Menon, V.K., Soman, K.P., Stock price prediction using LSTM, RNN and CNN-sliding window model. In2017 international conference on advances in computing, communications and informatics (icacci), 2017 Sep 13:1643-1647. IEEE. doi: 10.1109/ICACCI.2017.8126078
[27] Weng, B., Lu, L., Wang, X., Megahed, F.M., Martinez, W., Predicting short-term stock prices using ensemble methods and online data sources, Expert Systems with Applications. 2018 Dec 1;112: 258-73. doi: 10.1016/j.eswa.2018.06.016
[28] Yu, P., Yan, X., Stock price prediction based on deep neural networks. Neural Computing and Applications. 2020 Mar; 32: 1609-28. doi: 10.1007/s00521-019-04212-x
[29] Heydari Zare, B., Kordloui, H., Stock price prediction using artificial neural network, Researcher Management , Journal of Industrial Strategic Management, 2010; 7(17): 49-56. doi: 10.4108/eai.19-12-2018.156085
[30] Zhang, G.P., Time series forecasting using a hybrid ARIMA and neural network modelm, Neurocomputing, 2003 Jan 1; 50: 159-75.doi: 10.1016/S0925-2312(01)00702-0
Adv. Math. Fin. App., 2024, 9(2), P.448-460 | |
| Advances in Mathematical Finance & Applications www.amfa.iau-arak.ac.ir Print ISSN: 2538-5569 Online ISSN: 2645-4610 Doi: 10.22034/amfa.2023.1952556.1698 |
Comparing The Performance of The Auto-Regressive Integrated Moving Average (ARIMA) Method With That of The Recursive Neural Network (RNN) of Long-Short Term Memory (LSTM) In Forecasting Stock Price
| |||
Ehsan Taieby sani *, Hossein Ameri
| |||
Department of Finance, Faculty of Financial Sciences, Kharazmi University, Tehran, Iran | |||
Article Info Article history: Received 2022-02-13 Accepted 2022-11-27
Keywords: Abnormalities, Price gaps, Patterns, Heteroscedasticity. |
| Abstract | |
In this research, due to the importance of investing and especially investing in the stock market, we predicted the stock price return on the stock exchange through the Auto-Regressive Integrated Moving Average (ARIMA) and Recursive Neural Network (RNN) of long-short term memory (LSTM). Then, to reduce the risk of decision-making, we compared the predictive power of these two models to determine a better model. The research variable is the stock price of the top 20 (in market cap) companies on the stock exchange for the period of the 11th Feb 2015 to 22th Jan 2022. We considered the data of the last 10 days as experimental data and the previous data as educational data. Initially, we calculated the mean and standard deviation of the prediction error of both models; these criteria had less value for the LSTM recursive neural network model than the ARIMA model. To measure the significance of this difference in predictive power, we used Harvey, Liborne, and New Bold tests. The results showed that in predicting the stock prices of the top 20 companies of the stock exchange, the predictive power of the LSTM recursive neural network model was statistically and significantly higher than the ARIMA model which means better predition of stock prices and higher return for investors. In the end, it is believed that the LSTM model may have the best predictive ability, but it is greatly affected by the data processing. |
1 Introduction
Nowadays, the stock exchange market has become an integral part of the global economy; the economic conditions of individuals, companies, and the country are to some extent affected by any fluctuations in this sector. It has always been of interest to individuals and investors due to its higher average return than other markets. However, some factors affecting the stock exchange behavior are still unknown, which causes fluctuations and upward, downward and neutral trends. On the other hand, predicting the future behavior of stocks has become one of the most important subjects in financial science. Nowadays, to increase investment confidence and reduce the risk of buying stocks, by having information about past stock prices and using different scientific methods, we can predict its future price.
Predicting the future seems to be an ability that everyone wants to possess, especially when it can bring benefits. This may be why stock price forecasting is so popular. Although proponents of efficient market hypothesis believe that stock price fluctuations are impossible to predict, a considerable number of researchers claim that some models are acceptable as long as they can produce predictions with considerable accuracy. The most commonly used models are artificial neural networks (ANN) and autoregressive integrated moving average (ARIMA) models. Of course, in recent years, some researchers have proposed that long short-term memory (LSTM) networks has higher prediction accuracy. This article will focus on the differences in theses three models prediction results of the share price of the same corporation in a certain period, hoping to provide some convenience for later researchers.[20]
One of the tools for predicting the future behavior of stock is neural networks. Early neural networks were not capable of storing past information, so recursive neural networks were designed to address this problem. Recursive neural networks consist of a recursive loop that ensures that information gained from the previous moments is not lost and remains in the network. LSTM networks are a special type of recursive neural network that can learn long-term dependencies. These networks were first introduced in 1997 [15].Auto Regression Integrated Moving Average (ARIMA) is another important tool in time series analysis to predict the future prices of a variable based on its current value. ARIMA's goal is to identify the nature of relationships between residuals that provide a model with a certain degree of predictive power. [4]
The ARIMA model which is used for analysis and prediction has been considered as a very effective prediction technique, especially in social sciences. The prediction does not need to assume any underlying models or related equations. Because ARIMA's forecast results are derived from the values of the input variables and error terms. But limited to it is a linear regression model, ARIMA may have some deviations when facing complex nonlinear practical problems. However, in terms of short-term forecasting, the linear models usually outperform the complex structural models. ANN is a data-driven adaptive model, with almost no prior assumptions. It is used as a predictive model and is widely used in many fields including finance, commerce, and engineering. The prediction of ANN is based on the results obtained from the original data to make broad observations, and then infer the potential part of the whole. Unlike the ARIMA model, it is very effective in solving nonlinear problems. The changes in the stock market are also non-linear. Therefore, ANN can provide better results in terms of stock price prediction, compared with traditional models. Although ARIMA and ANN have been widely used in stock price forecasting, these models cannot measure the continuity of evolving price trends. LSTM is a variant of recurrent neural network. Unlike other methods, its feedback connection makes it easier to find development trends through the back propagation of current historical prices and current prices. However, since the LSTM model is rarely used in previous studies, and few research institutions conduct thorough preprocessing of the data, the performance of LSTM cannot be well demonstrated. This is also an important reason why it has not been widely used. [20]
[28] designed a DNN-oriented prediction model based on the PSR method and the recursive neural network of Long-Short Term Memory (LSTM) for deep learning and used it to predict stock prices. In this research, in addition to the proposed model, we used some other forecasting models to predict several stock indices for different periods. Comparison of the results showed that the proposed prediction model has a higher prediction accuracy than other prediction models. To improve the forecasting power of forecasting models [19], presented a hybrid model called RF-WNN, which arises from the integration of the Rough Set (RF) and the wavelet-based neural network (WNN), and forecasted stock price. The simulation results showed that reducing the data properties using RS simplifies the structure of the WNN forecasting model considerably but also improves the model performance. Given that the prediction results by this model were better than the results obtained by other neural networks, Support Vector Machine (SVM) and wavelet-based neural network, it is possible to establish the feasibility and effectiveness of the researcher's proposed method for predicting stock price trends.
Laboissiere and Fernandes [18] presented a new intelligent model for stock price forecasting in a multifactorial framework called the Bat-Neural Network Multi-Agent System (BNNMAS). The results showed that BNNMAS is remarkably accurate and reliable and can therefore be usable as a suitable tool for predicting stock prices, especially in long periods. In research [2] evaluated the performance of the ARIMA model and the artificial neural network model to predict stock prices using data of the New York Stock Exchange. The obtained experimental results show the superiority of the neural network model over the ARIMA model. These findings largely contradict the opposing views reported in the literature.
Accordingly, the purpose of this research is to determine the stock prices of the top 20 companies in the stock exchange market by considering their past behavior through two methods of autoregression integrated moving average (ARIMA) and recursive neural network (RNN) of long-short term memory (LSTM). Finally, it will evaluate the performance of the two to find a way that has a lower error and higher accuracy in forecasting stock prices.
The article is organized as follows. Section 1.1 outlines the Theoretical foundations of research. Section 2 discusses the Research methodology. Section 3 provide findings. Comparison of ARIMA and RNN Model established in Section 4. Finally, Section 5 concludes the paper
1.1. Theoretical Foundations of Research
The recursive neural network of Long-short term memory (LSTM)
Early versions of the recursive neural network have been unable to store long the information of the past inputs. This weakens the network in modeling long-term structures, and this "forgetfulness" causes these types of networks to be exposed to instability during sequence generation. The problem is that if the network predictions depend only on a few recent inputs and the network itself generates these inputs, there is very little chance for the network to correct past errors. Having a longer-term memory has a stabilizing effect because even if the network fails to understand its recent history, it is still able to complete its prediction with a look at the past. Long-short term memory, or LSTM for short, is a recursive neural network architecture designed to store and access information better than its original version. Unlike a traditional recursive neural network in which content is rewritten at every temporal step, in a LSTM recursive neural network, the network can make decisions about preserving current memory. LSTM is very powerful in predicting sequential issues because it can store past information. In stock price forecasting materials, this feature is very important because the previous stock price is a critical factor in predicting its future price. [26]
Method of autoregression Integrated moving average
The ARIMA model is usually represented by ARIMA (p, d, q). This display shows that this model consists of three parts AR, I, and MA, where p, d, and q are the parameters corresponding to these three parts, respectively. The steps that are often used in applying this model are to examine the necessary data conditions for the implementation of this model, to estimate the model parameters, to fit the model, and finally to predict and calculate the forecast error. In the first stage, the shape of the time series should be examined first to find any undesirable items, and if the time series was not continuous and had a trend, differentiation should be done, and if it had a heteroskedasticity, logarithmization should be done. Then it is time to determine the parameters of the model. In this stage, we specify the parameter d to the number of times that has been differentiated to base the time series. Then we determine the parameters p and q from the results of the study of the autocorrelation function and partial autocorrelation, respectively. Now, with these parameters, we make the model based on educational data and predict the experimental data with it. Finally, we calculate the prediction error. [4]
Then, we classified the existing studies in this field in terms of time. The following table summarizes the important information of the articles reviewed in this research.
Table 1: A Summary of Literature Review
Reference | Year | Approach |
[9] | 1982 | Heteroscedastic conditional auto-regression model |
[10] | 1997 | Generalized Heteroscedastic conditional auto-regression model |
[16] | 1999 | Artificial neural network |
[30] | 2003 | Autoregression integrated moving average (ARIMA) and artificial neural network |
[13] | 2004 | Comparison of Performance of Oscillation Predictions by Neural Networks and Implicit Oscillation of S&P 500 Index Using Baron-Adsi and Wali Pricing Model |
[22] | 2006 | Weightless neural network |
[24] | 2007 | Combined models using neural network and time series |
[8] | 2008 | Comparison of the performance of combined models of S&P 500 fluctuation forecast and other model-based forecasts |
[21] | 2009 | Fuzzy neural network and genetic algorithms |
[29] | 2010 | Multilayer perceptron model of artificial neural networks |
[1] | 2011 | Artificial neural network and fuzzy logic |
[23] | 2012 | Support vector regression (SVR) models, minimum degree estimator (LARS), neural-fuzzy network (ANFIS) |
[12] | 2013 | Hybrid model based on exponential generalized Heteroscedastic conditioned regression model and artificial neural networks for predicting S&P 500 index fluctuations |
[2] | 2014 | Autoregression integrated moving average model (ARIMA) and artificial neural network |
[18] | 2015 | Multifactorial system of bat neural network |
[11] | 2015 | Artificial neural network |
[17] | 2017 | Comparison of the function of fuzzy logic and multilayer perception, which is a kind of artificial neural network |
[19] | 2018 | Rough set and wavelet-based neural network |
[7] | 2018 | Glowworm algorithm |
[3] | 2018 | Neural network training with optimization algorithms (combination of chaotic mapping and colonial competition algorithm) |
[5] | 2019 | Recursive neural network based on artificial bee colony algorithm (ABC-RNN) |
[28] | 2020 | A deep neural network-based prediction model based on phase-space reconstruction method and recursive neural network of long-short term memory |
The present research is deductive in terms of approach, post-event in terms of nature, and applied in terms of purpose. The statistical population of this research was the companies listed on the Tehran Stock Exchange, among which we selected as a sample 20 top companies that were present at least in the period 11/02/2015 to 22/01/2022 and did not have a significant price gap in that period (because this would lead to a forecast error). We received their modified data (to eliminate the gap due to capital increase and cash dividend distribution) from the TSECLIENT site and used them to obtain the identities of each stock from www.tsetmc.com. In this research, we predict the stock price using ARIMA and LSTM methods.
To examine whether there is a statistically significant difference in the predictive power of the two methods, we use the Debold-Mariano test or, when the sample is small, Harvey, Liborne, and Newbold tests [14]. For this reason, in this research, we have used Harvey, Liborne, and New Bold tests to measure significantly the difference in predictive power of the two methods. We have in this test:
Auto-covariance calculation formula in log k:
| (1) |
| (2) |
| (3) |
Symbol | p | d | q |
Mobin | 2 | 1 | 3 |
Websader | 2 | 1 | 1 |
Pasargad | 6 | 1 | 3 |
Wamid | 1 | 2 | 3 |
Tapico | 3 | 2 | 3 |
Shabandar | 3 | 2 | 1 |
Fars | 3 | 2 | 3 |
Hamrah | 1 | 2 | 1 |
Parsan | 3 | 2 | 3 |
Shapna | 3 | 1 | 4 |
Akhaber | 1 | 1 | 3 |
Hakashti | 4 | 2 | 3 |
Rampna | 2 | 2 | 3 |
Fakhuz | 4 | 1 | 2 |
Foulad | 8 | 2 | 5 |
Kagol | 1 | 2 | 0 |
Kachad | 5 | 2 | 1 |
Va Maaden | 2 | 1 | 5 |
Va Ghadir | 1 | 2 | 4 |
Famli | 1 | 2 | 1 |
After obtaining the model parameters, we construct the model based on the educational data and predict the experimental data values using the sarima.for command from the astsa library, and finally, we must illustrate the actual values and the predicted values.
The following diagram shows the output of the implementation of this algorithm on one of the symbols. In this diagram, the vertical axis is price. The horizontal axis is the time that shows the last 100 days. In the last 10 days, as it is clear, the real value is displayed in black and the predicted value in red.
Fig. 1: ARIMA output for Websader symbol
3.2. Recursive Neural Network (RNN) of Long-Short Term Memory (LSTM)
All stages of implementing Recursive Neural Network (RNN) of Long-Short Term Memory (LSTM) have been performed using Python programming language. In the first step, it is necessary to load the data received from TSECLIENT software using Python programming language. For this purpose, we have used the read_csv command from the Pandas library. In the second step, to determine the forecast horizon, we referred to the field literature and similar articles were the basis for decision-making. Weng, Wang, Megahed and Martinez [27] and Babu and Reddy[6] were among the researchers whose researches were the basis of our work and according to them, we determined the time horizon of prediction. Therefore, in this research, the period under the study of each share is from 11/02/2015 to 01/22/2022. The data of the last 10 days is experimental data and the previous data is educational data.
In this research, it is necessary to change the stock price over time from 0 to 1. For this purpose, we have used the MinMaxScaler function from Sklearn library and Sklearn.preprocessing module in Python programming language; its calculation formula is as follows:
| (4) |
| ARIMA | LSTM |
| ||||||
Symbol | MAD | MSE | RMSE | MAPE | MAD | MSE | RMSE | MAPE | Superiority |
Mobin | 1344.3 | 2430292.2 | 1558.9 | 8.9 | 688.5 | 612720.6 | 782.8 | 4.7 | LSTM |
Websader | 142.4 | 23309.9 | 152.7 | 16.6 | 61.7 | 4071.5 | 63.8 | 7.4 | LSTM |
Pasargad | 93.7 | 13549.9 | 116.4 | 11.0 | 118.9 | 16966.5 | 130.3 | 14.4 | ARIMA |
Wamid | 634.6 | 503578.0 | 709.6 | 5.5 | 418.2 | 240014.6 | 489.9 | 3.4 | LSTM |
Tapico | 633.2 | 525417.6 | 724.9 | 14.2 | 451.2 | 273447.7 | 522.9 | 10.1 | LSTM |
Shabandar | 241.9 | 106163.4 | 325.8 | 2.6 | 265.6 | 93325.8 | 305.5 | 2.8 | ARIMA |
Fars | 177.5 | 44575.6 | 211.1 | 2.2 | 265.3 | 91193.6 | 302.0 | 3.4 | ARIMA |
Hamrah | 3043.5 | 12827156.5 | 3581.5 | 13.7 | 2673.4 | 7934902.1 | 2816.9 | 12.4 | LSTM |
Parsan | 366.2 | 221957.1 | 471.1 | 4.5 | 317.7 | 129189.5 | 359.4 | 4.0 | LSTM |
Shapna | 123.9 | 22013.3 | 148.4 | 2.3 | 212.2 | 59913.6 | 244.8 | 3.9 | ARIMA |
Akhaber | 678.0 | 588545.1 | 767.2 | 8.7 | 627.1 | 420803.8 | 648.7 | 8.1 | LSTM |
Hakashti | 1868.6 | 3727706.9 | 1930.7 | 13.6 | 965.6 | 1284929.0 | 1133.5 | 4.7 | LSTM |
Rampna | 2848.8 | 9492642.2 | 3081.0 | 15.9 | 2787.7 | 8362633.8 | 2891.8 | 15.9 | LSTM |
Fakhuz | 442.9 | 278615.2 | 527.8 | 3.3 | 386.6 | 198325.1 | 445.3 | 2.9 | LSTM |
Foulad | 167.0 | 38333.1 | 195.8 | 3.7 | 157.6 | 45185.2 | 212.6 | 3.3 | LSTM |
Kagol | 933.5 | 1074620.7 | 1036.6 | 13.9 | 660.5 | 480266.3 | 693.0 | 9.8 | LSTM |
Kachad | 291.8 | 109098.7 | 330.3 | 4.2 | 204.4 | 63980.5 | 252.9 | 3.0 | LSTM |
Va Maaden | 396.3 | 200423.7 | 447.7 | 14.7 | 318.6 | 126015.1 | 355.0 | 12.0 | LSTM |
Va Ghadir | 292.1 | 112749.6 | 335.8 | 6.3 | 194.5 | 54925.8 | 234.4 | 4.2 | LSTM |
Famli | 268.8 | 97698.4 | 312.6 | 4.0 | 265.2 | 92595.1 | 304.3 | 3.8 | LSTM |
After calculating the types of errors for both forecasting methods, it was necessary to examine statistically the mean and variance of the errors corresponding to each method in forecasting the price of 20 stocks. After performing the calculations, the result was that in general, the mean and standard deviation of error criteria for the LSTM method is less than the ARIMA method; so we can see that the predictive power of the LSTM method is more than the ARIMA method. In the table below, we calculated the mean and standard deviation of the prediction errors, and the mentioned results are observable.
Table 4: Mean and Standard Deviation of Prediction Errors
| ARIMA | LSTM | ||||||
| MAD | MSE | RMSE | MAPE | MAD | MSE | RMSE | MAPE |
Mean | 749.5 | 1621922 | 848.3 | 8.5 | 6.2 | 1029270 | 659.5 | 6.7 |
Standard deviation | 850.6 | 3347265 | 949.9 | 5.1 | 742 | 2391500 | 770.9 | 4.1 |
So far, we have been able to see that there is a difference in the predictive power of these two methods and the LSTM method has some advantages. However, is this difference statistically significant?
We have used the DM.test function of the multDM library in the R programming language to implement the Dibold-Mariano and Harvey, Liborne, and Newbold tests on the prediction results. The table below shows the results of this test for the predictions made by both methods. The null hypothesis in this test is that the predictive power of both methods is equal. In the test result column, we have presented the value of test statistic, p-value, and Alpha/2, and in the last column of this table, we have shown whether the null hypothesis is rejected according to p-value and Alpha/2.
Table 5: Harvey, Liborn, and New Bold Tests
Symbol | The test result of Harvey, Liborn, and New Bold |
|
Mobin | Harvey, Leybourne and Newbold test on Mobin Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 13.66756269, p-value = 0.0000003, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Websader | Harvey, Leybourne and Newbold test on Vabesader Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 2.9981563, p-value = 0.0150011, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Wamid | Harvey, Leybourne and Newbold test on Vaomid Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 4.0238599, p-value = 0.0030006, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Tapico | Harvey, Leybourne and Newbold test on Tapiko Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 3.9792357, p-value = 0.0032095, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Hamrah | Harvey, Leybourne and Newbold test on Hamrah Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 9.3910395, p-value =0.0000060, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Parsan | Harvey, Leybourne and Newbold test on Parsan Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 4.4601539, p-value = 0.0015769, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Akhaber | Harvey, Leybourne and Newbold test on Akhaber Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 4.9766057, p-value = 0.0007630, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Hakashti | Harvey, Leybourne and Newbold test on Hekeshti Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 11.7179281, p-value = 0.0000009, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Rampna | Harvey, Leybourne and Newbold test on Remapna Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 3.3191677, p-value = 0.0089522, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
| ||
Table 5: continue | ||
Fakhuz | Harvey, Leybourne and Newbold test on Fakhouz Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 12.6647009, p-value = 0.0000035, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Foulad | Harvey, Leybourne and Newbold test on Foulad Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 2.0584516, p-value =0.0696545, alpha/2=0.025 null hypothesis: Two forecasts have the same accuracy | Not rejected |
Kagol | Harvey, Leybourne and Newbold test on Kegol Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 3.3191677, p-value = 0.0089522, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Kachad | Harvey, Leybourne and Newbold test on Kechad Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 7.7797807, p-value = 0.0000276, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Va Maaden | Harvey, Leybourne and Newbold test on Vamaden Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 7.2921098, p-value = 0.0000460, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Va Ghadir | Harvey, Leybourne and Newbold test on Vaghadir Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic =11.1816981, p-value = 0.0000014, alpha/2=0.025 alternative hypothesis: Forecast f1 is more accurate than f2. | Rejected |
Famli | Harvey, Leybourne and Newbold test on Femeli Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 0.0738379, p-value = 0.9427544, alpha/2=0.025 null hypothesis: Two forecasts have the same accuracy | Not rejected |
Shabandar | Harvey, Leybourne, and Newbold test on Shebandar Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 0.3184985, p-value = 0.7660435, alpha/2=0.025 null hypothesis: Two forecasts have the same accuracy | Not rejected |
Fars | Harvey, Leybourne, and Newbold test on Fars Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 5.3072073, p-value = 0.0060576, alpha/2=0.025 alternative hypothesis: Forecast f1 is less accurate than f2. | Rejected |
Shapna | Harvey, Leybourne, and Newbold test on Shepna Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 3.5228063, p-value = 0.0243882198, alpha/2=0.025 alternative hypothesis: Forecast f1 is less accurate than f2. | Rejected |
| Harvey, Leybourne, and Newbold test on Vapasar Stock Price Forecasts data: f1:LSTM and f2:ARIMA and Actual Price statistic = 2.3087672, p-value = 0.0463299, alpha/2=0.025 alternative hypothesis: Forecast f1 is less accurate than f2. | Rejected |
4 Comparison and Discussion
Comparison of ARIMA and RNN Model. Many academics have compared ARIMA and RNN models capability for predicting stock prices. By checking the results, we can find that the prediction of the RNN model tends to predict the numerical value of the stock price. Because of linear model assumptions the ARIMA model's prediction is directional. Although it can be seen from the chart that the RNN of long-short term memory (LSTM) graph is closer to the fluctuation of the real stock price, there is no significant difference in the accuracy of the prediction results of the ARIMA and RNN models.
The present research compared the performance of the method of Auto-Regressive Integrated Moving Average (ARIMA) and that of Recursive Neural Network (RNN) of long-short term memory (LSTM) in forecasting stock price. In this research, we took the following steps.
In the first step, after implementing the two forecasting methods on each of the 20 introduced symbols, we calculated 4 types of forecasting errors. The results showed that in predicting the future price of 16 symbols, the LSTM method had less forecast error; but, after calculating the types of errors for both forecasting methods, it was necessary to examine statistically the mean and variance of the errors corresponding to each method in predicting the price of 20 stocks. After performing the calculations, the result was that in general, the mean and standard deviation of error criteria for the LSTM method is less than the ARIMA method; so we can see that the predictive power of the LSTM method is more than the ARIMA method.
In the second step, according to the result of the first step (a difference in the predictive power of the two methods), it was necessary to investigate whether this difference is statistically significant or not. After Harvey, Liborne, and New Bold test to measure the same/different prediction accuracy of the two methods under study, we compared the resulting P-value and the Alpha value (0.05). The result of this test was a significant difference in the predictive power of the LSTM recursive neural network method compared to the ARIMA method. After these two steps, we can conclude that statistically, the predictive power of the LSTM recursive neural network method is more than the ARIMA method for 20 symbols under study (selected from the top 50 symbols in the stock exchange that do not have significant gaps).
By inflation, the average nominal profit of companies increases after a period due to the devaluation of money. Therefore, rising inflation increases dividends and, consequently, the stock return index. Therefore, we expect a positive relationship between rising inflation and the stock cash return index. For future researches, we suggest that researchers also consider the effect of inflation on the design of forecasting models to increase forecasting accuracy.
5 Conclusion
Base on analysis of the models, conclusions can be made. The RNN model is better than that of the ARIMA model, and the performance of the LSTM model may be more due to the RNN. The disadvantage is that, as we all know, the fluctuation of stock prices is not only related to changes in time, but also related to economic factors, socio-political factors, and the listing of other stocks. Although the LSTM model introduces other variables than the other two models to distinguish market fluctuations and sudden changes, the models are essentially presumed by using possible relationships in the time series without considering other external factors. This is also the direction in which future research can be further in-depth. Of course, the further development and use of LSTM model in stock price prediction is also a subject of research value.
Reference
[1] ElAal, M.M,, Selim, G., Fakhr, W., Stock market trend prediction model for the Egyptian stock market using neural networks and fuzzy logic, InBio-Inspired Computing and Applications: 7th International Conference on Intelligent Computing, ICIC 2011, Zhengzhou, China, August 11-14. 2011; Revised Selected Papers 7 2012: 85-90. Springer Berlin Heidelberg. doi: 10.1007/978-3-642-24553-4_13
[2] Adebiyi, A.A., Adewumi, A.O., Ayo, C.K., Comparison of ARIMA and artificial neural networks models for stock price prediction, Journal of Applied Mathematics, 2014 Mar 5; 2014. doi: 10.1155/2014/614342
[3] AhmadKhanBeygi, S., Abdolvand, N., Stock Price Prediction Modeling Using Artificial Neural Network Approach and Imperialist Competitive Algorithm Based On Chaos Theory, Financial Management Strategy, 2017; 5(3): 27-73. doi: 10.22051/jfm.2017.14635.1319
[4] Ariyo, A.A., Adewumi, A.O., Ayo, C.K., Stock price prediction using the ARIMA model, In2014 UKSim-AMSS 16th international conference on computer modelling and simulation, 2014 Mar 26: 106-112. IEEE.
[5] Babajani, J., Taghva, M., Blue, G., Abdollahi, M., Forecasting Stock Prices In Tehran Stock Exchange Using Recurrent Neural Network Optimized by Artificial Bee Colony Algorithm, Financial Management Strategy, 2019; 7(2): 195-228. doi: 10.22051/jfm.2019.21049.1714
[6] Babu, C.N., Reddy, B.E., Performance comparison of four new ARIMA-ANN prediction models on internet traffic data, Journal of telecommunications and information technology, 2015; (1): 67-75.
[7] Bayat, A., Bagheri, Z., The Predication of Stock Price Using Firely Algorithm, Financial Knowledge of Securities Analysis, 2017; 10(35): 135-145.
[8] Becker, R., Clements A.E., Are combination forecasts of S&P 500 volatility statistically superior?. International Journal of Forecasting, 2008 Jan 1; 24(1):122-33. doi: 10.1016/j.ijforecast.2007.09.001
[9] Engle, RF., Autoregressive conditional heteroscedasticity with estimates of the variance of United Kingdom inflation, Econometrica: Journal of the econometric society, 1982 Jul 1:987-1007. doi: 10.2307/1912773
[10] Freisleben, B., Ripper, K., Volatility estimation with a neural network. InProceedings of the IEEE/IAFE 1997 Computational Intelligence for Financial Engineering (CIFEr), 1997 Mar 24, 177-181. IEEE. doi: 10.1109/CIFER.1997.618932
[11] Hafezi, R., Shahrabi, J., Hadavandi, E., A bat-neural network multi-agent system (BNNMAS) for stock price prediction: Case study of DAX stock price, Applied Soft Computing, 2015 Apr 1; 29: 196-210. doi: 10.1016/j.asoc.2014.12.028
[12] Hajizadeh, E., Seifi, A., Zarandi, MF., Turksen, IB., A hybrid modeling approach for forecasting the volatility of S&P 500 index return, Expert Systems with Applications, 2012 Jan 1; 39(1): 431-6. doi: 10.1016/j.eswa.2011.07.033
[13] Hamid, SA., Iqbal, Z., Using neural networks for forecasting volatility of S&P 500 Index futures prices, Journal of Business Research, 2004 Oct 1; 57(10):1116-25. doi: 10.1016/S0148-2963(03)00043-2
[14] Harvey, D., Leybourne, S., Newbold, P., Testing the equality of prediction mean squared errors, International Journal of forecasting, 1997 Jun 1;13(2): 281-91. doi: 10.1016/S0169-2070(96)00719-4
[15] Hochreiter, S., Schmidhuber, J., Long short-term memory, Neural computation. 1997 Nov 15; 9(8):1735-80. doi: 10.1162/neco.1997.9.8.1735
[16] Kaastra, I., Boyd, M., Designing a neural network for forecasting financial and economic time series. Neurocomputing. 1996 Apr 1;10(3):215-36. doi:10.1016/0925-2312(95)00039-9
[17] Khuat, TT., Le, MH., An application of artificial neural networks and fuzzy logic on the stock price prediction problem. JOIV: International Journal on Informatics Visualization. 2017 Apr 17; 1(2): 40-9.doi: 10.30630/joiv.1.2.20
[18] Laboissiere, L.A., Fernandes, R.A., Lage, G.G., Maximum and minimum stock price forecasting of Brazilian power distribution companies based on artificial neural networks, Applied Soft Computing, 2015 Oct 1; 35: 66-74. doi:10.1016/j.asoc.2015.06.005
[19] Lei, L., Wavelet neural network prediction method of stock price trend based on rough set attribute reduction, Applied Soft Computing, 2018 Jan 1;62:923-32. doi: 10.1016/j.asoc.2017.09.029
[20] Ma, Q., Comparison of ARIMA, ANN and LSTM for stock price prediction. InE3S Web of Conferences, 2020; 218: 01026. EDP Sciences.
[21] Monajemi, S.A. H., Abzari, M., Shavazi, R., A., Predicting stock prices in the stock market using fuzzy neural network and genetic algorithms and comparing it with an artificial neural network, Quantitative economics (Economic studies), 2009. doi: 10.22055/jqe.2009.10697
[22] Mpofu, N., Forecasting stock prices using a weightless neural network, Journal of Sustainable Development in Africa, 2006; 8(1): 115-9.
[23] Nasirzadeh, F., Evaluating the ability of data mining models to predict stock prices, Eleventh National Accounting Conference of Iran. 2012
[24] Roh, TH., Forecasting the volatility of stock price index, Expert Systems with Applications. 2007 Nov 1; 33(4): 916-22. doi:10.1016/j.eswa.2006.08.001
[25] Schöneburg, E., Stock price prediction using neural networks: A project report. Neurocomputing. 1990 Jun 1; 2(1): 17-27. doi: 10.1016/0925-2312(90)90013-H
[26] Selvin, S., Vinayakumar, R., Gopalakrishnan, E.A., Menon, V.K., Soman, K.P., Stock price prediction using LSTM, RNN and CNN-sliding window model. In2017 international conference on advances in computing, communications and informatics (icacci), 2017 Sep 13:1643-1647. IEEE. doi: 10.1109/ICACCI.2017.8126078
[27] Weng, B., Lu, L., Wang, X., Megahed, F.M., Martinez, W., Predicting short-term stock prices using ensemble methods and online data sources, Expert Systems with Applications. 2018 Dec 1;112: 258-73. doi: 10.1016/j.eswa.2018.06.016
[28] Yu, P., Yan, X., Stock price prediction based on deep neural networks. Neural Computing and Applications. 2020 Mar; 32: 1609-28. doi: 10.1007/s00521-019-04212-x
[29] Heydari Zare, B., Kordloui, H., Stock price prediction using artificial neural network, Researcher Management , Journal of Industrial Strategic Management, 2010; 7(17): 49-56. doi: 10.4108/eai.19-12-2018.156085
[30] Zhang, G.P., Time series forecasting using a hybrid ARIMA and neural network modelm, Neurocomputing, 2003 Jan 1; 50: 159-75.doi: 10.1016/S0925-2312(01)00702-0
* Corresponding author. Tel.: +989124806133 E-mail address: Ehsan_Taieby_sani@khu.ac.ir |
|
© 2024. All rights reserved. Hosting by IA University of Arak Press |