Asian Journal of Information Technology

Year: 2009
Volume: 8
Issue: 1
Page No. 1 - 7

Hybrid Neural Network-Monte Carlo Simulation for Stock Price Index Prediction

Authors : Joko Lianto Buliali, Chastine Fatichah and Mudji Susanto

Abstract: This research uses Monte Carlo simulation to increase the accuracy of neural network prediction on a limited number of composite stock price index. The case study is Indonesian composite stock price index (i.e., Jakarta Composite Index (JCI)) from July 1997 to December 2007. Monte Carlo simulation is used to generate additional data from the available data, which is then fed into neural network to forecast future data. Testing results show that the output of hybrid neural network-Monte Carlo simulation system produces significantly lower Mean Absolute Percentage Error (MAPE) than the output of neural network without data from Monte Carlo simulation.

How to cite this article:

Joko Lianto Buliali, Chastine Fatichah and Mudji Susanto, 2009. Hybrid Neural Network-Monte Carlo Simulation for Stock Price Index Prediction. Asian Journal of Information Technology, 8: 1-7.

INTRODUCTION

Financial forecasting (including security returns, stock price, foreign exchange rates, capital flow, etc.) has been a focus of research for the last few years and various techniques have been proposed. Below is a number of such researches and the techniques used:

Non-linear modeling, where financial data are regarded as non-linear and therefore require non-linear modeling (Gradojevic, 2006)
Fuzzy rule based system, where the relationship among factors are modeled in a fuzzy relationship (Chang and Liu, 2006)
Neural networks, which analyze relationships among complex financial data and store relationships in terms of weights as a result from training (Yao and Tan, 2001; Zhang, 2004; O’Connor and Madden, 2006; Kim, 2006; Tsang et al., 2007)

Neural networks gain popularity among other techniques for financial forecasting due to the relatively easy implementation and training. Complex relationship among data are tuned info the network during training. The more (and accurate) training data, the more accurate the network will perform. Unfortunately abundant data is not always available. In cases, where there are only limited number of data, neural networks can perform rather satisfactorily only when predicting short periods. The level of accuracy in such case is not high. If long period prediction is forced, the error will be excessively large.

The hypothesis in this research is that the use of Monte Carlo simulation for generating additional data can increase the accuracy of prediction of neural networks in situations where only limited number of composite stock price index data are available. Here Monte Carlo is used to increase the number of data according to the designated distribution of the sample data. As the system is intended to forecast composite stock price index, Exponential Generalized Autoregressive Conditional Heteroskedasticity (EGARCH) model is used which is the most common model used in composite stock price index forecast.

MATERIALS AND METHODS

As mentioned in the selection of input variables is fundamental to accurately forecast the stock movements (Coupelon, 2007). It primarily depends on a clear understanding of the economical background of the stock price to forecast.

In this research, the inputs chosen are Exponential Moving Average (EMA), Relative Strength Index (RSI), Moving Average Convergence Divergence (MACD) and Stochastic Oscillator (SO). These technical analysis indicators are commonly used as input for neural network.

Moving Average (MA): Moving average is suitable for identifying whether a security is moving in an uptrend or a downtrend depending on the direction of the moving average. The three most common types of moving averages are simple, linear and exponential (Janssen et al., 2009). Exponential Moving Average (EMA) is more responsive to new information relative to the simple moving average. As responsiveness is one of the key factors in calculating trend. EMA is the one used in this research. Equation 1 shows the formula of EMA (Colby and Thomas, 2002):

(1)

Where,
EMAt = Exponential moving average
EMAt-1 = Previous moving average value
St = Smoothing factor = 2/(n+1)
n = Number of periods

Relative Strength Index (RSI): RSI is popular as it can be interpreted easily. The RSI compares the magnitude of a stock's recent gains to the magnitude of its recent losses and turns that information into a number that ranges from 0-100 (StockCharts, 2009). Equation 2 shows the formula of RSI (Colby and Thomas, 2002):

(2)

where, RS is the ratio of the exponential moving average of 14-day gains divided by the absolute value of the exponential moving average of 14-day losses.

Moving Average Convergence Divergence (MACD): MACD is composed of two lines. The first line is the difference between two exponential moving averages (i.e., a 26 and 12-days moving average of daily close price). The second is a Signal line which is the EMA of the first line (i.e., a 9-days EMA). MACD line will oscillate along the time axis to show buy/sell opportunities. (Magdefrau, 2006). Equation 3 shows the formula of MACD (Colby and Thomas, 2002):

(3)

Where,
EMA12 = 12-period EMA
EMA26 = 26-period EMA
EMA9 = 9-period EMA

Stochastic Oscillator (SO): SO is a technical momentum indicator that compares a security’s closing price to its price range over a given time period. The oscillator’s sensitivity to market movements can be reduced by adjusting the time period or by taking a moving average of the result. This indicator is calculated with the formula shown in Eq. 4 (Investopedia, 2009):

(4)

Where,
K = Stochastic oscillator
CPt = The latest closing price of the stock or contract
Ln = n-period low price of the stock or contract
Hn = n-period high price of the stock or contract
n = Any number (a range of 5-21 is recommended)

Figure 1 shows the four technical indicators chosen as input data, both for neural network and hybrid neural network-Monte Carlo simulation system.

Before fed into neural network, data is preprocessed to facilitate the learning process of neural network. Data is normalized into 0 and +1 scale. Linear scaling method is applied to keep the uniformity of the distribution (Coupelon, 2007).

In designing a neural network system for stock price index prediction, several points must be considered (Coupelon, 2007; Azoff , 1994; Zhang, 2004):

Number of input neurons: As there are four inputs (EMA, RSI, MACD and SO), four input neurons for the neural network.

Number of hidden layers: In this research one hidden layer is used.

Number of hidden neurons: This number is determined during experimentation (training phase of the neural network development). If several experimentations yield different number of hidden neurons with more or less the same error, the one with the least number of hidden neurons is chosen.

Number of output neurons: As there is only one output is required (stock price index prediction), one output neuron is used.

Transfer functions: In this research sigmoid transfer function is used, which is the most commonly used.

Figure 2 shows the model of Neural Network for forecast composite stock price index.

Fig. 1: Input variables

Fig. 2: Neural network model

Neural network training is an iterative process so that the network tunes complex relationship among data into neuron weight and therefore can be used for prediction future data. The goal is to minimize errors, which indicates that the model behaves as closely as possible as the index behaviour in the real world. Error function used to evaluate the model is MSE (the mean squared of the difference of the output of the network and the targeted output) which is the commonly used error function. This error function is used to update the weights in the model so that the output is adjusted as the data (Back Propagation Networks (BPN)). The algorithm used for the training is as follows (Bourg and Seeman, 2004):

1 Start training with a group of input data and targeted output
2 Initialize all weights in the network with some small random numbers
3 Input each input data from the group and calculate the output
4 Compare the output of the network with targeted output and calculate the error
5 Change weights in the network to decrease error and repeat the process

Steps 4 (error calculation) and 5 (weight change) constitute the important part of back propagation algorithm. This error calculation (MSE calculation) cannot only to determine whether the output is correct or not, but also to determine the degree of error of the output. The main goal is the get the least MSE by changing the weights of the neurons iteratively. The formula is as shown in Eq. 5 (Arbib, 2002):

(5)

Where,
δoi = The error of ith neuron output
Δnoi = The difference of targeted output and the ith neuron output
f' (noci) = The derivative of activation function (sigmoid function) for the ith neuron output by using the derivative of sigmoid function

Eq. 5 becomes Eq. 6 (Arbib, 2002):

(6)

Where,
nodi = The value of ith targeted output neuron
noci = The value of ith output of the output layer

Error calculation in hidden layer can be calculated by using formula in Eq. 7 (Arbib, 2002):

(7)

where, nhci is the value of output neuron of the hidden layer. It is seen that the error from every neuron in hidden layer is an error function associated with every neuron in output layer, where the error of neuron output is multiplicated with the weight of the neuron. This implies that the error calculation changes the weights of the neurons from output layer towards input layer. By substituting activation function to Eq. 7 and 8 is obtained.

(8)

Error calculation for input layer is not required as the value of each neuron in input layer is known. By using the above error calculation, weight change can be calculated. Equation 9 shows the formula for weight change:

(9)

Where,
η = Learning rate
δi = The error of the neuron whose weight will be changed
ni = The value of the neuron whose weight will be changed

The new weight is obtained by adding the old weight and Δw. Weight change is carried out on every weight and the change value (Δw) will be different on every weight. Learning rate is a multiplier that affects the impact of every weight change. In this research the learning rate is set between 0.25 and 0.5. If the value is too large, the weights will oscillate. If the value is too small, the training will take a long time to settle.

To achieve an even shorter training time, momentum is used in the weight change process. The formula to calculate weight change that incorporates momentum is shown in Eq. 10 (Katagiri, 2000).

(10)

Where,
Δw' = The weight change from previous iteration
α = The momentum factor which ranges from 0.0-1.0

Another important part of the proposed system is Monte Carlo simulation. A Monte Carlo experiment involves the following steps (Schmidheiny, 2007):

1 Draw a (pseudo) random sample of size N for the stochastic elements of the stochastic model from their respective probability distribution functions
2 Assume values for the exogenous parts of the model or draw them from their respective distribution function
3 Calculate the endogenous parts of the statistical model
4 Calculate the value of interest (e.g., the estimate)
5 Replicate step 1-4 R times
5 Examine the empirical distribution of the R-values

In Monte Carlo experiments, random number generator produces a sequence of numbers from a mathematical algorithm, which produces a sequence of pseudo random numbers that are identically and independently distributed. The random numbers are called pseudo random numbers as they are not random as the algorithm describes the purely deterministic relationship between the numbers. However, with a good generator, the numbers are indistinguishable from sequences of genuinely random numbers and pass usual statistical tests of independence (Schmidheiny, 2007).

Input data is preprocessed before being fed into neural network. Preprocessing is required to change input data into matrix form to be further processed by MatLab software. Data from preprocessing constitute 50% of the data for neural network as shown in Fig. 3. The remaining 50% data is fed from Monte Carlo simulation.

Financial model for Monte Carlo simulation is Exponential Generalized Autoregressive Conditional Heteroskedasticity (EGARCH). In this research Gaussian data distribution is used for the GARCH model. Figure 4 shows Monte Carlo model for generating the remaining 50% data.

Fig. 3: Data preprocessing

Fig. 4: Monte Carlo model

RESULTS AND DISCUSSION

Testing was carried out by comparing the Mean Absolute Percentage Error (MAPE) calculation for the output of neural network system and that of hybrid neural network-Monte Carlo simulation system. Data for testing was Jakarta Composite Index (JCI)) from July 1997 to December 2007. The formula for MAPE calculation is shown in Eq. 11:

(11)

Where,
nc = The output value of neural network
nd = The targeted output
m = The number of outputs of the neural network

Two kinds of training were carried out, one training with 6-months data (experiment 1), another with 12-months data (experiment 2). This is meant to see the effects of the number of training data to system output. The length of prediction was varied from 3 months up to 9 months. This is meant to see the accuracy of the prediction for different time horizon. After training, both systems were ready for evaluation.

Experiment 1: The first step to evaluate the system is to calculate for the output of neural network system and that of hybrid neural network-Monte Carlo simulation system. Table 1 shows the results obtained.

The Monte Carlo system is run for ten replications initially. Next, the required (minimum) number of replication for each experiment is calculated for each category using in Eq. 12:

Table 1: MAPE of output of NN system and hybrid NN-MC simulation system

(12)

Where,
R = The required number of replication
α = The critical value (set to 0.05)
R-1 = The degree of freedom = (10 - 1) = 9
SD = The standard deviation from the experiments
ε = Maximum tolerable error (set as 10% from the associated MAPE)

Table 2 shows the number of replication for each experiment.

Finally statistical t-test was carried out with null Hypothesis (H0) that the MAPE of the output of neural network system does not differ from that of hybrid neural network-Monte Carlo simulation system. Each category was evaluated after the required number of replication was carried out. The alpha in the t-test is 0.05. The values are shown in Table 3.

As the critical value of t-test is 1.67, H0 will be rejected for areas where t = 1.67. The value of t for 3-months forecast period is 2.869, therefore, H0 is rejected (shich means that the MAPE of the output of neural network system differs from that of hybrid neural network-Monte Carlo simulation system). Similarly, H0 is rejected for 6-months forecast period and for 9-months forecast period. It is also seen that the MAPE of hybrid neural network-Monte Carlo simulation system is lower than that of neural network by itself.

Experiment 2: The steps in this experiment is the same as the steps in experiment 1. The difference is only in the length of data for training. While in experiment 1, 6-months data is used in experiment 2, 12-months data are used instead. Although, replication calculation reveals that different number of replication is required in each category, the statistical t-test yields the same conclusion of rejecting H0 and the MAPE of hybrid neural network-Monte Carlo simulation system is lower than that of neural network by itself.

The general conclusion from the two experiments is as follows. As H0 is rejected in all cases, it can be concluded that hybrid neural network-Monte Carlo simulation system performs significantly different from neural network by itself (without data from Monte Carlo simulation). Since the MAPE of hybrid neural network Monte Carlo simulation system is lower than that of neural network by itself, it is concluded that hybrid neural network-Monte Carlo simulation system performs better than neural network by itself.

Table 2: Number of replication required for each experiment

Table 3: T-test of the results

CONCLUSION

The proposed hybrid neural network-Monte Carlo simulation system has proved to produce smaller error than neural network model by itself on the case study of Jakarta composite index. The underlying concept here is that Monte Carlo simulation can be utilized to generate additional data from limited sample data. However, Monte Carlo is a simulation method, experiments using hybrid neural network-Monte Carlo simulation system requires more replication that neural network model by itself, because this hybrid system uses generated data from actual data.

Design and power by Medwell Web Development Team. © Medwell Publishing 2024 All Rights Reserved