You are on page 1of 4

Proceedings of the 2nd International Conference on Trends in Electronics and Informatics (ICOEI 2018)

IEEE Conference Record: # 42666; IEEE Xplore ISBN:978-1-5386-3570-4

Comparative Analysis of Various Stock Prediction


Techniques
Aakanksha Sharaff Meenakshi Choudhary
Department of Computer Science and Technology Department of Computer Science and Technology
National Institute of Technology Raipur, India National Institute of Technology Raipur, India
asharaff08@gmail.com meenakshi.choudharym96@gmail.com

Abstract—The analysis of stock market prediction is very Stock Market Prediction (or Forecasting) has a lot of scope
interesting subject. It influences lives of investors as they need to in the coming future. A number of models have been proposed
decide upon the choice of stocks to invest on a daily basis. This for prediction of stock market indices over the years [10,
involves a lot of risk analysis as the decisions they take might lead 11].Algorithms that have ability to predict future stock values
them to loss. However, if the right decisions can be made by using accurately have a huge financial incentive for whoever has
some algorithms then this would make millionaires out of many access to them [12]. An exact prediction about tomorrow can’t
investors. This aspect alone encourages many investors and also be made accurately, but from past experiences a roughly
mathematicians to study the field of stock market analysis. But estimate about tomorrow can be predicted. In this paper, a
making a right decisions on when to invest or not is a complicated
knowledge based approach upon various forecasting
task. This paper involves the comparative study of various stochastic
models such as ARIMA model, Artificial Neural Network, Holt-
techniques has been discussed. In the field of time series
Winters model and Recurrent Neural Network to predict the closing forecasting, R has created itself an alternative for many
stock indices of Standard’s & Poor Bombay Stock Exchange sensex. Programmers, Researchers and institutes. R has extensive
facilities for analyzing time series data. In this paper, various
Keywords—Stock Market; Forecasting; ARIMA model; Holt diverse techniques has been utilized and compared with their
Winters; Neural Nets; RNN predicted accuracy by calculating the MAPE (Mean Absolute
Percentage Error).
I. INTRODUCTION
II. LITERATURE SURVEY
Stock market may be viewed as a small loan in which there
is no guarantee of the refund. A number of people invest Several researchers proposed different models and analyzed
money in the company and in return they own some stock of the predicted value of stock market. Billah et. al. proposed an
the company. The more you invest, the more share you can improved Levenberg Marquardt (LM) training algorithm of
own. Later depending upon the price at which stocks are sold, artificial neural network which can predict the possible day-
you may earn or lose. Prediction of stock marketing is based end closing stock price with less memory and time [1]. P. K.
upon information. The data in stock markets are of 2 types- Mahato and V. Attar proposed ensemble models for prediction
structured data and unstructured data [1-3]. Stock market of gold and silver stocks [2]. S. S. Luo et al. studied the impact
analysis has become one of the challenging and fascinating of specific events on stock prices and proposed an event-
topics of research as it is a highly risky due to its highly driven stock prediction, using L1 regularized Logistic
volatile and complex nature [4-7]. There are various regression model and got a conclusion that L1 logistic
economic factors which affect the market and decide whether regression is the optimal model from the comprehensive effect
the market will run in bull mode and bearish model [8]. point of view [3]. Chen and Hao proposed a hybridized
Consequently they affect our day to day life in a rather direct framework composed of FWSVM and FWKNN based on the
way. Hence they comprise of a mechanism which has direct
information gain, and apply this new framework to forecast
and significant social impacts. Unpredictability is a feature
two Chinese stock market indices [4]. Y. Zuo and E. Kita used
that all Stock Markets are characterized by, which is somehow
the The P/E ratio forecast algorithm by using Bayesian
related to their short-term and long-term effect on future.
Prediction of stock prices has been considered as one of the network for stock market prediction[5]. Anbalagan and
most challenging and risky applications in the modern time Maheswari proposed a FM approach for stock market decision
series prediction [9]. The stock market closing price is the last making, classification and prediction for short term investors
bidding price at which the security is traded on a particular of Indian stock market [6]. Various researchers proposed a
day. For the purpose of analysis, the closing stock indices of new method for stock market prediction, uses Bayesian
S&P Bombay Stock Exchange sensex for six consecutive network, dynamical Bayesian factor graph, adopts the Long
years (2007 to 2012) have been used and different stochastic Short-Term Memory (LSTM) neural network and incorporates
models have been used for comparative analysis. investor sentiment and market factors to improve forecasting
performance [7-10]. By extracting investor sentiment from

978-1-5386-3570-4/18/$31.00 ©2018 IEEE 735


Proceedings of the 2nd International Conference on Trends in Electronics and Informatics (ICOEI 2018)
IEEE Conference Record: # 42666; IEEE Xplore ISBN:978-1-5386-3570-4

forum posts using Naïve Bayes, this paper makes it possible to adds the concept of integration. It is mostly applicable for
analyze the irrational component of stock price. Different stationary time series. If it is not stationary time, it is
forecasting parameters has been demonstrated in order to differentiated until it becomes stationary as most of the
provide a new qualitative method for the prediction of stock times data contains randomness i.e. it is not stationary. It
market trend [11, 12]. involves the following steps:-

III. PROPOSED MODEL AND METHODOLOGY


Different techniques from diverse domains has been studied
for carrying out the proposed model which includes ARIMA
model, Holt winters, Neural Nets and Recurrent Neural
Network. The dataset collected involves the closing stock
prices of sensex for six consecutive years (2007 -2012) on a
monthly basis. The methodology adopted is as follows-
1. The first step involves pre-processing of the dataset. In
this, initially the data set from Bombay S&E closing stock
indices of the year 2007 – 2012 has to be loaded to the
workspace, then the data obtained has to be converted to
time series data. R has multiple ways of representing time
series. Since the authors are working with daily prices of
stocks, they have consider that financial markets are
closed on weekends and business holidays so that trading
Fig. 1 Flow Diagram of Prediction using ARIMA Model
days and calendar days are not the same. However, the
time series may be given in terms of both calendar days or
trading days. Consider an example, the per day stock ARIMA model has certain parameter which is defined as:
returns are calculated from daily closing prices on a x p: also called lag , which is the number of lag terms
sequential basis regardless of whether a weekend of the Autoregressive model
intervenes. But sometimes estimating weekly price x d: also called the degree of differentiation which is
summary or calendar based reporting may be required. the number of times the series is to be differenced
For these reasons the xts package, an extension of zoo, is
x q: also termed as moving average order which is the
commonly used with financial data in R. An example of
how it could be used with data is as follows. size of the moving average window
A linear regression model is build which includes the
stocks <- xts( data1[,-1], order.by = as.Date appropriate number and type of p and q terms, and the
(data1[,1],"%d/%m/%Y")) (1) time series is prepared by differentiating it a number of
The next step involves removal of seasonal trends present times thereby removing seasonal terms and trends that
in the data. There are many sophisticated techniques in the have a negative impact on regression model hence
branch of Time Series Analysis to study to remove making it stationary.
seasonality from time series. Since the work is mainly acf(ds)
focused in time series forecasting and predictive analysis, pacf(ds)
the models are based on historical data and could be used auto.arima(ds)
for predicting new data. mydata.arima<-arima(ds,order=c(1,0,1)) (3)
StlStock =stl(timeseries,S.Window=“Periodic”) (2)

2. After removing the seasonal trends present in the data, the


next step is modeling. In this work, various models as
ARIMA model, Artificial Neural Nets and Holt Winters
and Recurrent Neural Network has been used.

a) Arima Model

An ARIMA model is a statistical model which is used for


the analysis and prediction of time series data. It provides a
easy and powerful method for analyzing and forecasting
time series by explicitly catering to a set of standard
structures in time series data. ARIMA stands for Fig. 2 Plot of Actual and Forecasted value Vs Time for Arima model
AutoRegressive Integrated Moving Average. It is a
generalized study of AutoRegressive Moving Average and

978-1-5386-3570-4/18/$31.00 ©2018 IEEE 736


Proceedings of the 2nd International Conference on Trends in Electronics and Informatics (ICOEI 2018)
IEEE Conference Record: # 42666; IEEE Xplore ISBN:978-1-5386-3570-4

layer. The number of neurons in the hidden layer could be


b) Holt-Winters adjusted in ANN but unfortunately, there is no unique
method for determining the optimum number of neurons in
When the time series contains trend and seasonal factors, hidden layer for a particular problem.
the appropriate model is Holt Winters. It breaks up the
Npred <- nnetar(ds,repeats = 20,p=5,P=1,size=3)
series into three parts that is the trend, base and seasonality
pred1 <- predict(Npred,n.ahead = 9) (5)
components. This model finds three smoothening
parameters that constitute trend, level and seasonal terms.
It has two variations, Additive Holt Winters Smoothening
model and Multiplicative Holt-Winters model. The former
is used for forecasting and the latter is preferred when
seasonal variations in the series are not constant. Holt
winters is mainly popular for its accuracy and it has
outperformed many other models in the domain of
Prediction. Holt-Winters exponential smoothing method,
with trend and seasonal fluctuations is usually used in
short-term forecast of economical development trend.
After removing the seasonal trends from the data, it is
taken as input for the function mentioned below and in
return the Holt Winters makes the pre calculations that are
necessary for the forecasting purpose. All the parameters
that are necessary for the forecasting purpose will be
Fig. 4 Plot of Actual and Forecasted value Vs Time for ANN model
initialized automatically based up on the data given to the
function.
HWStock1_ng= HoltWinters(ds,gamma=FALSE)
predHW=predict(HWStock1_ng,n.ahead=9) (4) d) Recurrent Neural Network

RNN are called as recurrent because they perform the


same task for every element of a sequence with the
output dependent on the previous computations.
model <- trainr( Y= trainy,X=trainx,learningrate
=0.05,hidden_dim = 5,numepochs = 2600)
pred <- predictr(model,testx) (6)

Fig. 3 Plot of Actual and Forecasted value Vs Time for Holt-Winters


model

c) Artificial Neural Nets


Artificial Neural Network is considered as one of the most Fig. 5 Plot of Actual and Forecasted value Vs Time for Recurrent
efficient techniques in the field of data analytics [12]. Neural Network model
However neural networks are complex and are termed as
black box as they allow the users to view the input and IV. DISCUSSION ON RESULTS
output of a neural network without having knowledge of
The last step involves evaluating the performance of
the internal process. Neural networks consists of a number
various models. Figure 1, Figure 2, Figure 3 and Figure 4
of simple processing elements operating in parallel. In a
shows the observed and forecasted value for different
neural network model, lagged terms can be used just as it is
models. In order to measure the accuracy of predictions
used in Autoregression model. The lagged values of time
made by prediction models, precision is taken as one of
series data could be used as input to neural network. In
the important measure. Mean Absolute Percentage Error
forecasting problem, the number of inputs and number of
is one of the important methods which is used to evaluate
processing elements i.e. neurons are flexible in the hidden
layer whereas there is only a single neuron in the output

978-1-5386-3570-4/18/$31.00 ©2018 IEEE 737


Proceedings of the 2nd International Conference on Trends in Electronics and Informatics (ICOEI 2018)
IEEE Conference Record: # 42666; IEEE Xplore ISBN:978-1-5386-3570-4

the accuracy and precision of the predictions made. It is REFERENCES


termed as MAPE in acronym. [1] M. Billah, S. Waheed, and A. Hanifa, “Stock Market Prediction
Using an Improved Training Algorithm of Neural Network,”
Mean absolute percentage error (also called as MAPE in Comput. Telecommun. Eng., vol. 8, no. December, pp. 8–10, 2016.
[2] P. K. Mahato and V. Attar, “Prediction of gold and silver stock price
acronym) is used to measure percentage of divergence of using ensemble models,” 2014 Int. Conf. Adv. Eng. Technol. Res.
the predicted Stock prices through the predictive models ICAETR 2014, pp. 5–8, 2014.
from the actual Stock Prices. It is calculated as [3] S. S. Luo, Y. Weng, W. W. Wang, and W. X. Hong, “L1-
regularized logistic regression for event-driven stock market
mape_model<-mean(abs((actual-pred)/actual ))*100 (6) prediction,” 2017 12th Int. Conf. Comput. Sci. Educ., no. Iccse, pp.
536–541, 2017.
Table 1 MAPE values of the different models [4] Y. Chen and Y. Hao, “A feature weighted support vector machine
and K-nearest neighbor algorithm for stock market indices
Model MAPE prediction,” Expert Syst. Appl., vol. 80, pp. 340–355, 2017.
[5] Y. Zuo and E. Kita, “Stock price forecast using Bayesian network,”
ARIMA 3.99251 Expert Syst. Appl., vol. 39, no. 8, pp. 6729–6737, 2012.
[6] T. Anbalagan and S. U. Maheswari, “Classification and Prediction
Holt-Winters 12.56901 of Stock Market Index Based on Fuzzy Metagraph,” Procedia
Neural network 2.83544 Comput. Sci., vol. 47, pp. 214–221, 2015.
[7] R. K. MacKinnon and C. K. Leung, “Stock Price Prediction in
RNN 5.808394 Undirected Graphs Using a Structural Support Vector Machine,”
2015 IEEE/WIC/ACM Int. Conf. Web Intell. Intell. Agent Technol.,
pp. 548–555, 2015.
[8] Agarwal, Udit, and A. Sai Sabitha. "Time series forecasting of stock
market index." Information Processing (IICIP), 2016 1st India
Predictions of the Stock market prices that are generated
International Conference on. IEEE, 2016.
using these stochastic techniques including the ARIMA [9] Al-hnaity, Bashar, and Maysam Abbod. "Predicting financial time
Model, Holt Winters Artificial Neural Nets and Recurrent series data using hybrid model." Intelligent Systems and
Neural Network are easy to implement, Reliable and Applications. Springer, Cham, 2016. 19-41.
Justifiable. As per the results observed Neural Network has [10] L. Wang, Z. Wang, S. Zhao, and S. Tan, “Stock market trend
prediction using dynamical Bayesian factor graph,” Expert Syst.
better accuracy when compared to the other predictive models Appl., vol. 42, no. 15–16, pp. 6267–6275, 2015.
in terms of the Mean absolute percentage error. After this [11] J. Li, H. Bu, and J. Wu, “Sentiment-aware stock market prediction:
Arima model seems to be a promising model. The A deep learning method,” 2017 Int. Conf. Serv. Syst. Serv. Manag.,
pp. 1–6, 2017.
performance of these techniques may be affected by the data
[12] A. A. Ariyo, A. O. Adewumi, and C. K. Ayo, “Stock Price
sparsity and therefore there is a great scope of conducting Prediction Using the ARIMA Model,” 2014 UKSim-AMSS 16th Int.
research in this field. New models and technologies are Conf. Comput. Model. Simul., pp. 106–112, 2014.
needed to improve the accuracy of prediction as the need for
these predictive models is increasing drastically especially in
the field of stock market prediction.

V. CONCLUSION AND FUTURE WORK


The task of stock market analysis and prediction is very
difficult due to its non linear, dynamic and changing nature.
However in the recent time, many machine learning
techniques have been used effectively for stock market
prediction. Various mathematical models such as ANN, Arima
model have been analyzed for robustness in the task of
prediction stock market price. However there is still need of
exploring ensemble models in this field. In this paper, ANN
model has been compared with other models for making
prediction and has produced really impressive results. The
model has been proven robust in predicting the future stock
market indices. The robustness of the model has been checked
by evaluating various parameters such as accuracy, precision
as calculated by MAPE. In order to improve the accuracy of
forecasting model, hybrid models could be effectively used for
complex time series that has both linear and non-linear
components.

978-1-5386-3570-4/18/$31.00 ©2018 IEEE 738

You might also like