Comparison of Financial Models for Stock Price Prediction

: Time series analysis of daily stock data and building predictive models are complicated. This paper presents a comparative study for stock price prediction using three different methods, namely autoregressive integrated moving average, artiﬁcial neural network, and stochastic process-geometric Brownian motion. Each of the methods is used to build predictive models using historical stock data collected from Yahoo Finance. Finally, output from each of the models is compared to the actual stock price. Empirical results show that the conventional statistical model and the stochastic model provide better approximation for next-day stock price prediction compared to the neural network model.


Introduction
Predicting modeling is one of the most popular mathematical methods in many fields such as business, social science, engineering, and finance. In business, predictive modeling is also known as predictive analytics. Among many, one of the most important applications of predictive modeling is to predict the stock price. Modern predictive modeling can be categorized into two basic categories such as statistical and soft computing techniques (Adebiyi et al. 2014). Autoregressive integrated moving average (ARIMA) is one of the most popular and widely used statistical techniques for making predictions using past observations (Meyler et al. 1998). In spite of having great popularity in making predictions, this method has some limitations such as seasonality, non-stationarity, and other factors (Tambi 2005). In contrast, as a machine learning method or soft computing technique, artificial neural networks (ANNs) are one of the most accurate and widely used forecasting models for forecasting, pattern recognition, and image processing (Khashei and Bijari 2010). Neural network models have become more popular in forecasting over the last decade in business, economics, and finance (Avcı 2007). According to Khashei and Bijari (2010), ANNs are distinguished and most effective for predictive modeling because of their data-driven self-adaptive nature and they are universal function approximators. The network can generalize, this means that once the network learns the data, it can predict the unseen or future part of the data even if the given data is not smooth.
In addition to the above two methods, stochastic modeling that uses geometric Brownian motion to predict the stock price is very popular. Brownian motion is a special type of motion of molecular particles, first observed and described by the British-Scottish botanist in 1827. However, Louis Bachelier, a French mathematician named this Brownian motion and proposed a model to predict stock prices using Brownian motion in 1900. According to the geometric Brownian motion model, the returns on a certain stock in successive, equal periods of time are independents and normally distributed (Dmouj 2006). The equation of geometric Brownian motion has a constant volatility and drift, but in real-world scenario these are not constant and vary over time (Estember and Maraña 2016). Hence, we consider time variant volatility and drift in our analysis.
There are many researchers using the three basic techniques: ARIMA, ANN, and stochastic models to predict stock prices, which will be reviewed in the next section. However, in the literature, there are no comparisons of using each of the three models to predict prices of one stock. Most of the researchers compared performances of the two models ARIMA and ANN in stock price predictions, but not all of the three methods. Therefore, in this paper, we build predictive models using all of the above three modeling techniques and compare the models' performance for stock price predictions, which are discussed in the subsequent sections. Section 2 represents the literature review and related works. In Section 3, we describe the general theories for each of the methods and then build the models specifically for S & P 500 index. In Section 4, we describe the results from each of the three models and model diagnostics. Section 5 contains the conclusions.

Literature Review
Prediction has long been a popular field in mathematical science, so there is plenty of related research in the field. The first significant study of neural network models for stock price prediction was done by (White 1988). His predictive model was based on IBM's daily common stock and the training predictions were very optimistic. Thereafter, a lot of research was performed to check the neural networks' accuracy of prediction to forecast the stock market. Hassan et al. (2007) proposed a fusion model by combining the hidden Markov model (HMM), artificial neural network (ANN), and genetic algorithms (GA) to forecast financial market behavior. They found that the performance of the fusion tool is better than that of the basic model (Hassan and Nath 2005) where they used only a single HMM. They also indicated that the performance of the fusion model is similar to that of the ARIMA model. Zhang and Wu (2009) proposed an integrated model improved bacterial chemotaxis optimization (IBCO) and back propagation artificial neural network to predict the S & P 500 index. The IBCO based back propagation (or IBCO-BP) model is less computationally complex and has better accuracy. Khashei and Bijari (2010) found that the performance of a neural network for some real time series is not satisfactory. Hence, using ARIMA models, they suggested a novel hybrid type of artificial neural network. The proposed model provided better predictions for three separate actual datasets than just the neural artificial network model. Yao et al. (1999) compared the back propagation neural network model and ARIMA model stock index forecasting. They found that the neural network results in better accuracy in forecasting than the traditional ARIMA models. Adebiyi et al. (2014) compared the forecasting performance by ARIMA and artificial neural network for stock data. They analyzed daily stock prices for the Dell Incorporation and found a superiority of the neural network model over the ARIMA model. Merh et al. (2010) developed a three-layer feed-forward neural network model and auto-regressive integrated moving average model to predict the future value of the stock price and revealed that the ARIMA models perform better over ANN models. Lee et al. (2007) did a comparative study of the forecasting performance by neural network models and the time series model (SARIMA) for the Korean Stock Index data. They also found ARIMA models outperforming ANN models for the stock price prediction. Agustini et al. (2018) used several stock indexes under the Jakarta Corporate Index to build a predictive model with Brownian motion. They found a higher accuracy for prediction with a mean absolute percentage error (MAPE) less than 20%. Rathnayaka et al. (2014) developed a forecasting model using the geometric Brownian motion model and compared the predictions with the results from the traditional time series model ARIMA. They used the Colombo Stock Exchange (CSE), Sri Lanka data to build their models and found that the stochastic model prediction is more significant than the traditional model.
The literature shows different opinions on the relative performances of the two of the three models depending on data. Hence, further comparative studies of all the three models can assemble a consistent methodology for stock price prediction. In this paper, we study the comparative performances of the three models in predicting next-day stock prices for S & P 500 index data from Yahoo Finance.

Methodology
The methodology section contains the basic four subsections. The first subsection describes the data that were used to build the models. Then, each of the subsections describes general theories and procedures to build the models and then how the models were fitted for a particular dataset. The overall performance of each of the models was checked by the analysis of the residuals and four different error measures, namely the absolute percentage error (APE), the average absolute error (AAE), the average relative percentage error (ARPE), and the root-mean-square error (RMSE) (Nguyet Nguyen and Wakefield 2018). The formula to calculate these errors are as follows: (1)

Data
S & P 500 daily stock for the period 1 January 2015 to 31 December 2019 was used in this research. We used the quantmod package (Ryan et al. 2020) in statistical software R, version 1.2.1335 to collect the data directly from Yahoo Finance. Initially, the dataset contains six variables, namely daily Open, High, Low, Close, Volume, and Adjusted Close price. Addition to the six variables, we created two more variables, i.e., Average and Return. The Average variable is the average of daily Open, High, Low, and Close price. All the predictive models were built to predict the Adjusted Close price for the next day on the basis of the present day's predictor variables. There were 63 trading days per quarter in 2019. All the models were used to predict the next-day stock price for the last quarter of 2019. A total of 63 predictions were made.

ARIMA(p,d,q) Models
The time series analysis requires the stationarity of the data, meaning the statistical properties such as mean, variance, and so on do not change over time. However, most of the real-world data, like stock data, are non-stationary by nature. This non-stationarity can be taken care of by using the Box-Jenkins ARIMA(p,d,q) approach (Makridakis and Hibon 1997) (Cryer and Kellet 1991). A generalised ARI MA(p, d, q) model can be written as where φ 1 , φ 2 , . . . , φ p and θ 1 , θ 2 , . . . , θ q are the autoregressive and moving average parameters, respectively, and e s are the white noise. The autoregression AR(p), order p, and moving average MA(q), order q, are determined from the analysis of the autocorrelation function. The number d indicates the number of differences applied to the time series to remove the trend. The autoregressive parameters φ s and moving average parameters θ s are estimated from the model based on p, d, and q.

ARIMA(p,d,q) Model for S & P 500 Index
The adjusted close price of S & P 500 is a time series process {X t } that has been analysed to build the model. The process {X t } is not a stationary process, if we see the following graphs. Figure 1 shows an upward trend in the data. Inspecting the sample autocorrelation plot from Figure 2, it is clear that the Auto Correlation Function (ACF) dies down very slowly and the Partial Autocorrelation Function (PACF) cuts off at lag 1 with correlation one.  The slow dying-down nature of the ACF indicates that the process is non-volatile. That is, the current value is relating with all the past values. These facts ensure the process is non stationary. To make the process stationary, we transform the {X t } series to the {Y t } = {log X t } series and then to a new series Figure 3 is the window plot of the second differenced log transformed stock price. From this plot, the data looks stationary and randomized. Stationarity has been confirmed from the augmented Dickey-Fuller test (Cheung and Lai 1995) with a p value of 0.01, where the alternative hypothesis was stationary. Next, the autoregressive and moving average orders p and q were determined from the PACF and ACF plot from Figure 4.  The ACF cuts of at lag 1 which indicates that the process incorporates an MA process of order q = 1 whereas the PACF gradually dies down. Therefore, the series W t follows an MA(1) process or the series Y t follows an I MA(2, 1) process i.e. Y t ∼ ARI MA(0, 2, 1). Other ARI MA(p, d, q) models were also considered in this research, as shown in Table 1. The best model has been chosen based on the Schwarz Bayesian Information Criterion (BIC) (Neath and Cavanaugh 2012) criteria, the more negative, the more accurate model. The reason of not choosing Akaike Information Criterion (AIC) or Bias Corrected Akaike Information Criterion (AICc) is that those models provide over-fitting and non significant parameters.
From Table 1, the ARI MA(0, 2, 1) model has the most negative BIC value which fits the data most perfectly. The Arima function with order (p, d, q) = (0, 2, 1) was run in RStudio and the summary of the model is displayed in Table 2.  Table 2. ARIMA(0,2,1) model summary.

Model
Arima(x = tr.stock, order = c(0, 2, 1)) MA (1) Finally, substituting the MA parameter θ = −1 in Equation (2), the model for Y t = log X t is given as A fixed window of 1194 past observed stock prices have been used to predict each of the next-day prices using the model in Equation (3). Hence, the training dataset moved and the end price of the window was updated with the actual price. The results and diagnostics of this model are discussed in Section 4.1.

Stochastic Model Geometric Brownian Motion
A process that generates some outcomes which are time-dependent but can not be said ahead of time is known as a stochastic process. A stochastic process It has independent increments. That is, for any t 1 , t 2 , . . . , t n , A stochastic process {X(t) : 0 < t < T} is said to be a general Brownian motion with a drift parameter µ and diffusion coefficient σ 2 if is a standard Brownian motion, written as X(t) ∼ BM(µ, σ 2 ).
The general Brownian motion still follows first two properties of the standard Brownian motion. However, the third property is modified as X(t) − X(s) ∼ N(µ(t − s), σ 2 (t − s)) for any 0 ≤ s < t < T.

Geometric Brownian Motion (GBM) Model
If X(t) ∼ BM(µ, σ 2 ) then X(t) satisfies the stochastic differential equation (Yang and Aldous 2015) where, W(t) is the standard Brownian motion or Wiener process. If the stochastic process is defined as X(t) = log S(t) then dS(t) = µS(t)dt + σS(t)dW(t) is the stochastic differential equation for the stock price random process. For a given time t > 0, the standard model for stock prediction can be given from the stochastic differential equation by integration A more explicit formula can be derived using Ito's formula (Ševcovic et al. 2011) to the function F(log S(t), t) For any time t > 0, the differential can be written as Or, S(t) = S(0)e (µ− 1 2 σ 2 )t+σW(t) .
3.3.2. Geometric Brownian Motion Model for S & P 500 Index: GBM(µ, σ 2 ) Simulation For a given time set, t 0 = 0 < t 1 < t 2 < . . . < t n , the stock price S(t) at time t 0 , t 1 , . . . , t n can be generated by where Z 1 , Z 2 , . . . Z n are independent and identically distributed standard normals and i = 0, (n − 1). In our case, the time interval t i+1 − t i = 1 for all i = 0, (n − 1), since we are predicting the next-day price. Hence, the model becomes Using the model in Equation (8), we simulate a large number of prices, and from that we take the average to predict the next-day price. For our data, this large number is 100, 000. A total of 63 predictions have been made using this model. A fixed window of 1194 past observed stock prices have been used to predict each of the next-day prices. Hence, the training dataset moved, and the end price of the window was updated with the actual price. The results and diagnostics of this model are discussed in Section 4.2.

Artificial Neural Network
This section describes how an artificial neural network can be used to predict the stock price and how to build a model based on the stock data for S & P 500 index.

Model Descriptions
Artificial neural network is one of the most popular machine learning techniques for nonlinear approximations because of its ability to deal with a large number of functions with a high degree of accuracy (Chen et al. 2003). The idea of ANN came from the structure of the animal brain, more specifically, from the human neural system. It is based on the idea of how brain works, how the neurons in the brain receive information from the input neurons, analyse it, and finally identify the object or pattern. Fundamentally, the mechanism has three layers-input layer, hidden layers, and output layer. Each layer consists of neurons or nodes. The hidden part may consist of many layers, however, for the time series analysis and forecasting, the single hidden layer feed forward network is the most widely used model structure (Zhang et al. 1998). A simple three layer neural network has the following mathematical form where, W i,j and W j for i = 1, 2, . . . , p, j = 1, 2, . . . , q are known as connection weights. The parameter p and q are the number of input and output nodes respectively. The network involves an activation function which plays a very important role because it converts the input signals to be used for the neurons or nodes in the next layer, eventually the output neuron. The most widely used activation functions are the logistic and hyperbolic functions (Khashei and Bijari 2010), which are shown in Equations (10) and (11) sig ( Most of the modelers prefer the hyperbolic tangent function as the activation functions because of its faster convergence, and it makes the optimization easier. Hence, we used this activation function in our model. There is no systematic rule of choosing the number of neurons or nodes, q in the hidden layer (Khashei and Bijari 2010). In most of the cases it is data-dependent and chosen on the basis of trial and error.

Artificial Neural Network for S & P 500 Index
The model proposed for S & P 500 in this section is a three layer model-input, hidden, and the output layer. The input layer consists of a total of seven nodes which are daily Open, Close, High, Low, Average, Volume, and Return. The variable Average is the average of daily Open, Close, High, and Low. The Volume was converted to million units. Daily return was calculated by this formula r t = log S t S t−1 , where S t is the adjusted closed price and day one return, r 0 was considered zero. The output layer has only one node that corresponds to the predicting variable Adjusted Close price. The number of the nodes in the hidden layer was chosen based on the error measures in Equation (1) for different combinations of the hidden nodes, which are displayed in Table 3. From this Table 3, we see that model ANN(7-15-1) has the lowest APE, AAE, ARPE, and RMSE and the highest adjusted R 2 value. The original dataset had 1257 observations, but the dataset used in this method was modified in this way-all the predictor and predicting variables have the same length of 1256, however, the predictor variables started from day 1 to the 1256th day and the predicting variable day 2 to the 1257th day. Then, the dataset was divided into two parts to run the model. The test dataset contained the last 63 actual stock prices (adjusted close) which were compared to the predicted prices. The best model was selected on the basis of the adjusted R 2 and four error measures (Table 3). The model architecture is shown in Figure 5 and the result of this model is discussed in Section 4.3.

Results
In this section, the result of from the above three models is discussed and a window of the predicted and actual price is shown together with a graphical presentation. Finally, we assess how our model is performing by model diagnostics.

ARIMA Model Result
The model ARI MA(0, 2, 1) in Equation (3) produces the prediction in a logarithmic scale, which is then converted back to the original scale by the formula Predicted Price = e prediction . Total 63 trading days have been predicted by the model and compared with the actual prices which has been shown in Table 4 with individual prediction error calculated by the formula, From Table 4, we see that the forecast errors are less than one dollar for the daily period from 12 November, 2019 to 30 December 2019, with the relative errors within the range of 0.00003 to 0.00292. Figure 6 shows the graphical representation of the actual and predicted stock price by the model. The black line represents the actual stock price and the red line represents the predicted stock price for S & P 500. Figure 6 also shows that the ARIMA (0,2,1) predicted prices follow closely to the trend of the actual prices. The performance of the ARIMA(0,2,1) model was assessed by the analysis of the four error measures state in Equation (1) and the residuals plot, which is depicted in Figure 7 and those four error measures are tabulated in Table 5. From the results in Table 5, we see that all the error measures are comparatively very low to the actual prices, this indicates that the model is performing better in its prediction. From Figure 7 it is clear that the residuals do not follow any special pattern, they are a randomized plot. Correlations in the few lags are significant. Overall, the model fits very well to predict the stock price.

Stochastic Model Result
The model proposed in Equation (8) Table 6, and the errors were calculated by the same formula (12) used in the previous model. The results in Tables 5 and 6 are almost the same except at some points. Thus, Figures 7 and 8 are almost identical. Figure 8 displays the graphical representation of the actual and predicted stock prices from the stochastic model. The black line represents the actual stock price and the green line represents the predicted stock price for S & P 500 index.

Stochastic Model Diagnostics
The performance of the stochastic model was assessed by the analysis of the four error measures stated in Equation (1) and the residual plot which is depicted in Figure 9 and the calculation of the four different error measures, as shown in Table 7.  9. GBM model diagnostics.
The standardized residual plot is random and the mean passes through the zero line. A few of the residuals at the lower end are outside of the band in the Q-Q plot of the residuals. Still, both of the plots depict the approximate normal behavior of the residuals.

ANN(7-15-1) Results
Both of the training and test datasets were converted to normal and the prediction was converted back to the original scale by inverse transformation. The model required approximately 7000 steps with an error of 0.1972. Actual prices, predicted prices, and the corresponding errors are displayed in Table 8.  The predicted errors in Table 8 are much higher than those in Tables 5 and 6. Precise comparisons of the three models are given in the next section. The graph associated with this result is displayed in Figure 10. The black line represents the actual stock price and the blue line represents the predicted stock price for the S & P 500 index. From the graph, it is clear that the model is working better at the beginning of the prediction interval.

ANN(7-15-1) Model Diagnostics
The performance of the neural network ANN(7-15-1) was assessed by the analysis of the four error measures stated in Equation (1) and the standardized residuals plot, which is depicted in Figure 11, and the calculation of the four different error measures are shown in Table 9. Table 9. Prediction error by ANN(7-5-1) model.
The standardized residual plot does not show normal behavior. The error increases in an exponential shape as the predicting interval increases.

Comparison
In this section, the combined output from the three models above is discussed. Table 10 shows a sample of the empirical results obtained from the models and Figure 12 displays the result graphically. Table 10. Sample results from the models-ARIMA(0,2,1), GBM(µ, σ 2 ), and ANN(7-15-1).

Date
Actual ARIMA GBM ANN From Figure 12 it clear that that ARIMA(0,2,1) model's output and GBM model's output are very close, sometimes they coincide, whereas the output from the ANN(7-15-1) model gets far from the actual points as time increases. Looking at the error measures in Table 11, it is clear that the ARIMA model and stochastic model perform better than the neural network model for predicting the next-day stock price.

Conclusions
This study represents a comparative study of three financial models ARIMA, ANN, and Geometric Brownian Motion to predict the next-day stock prices. Results obtained from the analysis of the S & P 500 index show that the conventional statistical model ARIMA and the stochastic model-geometric Brownian motion model perform better than the artificial neural network models for short term next-day stock price prediction. The results are in contradiction with the results in Khashei and Bijari (2010), which concluded that the ARIMA was no better than the ANN model in time series predictions. However, their proposed hybrid ANN model outperformed the traditional ANN and the ARIMA models. Furthermore, our results are similar to the conclusions in Merh et al. (2010) and Lee et al. (2007) which stated that ARIMA models outperform ANN models for stock price predictions. On the other hand, Rathnayaka et al. (2014) found that the stochastic model prediction is more significant than the traditional ARIMA model. In fact, on the basis of our results, the ARIMA model and the stochastic model produce almost the same results. Thus, for short term prediction using the time series data, the ARIMA model and the stochastic model can be used interchangeably. For the ANN models, further studies, hybridization of existing models, and adding more independent variables can improve the neural network models in predicting stock prices. One model can work better than other models with particular time series data. Therefore, researchers or investors should examine some different models to predict the prices of each stock to find the best prediction model. Author Contributions: M.R.I. setup and ran models, processed data, and wrote the first draft. N.N. introduced the methodology, refined the manuscript, and supervised the project. All authors have read and agreed to the published version of the manuscript.
Funding: This research received no external funding.

Conflicts of Interest:
The authors declare no conflict of interest.