Sie sind auf Seite 1von 5

APPLICATION OF COMBINED ARMA-NEURAL NETWORK

MODELS TO PREDICT STOCK PRICES


Mohammad Umair Yaqub Mohammad Saad Al-Ahmadi
Electrical Engineering Department Accounting and MIS Department
King Fahd University of Petroleum and King Fahd University of Petroleum and
Minerals, KFUPM Box 767 Minerals, KFUPM Box 443
Dhahran 31261, Saudi Arabia Dhahran 31261, Saudi Arabia
+966535971232 +966552055577
umairy@kfupm.edu.sa alahmadi@kfupm.edu.sa

ABSTRACT algorithms and fuzzy logic. The most recent papers have tried to
Predicting the prices of stocks is a very important field of research improve these individual methods by combining ARMA models
nowadays. Many different types of models have already been with one or more of these AI techniques. In this research, we follow
implemented. Two types of techniques include ARMA models and the works of Shi and his colleagues [13], [14] as well as Kashei et
Neural Networks. In this work, ARMA models, along with two al [12].
types of Neural Networks (Back Propagation) and Multi-Layer An attempt is made to forecast the daily closing prices/values for
Perceptron (MLP) have been used. Furthermore, the two neural the Microsoft Corporation, Dow Jones Industrial Average (DJI),
networks were combined with ARMA models (individually) in and Saudi Stock Exchange Tadawul (TASI). ARMA models are
order to generate the best forecasted prices. The two indexes used used to predict the stock prices and then Back-Propagation Neural
for forecasting are the Dow Jones Industrial Average (DJI) and the Network (BPNN) and Multi-Layer Perceptron Neural Network
Saudi Stock Exchange Tadawul (TASI). 800 values were used to (MLP-NN) is used to optimize the residual errors form the ARMA
predict the future 200 values. It was found out that for such large forecast. The results of the individual models as well as the
number of predictions, MLP yields the best results, which are combined techniques are then tabulated and a comparison is made.
drastically improved when combined with ARMA forecasting.
The paper is split into the following sections. Section 2 is a brief
CCS Concepts literature review about the work done in literature by other
researchers. Section 3 is a description of some of the theory behind
• Applied Computing ➝ Law, social and behavioral sciences➝
the techniques used. ARMA models are discussed and Neural
Economics • Computing methodologies ➝ Machine learning ➝
Networks are described in general with an emphasis on BPNN’s
Machine learning approaches ➝ Neural networks and MLP-NN’s. In the next chapter, the overall process is described
Keywords and the details about the data are presented. Lastly, section 5
presents the various experiments performed along with the details
Auto-Regressive Moving Average (ARMA); Back-Propagation
of the models and tabulates the results. This part is performed using
Neural Network (BPNN); Multi-Layer Perceptron Neural Network
three sub-sections for each stock price dataset. Finally, we conclude
(MLP-NN); stock forecasting; Artificial Intelligence (AI).
our project with a hint on some future directions possible.
1. INTRODUCTION 2. LITERATURE REVIEW
The prediction of stock prices and trends is a very hot field of
Due to the nature and importance of the subject, various techniques
research. Many people invest their money in various assets
have been applied in research to predict the future prices of stocks.
nowadays and they would like to know the trends beforehand in
Two such techniques are the Auto-Regressive Moving Average
order to make the most informed decisions possible. A lot of work
(ARMA) models and the artificial intelligence technique called
has been done to predict the future values of various indices in the
Neural Networks (NN’s). In this section, we mention a couple of
stock market. Some of the techniques applied include financial
works that use financial models for prediction, then we introduce
mathematics and regression method such as the Auto-Regressive
AI techniques and finally we focus on some work in literature that
(AR) model, the Moving Average (MA) model and the combined
combines the two techniques to obtain better results.
ARMA model.
A different set of techniques were employed including methods The work of Anaghi and Nourouzi [1] discusses in details how to
from Artificial Intelligence (AI). AI techniques include Neural forecast prices using ARMA models. They analyze six different
Networks (NN), support vector machines (SVM), genetic transfer functions using equal number of poles and zeros at each
stage. The work of Chang and Ramakrishna [2] is slightly different
in that they compare the performances of ARMA, Generalized
Permission to make digital or hard copies of all or part of this work for Autoregressive Conditional Heteroskedasticity (GARCH), and NN
personal or classroom use is granted without fee provided that copies are not models. It is found that GARCH and NN models are more effective
made or distributed for profit or commercial advantage and that copies bear than ARMA models alone. This is one of the motivation to combine
this notice and the full citation on the first page. Copyrights for components
of this work owned by others than ACM must be honored. Abstracting with
BPNN with ARMA in order to achieve higher accuracy.
credit is permitted. To copy otherwise, or republish, to post on servers or to As far as AI techniques are concerned, Wu and Lu have covered a
redistribute to lists, requires prior specific permission and/or a fee. Request
wide range of NN based algorithms in their study [3]. The
permissions from Permissions@acm.org.
MISNC, SI, DS '16, August 15-17, 2016, Union, NJ, USA
algorithms covered include many different types of neural networks
© 2016 ACM. ISBN 978-1-4503-4129-5/16/08…$15.00 that are compared with respect to mean square errors as well as
DOI: http://dx.doi.org/10.1145/2955129.2955171 computation times. Some of the neural networks covered include
Self-Organizing Polynomial (SOP) NN’s and many types of Back There is a constant c, which can be taken as zero for simplicity as
Propagation Neural Networks (BPNN’s). well as the expected value µ. In this research, MATLAB is used as
a simulation tool to obtain the best values for p and q based on the
The idea of using only NN’s to predict the future stock price has minimum AIC criteria.
been explored in literature [4] - [6]. The work of Senanayake [4] is
concerned with using automated NN’s for forecasting. They 3.2 Neural Networks (NN’s)
employ an implementation of BPNN to predict the price depending NN’s were introduced to simulate the behavior of the human brain.
on historical process as well as qualitative factors by questionnaires Usually, they are formed of three layers. The input layer, one or
filled by experts. The work of Chih-Ming Hsu [5] is a more modern more hidden layers and the output layer. The job of the hidden layer
work that focuses on prediction based on two stages. In the first is to optimize the relation between the outputs and the inputs using
stage, the prices are normalized between 0 and 1 and then feature a heuristic or iterative approach such as the steepest descent method.
extraction is employed via the mean absolute percentage error In back-propagation, the hidden layer nodes or weights are
criteria. Finally, Khoa et al. [6] also propose a similar technique to optimized using the gradient descent method. On the other hand, in
[5] but the features used in the second stage are the adjusted profit MLP, there is no feedback and the weights are updated based on an
margins. activation function (in our case the logistic function is used). The
The research of Gomes et al. [9] again utilizes the same concept of output of any NN is the sum of the weights multiplied by the
hybridization but they use a specific Neural Network called DAN2 connected input nodes. MLP-NN is the most basic and earliest
designed by the authors of [10] and [11]. Lastly, the work done in neural network and most of the other architectures are derived from
[12] is focused on combine an ARIMA (AR Integrated MA) model it in literature. Therefore, the idea is to try the simplest NN in this
with probabilistic Neural Networks (MLP-NN’s). However, they project and test for improvements against the BPNN.
apply this to exchange rate prediction rather than stock prices.
Finally, this takes us to the work done in [13], which is done by the 4. PREDICTION MODEL
same authors as our reference paper. IN this model, they apply the
ARMA to the price of Petro China and fit the errors using BPNN
4.1 System Design and Data Description
model. Then they try to improve the accuracy by using the Hidden The work done by Shi et al. uses the ARMA and BPNN models to
Markov Model (HMM) algorithm. fit the data and choose the parameters that yield the least error [13]
and [14]. In the next step, both ARMA models and BPNN are used
3. BRIEF THEORETICAL BACKGROUND to forecast the prices individually. In the combining step,
In this research, three different models have been used for forecasting is done using the ARMA model and then BPNN is used
forecasting. The first one is the Auto-Regressive Moving Average to fix the errors introduced by the first stage. On the other hand, the
(ARMA) Model whereas the second model involves artificial work of [12] employs the same mechanism but for exchange rate
Neural Networks (NN’s). Two different types of NN’s have been prediction and instead of BPNN, MLP is used. In this project, the
used, the Back-Propagation NN (BPNN) and the Multi-Layer methodology of [13] and [14] is followed except that the last step
Perceptron NN (MLP-NN). In the original papers [1], they used the of Hidden Markov Models (HMM) is not applied. Instead, a new
ARMA model to predict the prices and then employed BPNN to model is tried where the BPNN is replaced by MLP. The
optimize the errors. In our case, experiments are performed with methodology is summarized in Figure 1. The ARMA and BPNN
both BPNN and MLP. Prior to describing the complete modelling is done using MATLAB whereas the MLP regression is
methodology of our system, we would like to begin by presenting performed using DTREG tool.
some theoretical background on these.

3.1 Auto-Regressive Moving Average


(ARMA)
The concept of ARMA filters was introduced in digital signal
processing DSP. The AR model assumes that a time-series is a
summation of the previous p number of terms itself weighted by
some parameter Φ. The errors are represented by e, which is
assumed to be white noise of Gaussian distribution. Equation 1
describes the AR model.
𝑝
𝑋𝑡 = 𝑐 + ∑𝑖=1 𝜑𝑖 𝑋𝑡−𝑖 + 𝑒𝑡    
The error terms can be estimated using the MA model as shown
below in equation 2. Usually, e is assumed to have normal
distribution and it is estimated using q terms.
𝑋𝑡 = 𝜇 + ∑𝑖=1 𝜃𝑖 𝑒𝑡−𝑖 + 𝑒𝑡 
𝑞

The combined model is given by equation 3. The total order of the


systems is defined as ARMA (p, q) where p represents the AR terms
and q represents the MA terms. The challenge is to develop a model
by selecting the best possible numbers of p and q as well as
estimating the parameters Φ and θ.
𝑝 𝑞
𝑋𝑡 = 𝑐 + 𝜇 + 𝑒𝑡 + ∑𝑖=1 𝜑𝑖 𝑋𝑡−𝑖 + ∑𝑖=1 𝜃𝑖 𝑒𝑡−𝑖 (3)
Figure 1: Complete System Process including BPNN and
MLP-NN
As one of our contributions, BPNN was replaced by MLP to test
whether it can improve on the results, especially for large datasets
such as the one chosen for DJI and TASI. Furthermore, the
experiments done in the reference papers involve the closing prices
of the Microsoft Corporation and Petro China; 320 samples are
used where the future prices of the 20 samples are predicted using
all of the models and the results are compared. In this experiment,
we try to predict the close values of the Dow Jones Industrial
Average (DJI) and Saudi Stock Exchange (TASI). Furthermore,
larger datasets are used where the data of approximately previous
four years is employed. This comes down to 1000 values, where
800 values are used to train the models and an attempt is made to
predict the future 200 values. Figure 2: ARMA-Fitted Data versus original for DJI

4.2 Error Definitions


Let us define the errors used to evaluate the performances in this
project. For the Microsoft Corporation, since the forecasted values
are only 20, it is feasible to show the results in one table. However,
for the DJI and TASI, 200 points are forecasted and it is not
practical to tabulate the results. Therefore, the performances have
been summarized in terms of the mean absolute percentage error
(MAPE), mean square error (MSE), root mean square error (RMSE)
and normalized root mean square error (NRMSE - percentage). The
formulae are given in equations 4-7.
1 𝑥𝑘 −𝑦𝑘
𝑀𝐴𝑃𝐸 = 100 ∗ ∑𝑁
𝑘=1 (6)
𝑁 𝑥𝑘
Figure 3: ARMA-Fitted Data versus original for TASI

1
𝑀𝑆𝐸 = ∑𝑁
𝑘=1(𝑥𝑘 − 𝑦𝑘 )
2
(7)
𝑁

1
𝑅𝑀𝑆𝐸 = √ ∑𝑁
𝑘=1(𝑥𝑘 − 𝑦𝑘 )
2 (8)
𝑁

1 𝑁
√ ∑ (𝑥 −𝑦𝑘 )2
𝑁 𝑘=1 𝑘
𝑁𝑅𝑀𝑆𝐸 = (9)
𝑚𝑎𝑥(𝑥)−𝑚𝑖𝑛(𝑥)

5. EXPERIMENTS AND RESULTS


As mentioned in the methodology, the experiments were carried out
using ARMA, BPNN, MLP, combined ARMA-BPNN and ARMA-
MLP. Two datasets are used: DJI and TASI from May 2010 to May Figure 4: BPNN-Fitted Data versus original closing values for
2014. Before displaying the results, let us display the fitted plots DJI
for all three indices.

5.1 Data Fitting Results


5.1.1 ARMA fitting
Based on the minimum AIC criterion, the ARMA model was
developed for both datasets. It was discovered that the best models
turned out to be ARMA (1, 5) for the DJI and ARMA (3, 5) for
TASI. The results of fitting the training data for all three are
presented in Figures 3 and 4. As you can observe, the fitting was
quite accurate and an initial forecast was made using this model.
The errors were later corrected using the two NN models.

5.1.2 BPP-NN fitting


In terms of fitting, BPNN performed very well as shown in Figures Figure 5: BPNN-Fitted Data versus original closing values for
4 and 5. However, as we will observe later, this model was not able TASI
to predict the future error values accurately. So although BPNN
provided a good fitting model, it was not very useful for the
purposes of prediction.
5.1.3 MLP-NN fitting
For this method, it was discovered that six hidden nodes give the
best results in terms of the MSE. Since the values are larger than
one (not normalized), this model should give the least RMSE and
NRMSE as well. As it can be observed, MLP-NN does not provide
a very good fitting model, but it is a better tool for prediction as it
was able to follow the trend better. This will be clear from the final
forecasting results in sections 5.2 and 5.3.

5.2 Forecasting Results for DJI


For the DJI as well as for the TASI, the forecasted range has 200
results. Therefore, a summary is provided below in Table 1 and
graphically presented in Figure 8. The results are summarized in Figure 8: Results of forecasting 200 stock values for DJI using
the following manner: Two subsections are used to detail the all models
models used for each index. The results are then tabulated as
follows: the model used is specified in the first column and each of
the four types of errors discussed in section IV part B are listed in Table 1: Summary of the Results for DJI
the next 4 columns of the same row. Model MAPE MSE RMSE NRMSE
It can clearly be observed for DJI that the best results are obtained ARMA 2.21 172990.00 415.92 7.17
when the MLPNN is used in conjunction with the ARMA model.
In terms of all of the errors, it seems that the ARMA-BPNN will MLP 1.46 55168.16 234.88 9.01
not work for DJI whereas MLP-NN alone improves the result ARMA- 2.24 173750.00 416.83 7.19
significantly. Overall, the best result is provided by the composite BPNN
ARMA-MLP technique and by observing Figure 8, the reason is ARMA- 0.64 18209.00 134.94 2.33
clear as the predicted values follow the actual very closely. This MLP
implies that the MLP-NN was the best stand-alone model in terms
of following the error trend.
5.3 Forecasting Results for TASI
Similar to what has been done for DJI, the 200 values have been
forecasted for TASI and the resulting errors have been summarized
in Table 2 and graphically displayed in Figure 9. Once again, the
pattern is similar. However, for this data the effects are even more
severe. The ARMA and ARMA-BPNN models fail to track the
progress of the curve and move in the opposite direction to the
general trend. On the other hand, MLP alone does follow the
direction of the trend but the error is still large. In contrast,
combining the both models yields the most successful results.

Figure 6: MLP-NN Fitted Data versus original closing values


for DJI

Figure 9: Results of forecasting 200 stock values for DJI using


all models
Table 2: Summary of the Results for TASI
Model MAPE MSE RMSE NRMSE
ARMA 16.12 2765000.00 1662.80 63.78
MLP 2.50 55168.16 234.88 22.15
Figure 7: MLP-NN Fitted Data versus original closing values ARMA- 16.35 2812900.00 1677.20 64.33
for DJI BPNN
ARMA- 0.58 4076.30 63.85 2.45
MLP
6. CONCLUSION [4] Senanayake, A., "Automated neural-ware system for stock market
prediction," Cybernetics and Intelligent Systems, 2004 IEEE
In conclusion, in this experiment ARMA, BPNN, MLP and Conference on , vol.2, no., pp.1166,1171, 1-3 Dec. 2004
combined ARMA-BPNN and ARMA-MLPNN models were used doi: 10.1109/ICCIS.2004.1460755
to predict stock prices/values. 800 historical values were used to
[5] Chih-Ming Hsu, "Forecasting stock/futures prices by using neural
predict the future 200 values form May 2010 all the way to May networks with feature selection," Information Technology and
2014 for DJI and TASI indexes. By applying the individual ARMA Artificial Intelligence Conference (ITAIC), 2011 6th IEEE Joint
and MLP models, it was discovered that the best stand-alone model International , vol.1, no., pp.1,7, 20-22 Aug. 2011
was MLP for both datasets, as the MAPE was reduced form 2.21% doi: 10.1109/ITAIC.2011.6030137
to 1.46% and 16.12% to 2.5% for both cases. Furthermore, [6] Khoa, N.L.D.; Sakakibara, K.; Nishikawa, I., "Stock Price Forecasting
combining ARMA with BPNN resulted in no improvements. using Back Propagation Neural Networks with Time and Profit Based
However, when ARMA model was combined with MLP-NN, it Adjusted Weight Factors," SICE-ICASE, 2006. International Joint
resulted in the best improvement. The MAPE went all the way Conference , vol., no., pp.5484,5488, 18-21 Oct. 2006
down to about 0.5% for both cases. In addition, the NRMSE was doi: 10.1109/SICE.2006.315683
also reduced all the way to about 2.5%. [7] Sallehuddin, R.; Shamsuddin, S.M.; Hashim, S.Z.M., "Hybridization
In the original paper, combining ARMA with BPNN results in a Model of Linear and Nonlinear Time Series Data for Forecasting,"
Modeling & Simulation, 2008. AICMS 08. Second Asia International
marked improvement. However, in our case, there is no Conference on , vol., no., pp.597,602, 13-15 May 2008
improvement when that particular model is used. This has to be
doi: 10.1109/AMS.2008.142
investigated and the reason may be that BPNN is only suitable for
prediction of small number of values. Moreover, he original authors [8] Abounoori, E.; Tazehabadi, A.G., "Forecasting Stock Price Using
Macroeconomic Variables: A Hybrid ARDL, ARIMA and Artificial
apply Hidden Markov Models to improve the predictions and this Neural Network," Information and Financial Engineering, 2009.
avenue can be explored further. It is possible that ARMA-BPNN ICIFE 2009. International Conference on , vol., no., pp.149,153, 17-
may not improve the results but with HMMM, the accuracy may 20 April 2009
increase. doi: 10.1109/ICIFE.2009.23
[9] Gomes, G.S.S.; Maia, A.L.S.; Ludermir, T.B.; de A.T.de Carvalho, F.;
7. ACKNOWLEDGMENTS Araujo, A. F R, "Hybrid model with dynamic architecture for
The authors would like to acknowledge the support provided by forecasting time series," Neural Networks, 2006. IJCNN '06.
King Abdulaziz City for Science and Technology (KACST) through International Joint Conference on , vol., no., pp.3742,3747, 0-0 0
the Science & Technology Unit at King Fahd University of doi: 10.1109/IJCNN.2006.247391
Petroleum & Minerals (KFUPM) for funding this work through [10] M. Ghiassi e H. Saidane, A dynamic architecture for artificial neural
project No. 09-INF769-04 as part of the National Science, network, Journal of Neurocomputing, 63, 397–413, 2005
Technology and Innovation Plan. [11] M. Ghiassi, H. Saidane e D. K. Zimbra, A dynamic artificial neural
network model for forecasting time series events, Journal of
8. REFERENCES forecasting, 21, 341–362, 2005
[1] Anaghi, M.F.; Norouzi, Y., "A model for stock price forecasting based [12] Khashei, M., Bijari, M., & Raissi Ardali, G. A. (2012). Hybridization
on ARMA systems," Advances in Computational Tools for of autoregressive integrated moving average (ARIMA) with
Engineering Applications (ACTEA), 2012 2nd International probabilistic neural networks (PNNs). Computers & Industrial
Conference on , vol., no., pp.265,268, 12-15 Dec. 2012 Engineering, 63(1), 37-45. doi: 10.1016/j.cie.2012.01.017
[2] W. A. Chang and R. S. Ramakrishna, “A genetic algorithm for shortest [13] Shuzhen Shi; Wenlong Liu; Minglu Jin, "Stock price forecasting using
path routing problem and the sizing of populations,” IEEE a hybrid ARMA and BP neural network and Markov model,"
Transactions on Evolutionary Computation, vol. 6, no. 6, pp. 566–579, Communication Technology (ICCT), 2012 IEEE 14th International
2002. 2010. Conference on , vol., no., pp.981,985, 9-11 Nov. 2012
[3] Hossain, A.; Nasser, M., "Comparison of GARCH and neural network doi: 10.1109/ICCT.2012.6511341
methods in financial time series prediction," Computer and
Information Technology, 2008. ICCIT 2008. 11th International [14] Shuzhen Shi; Wenlong Liu; Minglu Jin, " Stock Price Forecasting
Conference on , vol., no., pp.729,734, 24-27 Dec. 2008 Based on a Combined Model of ARMA and BP Neural Network and
Markov Model," International Journal of Information Processing and
Management(IJIPM), vol. 4, no. 3, 9-11 May. 2013

Das könnte Ihnen auch gefallen