82
NAVAL POSTGRADUATE SCHOOL Monterey, California THESIS Approved for public release; distribution is unlimited. FORECASTING FINANCIAL MARKETS USING NEURAL NETWORKS: AN ANALYSIS OF METHODS AND ACCURACY by Jason E. Kutsurelis September 1998 Principal Advisor: Katsuaki Terasawa

THESIS - Advanced Neural Network and Genetic Algorithm Software

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: THESIS - Advanced Neural Network and Genetic Algorithm Software

NAVAL POSTGRADUATE SCHOOLMonterey, California

THESIS

Approved for public release; distribution is unlimited.

FORECASTING FINANCIAL MARKETSUSING NEURAL NETWORKS: AN ANALYSIS

OF METHODS AND ACCURACY

by

Jason E. Kutsurelis

September 1998

Principal Advisor: Katsuaki Terasawa

Page 2: THESIS - Advanced Neural Network and Genetic Algorithm Software

FORECASTING FINANCIAL MARKETS USING NEURALNETWORKS: AN ANALYSIS OF METHODS AND ACCURACY

Jason E. Kutsurelis-Lieutenant, United States NavyB.S., United States Naval Academy, 1991

Master of Science in Management-September 1998Principal Advisor: Katsuaki Terasawa, Department of Systems

ManagementAssociate Advisor: William R. Gates, Department of Systems

Management

This research examines and analyzes the use of neural networks as a forecasting tool. Specifically a neural network's ability to predict future trends of Stock Market Indices istested. Accuracy is compared against a traditional forecasting method, multiple linearregression analysis. Finally, the probability of the model's forecast being correct is calculatedusing conditional probabilities. While only briefly discussing neural network theory, thisresearch determines the feasibility and practicality of using neural networks as a forecastingtool for the individual investor. This study builds upon the work done by Edward Gately inhis book Neural Networks for Financial Forecasting. This research validates the work ofGately and describes the development of a neural network that achieved a 93.3 percentprobability of predicting a market rise, and an 88.07 percent probability of predicting a marketdrop in the S&P500. It was concluded that neural networks do have the capability to forecastfinancial markets and, if properly trained, the individual investor could benefit from the useof this forecasting tool.

KEYWORDS: Neural Networks, Finance, Time Series Analysis, Forecasting, Artificial Intelligence

DOD TECHNOLOGY AREA: Modeling and simulation, ArtificialIntelligence, Neural Networks

Page 3: THESIS - Advanced Neural Network and Genetic Algorithm Software

i

REPORT DOCUMENTATION PAGE Form Approved OMB No. 0704-0188

Public reporting burden for this collection of information is estimated to average 1 hour per response, including the time for reviewing instruction, searchingexisting data sources, gathering and maintaining the data needed, and completing and reviewing the collection of information. Send comments regarding thisburden estimate or any other aspect of this collection of information, including suggestions for reducing this burden, to Washington Headquarters Services,Directorate for Information Operations and Reports, 1215 Jefferson Davis Highway, Suite 1204, Arlington, VA 22202-4302, and to the Office of Managementand Budget, Paperwork Reduction Project (0704-0188) Washington DC 20503.

1. AGENCY USE ONLY (Leave blank) 2. REPORT DATE

September 19983. REPORT TYPE AND DATES COVERED

Master’s Thesis

4. TITLE AND SUBTITLE FORECASTING FINANCIALMARKETS USING NEURAL NETWORKS: ANANALYSIS OF METHODS AND ACCURACY

6. AUTHOR(S) Kutsurelis, Jason E.

5. FUNDING NUMBERS

7. PERFORMING ORGANIZATION NAME(S) AND ADDRESS(ES)Naval Postgraduate SchoolMonterey CA 93943-5000

8. PERFORMINGORGANIZATIONREPORT NUMBER

9. SPONSORING/MONITORING AGENCY NAME(S) AND ADDRESS(ES) 10.SPONSORING/MONITORINGAGENCY REPORT NUMBER

11. SUPPLEMENTARY NOTES The views expressed in this thesis are those of the author and do not reflectthe official policy or position of the Department of Defense or the U.S. Government.

12a. DISTRIBUTION/AVAILABILITY STATEMENTApproved for public release; distribution is unlimited.

12b. DISTRIBUTION CODE

13. ABSTRACT (maximum 200 words)

This research examines and analyzes the use of neural networks as a forecasting tool. Specifically aneural network's ability to predict future trends of Stock Market Indices is tested. Accuracy is comparedagainst a traditional forecasting method, multiple linear regression analysis. Finally, the probability of themodel's forecast being correct is calculated using conditional probabilities. While only briefly discussingneural network theory, this research determines the feasibility and practicality of using neural networks asa forecasting tool for the individual investor. This study builds upon the work done by Edward Gately inhis book Neural Networks for Financial Forecasting. This research validates the work of Gately anddescribes the development of a neural network that achieved a 93.3 percent probability of predicting amarket rise, and an 88.07 percent probability of predicting a market drop in the S&P500. It was concludedthat neural networks do have the capability to forecast financial markets and, if properly trained, theindividual investor could benefit from the use of this forecasting tool.

15. NUMBER OFPAGES *123

14. SUBJECT TERMS Neural Networks, Finance, Time Series Analysis,Forecasting, Artificial Intelligence.

16. PRICE CODE

17. SECURITY CLASSIFI-CATION OF REPORTUnclassified

18. SECURITY CLASSIFI-CATION OF THIS PAGEUnclassified

19. SECURITY CLASSIFI-CATION OF ABSTRACTUnclassified

20. LIMITATION OFABSTRACTUL

NSN 7540-01-280-5500 Standard Form 298 (Rev. 2-89)Prescribed by ANSI Std. 239-18 298-102

Page 4: THESIS - Advanced Neural Network and Genetic Algorithm Software

ii

Approved for public release; distribution is unlimited.

FORECASTING FINANCIAL MARKETS USING NEURAL

NETWORKS: AN ANALYSIS OF METHODS AND ACCURACY

Jason E. Kutsurelis

Lieutenant, United States Navy

B.S., United States Naval Academy, 1991

Submitted in partial fulfillment

of the requirements for the degree of

MASTER OF SCIENCE IN MANAGEMENT

from the

NAVAL POSTGRADUATE SCHOOL

September 1998

Author:

Jason E. Kutsurelis

Approved by:

Katsuaki Terasawa, Principal Advisor

William R. Gates, Associate Advisor

Reuben T. Harris, Chairman

Department of Systems Management

Page 5: THESIS - Advanced Neural Network and Genetic Algorithm Software

iii

Page 6: THESIS - Advanced Neural Network and Genetic Algorithm Software

iv

ABSTRACT

This research examines and analyzes the use of neural networks as a forecasting tool.

Specifically a neural network's ability to predict future trends of Stock Market Indices is

tested. Accuracy is compared against a traditional forecasting method, multiple linear

regression analysis. Finally, the probability of the model's forecast being correct is calculated

using conditional probabilities. While only briefly discussing neural network theory, this

research determines the feasibility and practicality of using neural networks as a forecasting

tool for the individual investor. This study builds upon the work done by Edward Gately in

his book Neural Networks for Financial Forecasting. This research validates the work of

Gately and describes the development of a neural network that achieved a 93.3 percent

probability of predicting a market rise, and an 88.07 percent probability of predicting a market

drop in the S&P500. It was concluded that neural networks do have the capability to forecast

financial markets and, if properly trained, the individual investor could benefit from the use

of this forecasting tool.

Page 7: THESIS - Advanced Neural Network and Genetic Algorithm Software

v

Page 8: THESIS - Advanced Neural Network and Genetic Algorithm Software

vi

TABLE OF CONTENTS

I. INTRODUCTION............................................................................................... 1

A. GOALS.................................................................................................... 1

1. Background .................................................................................. 2

2. Objectives..................................................................................... 6

3. The Research Question ................................................................. 6

4. Scope, Limitations and Assumptions ............................................. 7

5. Literature Review and Methodology ............................................. 7

6. Organization of Study ................................................................... 8

II. LITERATURE REVIEW AND THEORETICAL FRAMEWORK.................... 11

A. LITERATURE REVIEW....................................................................... 11

B. THEORETICAL FRAMEWORK .......................................................... 13

III. METHODOLOGY ............................................................................................ 18

IV. PRESENTATION OF DATA COLLECTED .................................................... 33

A. CLOSE NETWORK .............................................................................. 33

B. PERCENT NETWORK ......................................................................... 39

C. MULTIPLE LINEAR REGRESSION MODEL..................................... 47

D. CONDITIONAL PROBABILITY.......................................................... 53

V. DATA ANALYSIS AND INTERPRETATION................................................. 59

VI. CONCLUSIONS AND RECOMMENDATIONS.............................................. 63

A. CONCLUSIONS.................................................................................... 63

B. RECOMMENDATIONS ....................................................................... 63

Page 9: THESIS - Advanced Neural Network and Genetic Algorithm Software

vii

APPENDIX A. THIRD REGRESSION PARTIAL OUTPUT AND VITALPLOTS (NOT INCLUDED IN ELECTRONIC VERSION)

APPENDIX B. PARTIAL LISTING OF RAW AND PREPROCESSEDINPUT DATA (NOT INCLUDED IN ELECTRONIC VERSION)

APPENDIX C. SOURCE CODE FOR CLOSE NETWORK (NOT INCLUDEDIN ELECTRONIC VERSION)

LIST OF REFERENCES .............................................................................................. 65

BIBLIOGRAPHY......................................................................................................... 67

INITIAL DISTRIBUTION LIST (NOT INCLUDED IN ELECTRONIC VERSION)

Page 10: THESIS - Advanced Neural Network and Genetic Algorithm Software

viii

LIST OF FIGURES

Figure 1. Biological Neuron .................................................................................... 3

Figure 2. Artificial Neuron Model............................................................................ 4

Figure 3. Logistic Activation Function..................................................................... 5

Figure 4. Gaussian Activation Function ................................................................... 5

Figure 5. Artificial Neuron Using Backpropagation Learning................................. 14

Figure 6. Training Error on Close Network Training Set ....................................... 34

Figure 7. Training Error on Close Network Test Set ............................................. 34

Figure 8. Input Contribution Factors Close Network ............................................. 36

Figure 9. Close Network Actual vs Predicted S&P500 Close................................. 37

Figure 10. Close Network Error.............................................................................. 38

Figure 11. Training Error on Percent Network Training Set .................................... 40

Figure 12. Training Error on Percent Network Test Set........................................... 40

Figure 13. Input Contribution Factors Percent Network .......................................... 42

Figure 14. Percent Network Actual vs. Predicted Future 10 Day Percent Changeand Closing Price of S&P500 ................................................................. 43

Figure 15. Percent Network Error ........................................................................... 44

Figure 16. All Network Models Actual vs. Predicted S & P500 C ........................... 46

Figure 17. S&P500 Closing Value Prediction Neural Network Model ErrorChart...................................................................................................... 47

Figure 18. Regression Model Predicted vs. Actual S&P500 Close ........................... 50

Figure 19. Regression Model Error Chart................................................................ 51

Page 11: THESIS - Advanced Neural Network and Genetic Algorithm Software

ix

Figure 20. Actual vs. All Model Predictions of S&P500 Close Ten DaysInto Future ............................................................................................. 52

Figure 21. All Model Error Chart ............................................................................ 53

Page 12: THESIS - Advanced Neural Network and Genetic Algorithm Software

x

LIST OF TABLES

Table 1. Training Module Output Close Network................................................. 33

Table 2. Close Network Output Statistics............................................................. 35

Table 3. Close Network Descriptive Statistics ...................................................... 38

Table 4. Training Module Output Percent Network.............................................. 39

Table 5. Percent Network Output Statistics.......................................................... 40

Table 6. Percent Network Descriptive Statistics ................................................... 45

Table 7. Regression Statistics............................................................................... 47

Table 8. VIF for Regression................................................................................. 49

Table 9. Regression Model Descriptive Statistics ................................................. 51

Table 10. Historical Market Data ........................................................................... 53

Table 11. Close Network Accuracy........................................................................ 54

Table 12. Percent Network Accuracy..................................................................... 54

Table 13. Multiple Regression Accuracy ................................................................ 55

Table 14. Close Network Environmental Adjustment ............................................. 55

Table 15. Percent Network Environmental Adjustment .......................................... 56

Table 16. Multiple Regression Environmental Adjustment...................................... 56

Table 17. Close Network Accuracy Probability ...................................................... 57

Table 18. Percent Network Accuracy Probability ................................................... 57

Table 19. Multiple Regression Accuracy Probability............................................... 57

Table 20. Coefficients of Multiple Determination ................................................... 59

Table 21. Model Error Statistics ............................................................................ 60

Page 13: THESIS - Advanced Neural Network and Genetic Algorithm Software

xi

Table 22. Conditional Probabilities......................................................................... 61

Page 14: THESIS - Advanced Neural Network and Genetic Algorithm Software

xii

Page 15: THESIS - Advanced Neural Network and Genetic Algorithm Software

1

I. INTRODUCTION

A. GOALS

This research will examine and analyze the use of neural networks as a forecasting

tool. Specifically a neural network’s ability to predict future trends of Stock Market Indices

will be tested. Accuracy will be compared against a traditional forecasting method, multiple

linear regression analysis. Finally, the probability of the model’s forecast being correct will

be calculated using conditional probabilities. While only briefly discussing neural network

theory, this research will determine the feasibility and practicality of using neural networks

as a forecasting tool for the individual investor.

The study builds upon the work done by Edward Gately in his book Neural Networks

for Financial Forecasting. In his book, Gately (1996) describes the general methodology

required to build, train, and test a neural network using commercially available software. In

this research, one of Gately’s S&P500 network models was validated using recent data and

provided a benchmark for further improvement. Gately’s model was slightly improved upon,

a new model was designed, and both models were compared to a multiple regression model.

Finally, and potentially most importantly for the investor, model accuracy probabilities were

generated. This was done by combining historical market movement probabilities with the

model accuracy probability. This conditional probability could prove to be a vital tool for

investment decision making.

Until recently, neural network research, as a subset of artificial intelligence, was

limited to the realm of universities, research organizations, and large investment firms. The

entrance of the neural network as an investment tool for the individual investor was one of

Page 16: THESIS - Advanced Neural Network and Genetic Algorithm Software

2

the many things brought about by the explosive growth personal computers. Neural network

software is easily available and is profusely advertised in magazines such as Technical

Analysis of Stocks and Commodities. What isn’t advertised as well is the amount of skill and

effort required when building an effective model.

This research validates the work of Gately (1996) and describes the development of

a neural network that achieved a 93.3 percent probability of predicting a market rise, and an

88.07 percent probability of predicting a market drop in the S&P500. It was concluded that

neural networks do have the capability to forecast financial markets and, if properly trained,

the individual investor could benefit from using this forecasting tool.

1. Background

Neural network theory grew out of Artificial Intelligence research, or the research in

designing machines with cognitive ability. A neural network is a computer program or

hardwired machine that is designed to learn in a manner similar to the human brain. Haykin

(1994) describes neural networks as an adaptive machine or more specifically:

A neural network is a massively parallel distributed processor that has anatural propensity for storing experiential knowledge and making it availablefor use. It resembles the brain in two respects: Knowledge is acquired by thenetwork through a learning process and interneuron connection strengthsknown as synaptic weights are used to store the knowledge.

The basic building block of a brain and the neural network is the neuron. The basic

human neuron adapted from Beale and Jackson (1990) is shown below in Figure 1.

Page 17: THESIS - Advanced Neural Network and Genetic Algorithm Software

3

Figure 1. Biological Neuron

As described by Jackson et al. (1990), all inputs to the cell body of the neuron arrive along

dendrites. Dendrites can also act as outputs interconnecting interneurons. Mathema-tically,

the dendrite's function can be approximated as a summation. Axons, on the other hand, are

found only on output cells. The axon has an electrical potential. If excited past a threshold

it will transmit an electrical signal. Axons terminate at synapses that connect it to the dendrite

of another neuron. When the electrical input to a synapse reaches a threshold, it will pass the

signal through to the dendrite to which it is connected. The human brain contains

approximately 1010 interconnected neurons creating its massively parallel computational

capability.

Page 18: THESIS - Advanced Neural Network and Genetic Algorithm Software

4

The artificial neuron was developed in an effort to model the human neuron. The

artificial neuron depicted below in Figure 2 was adapted from Kartalopoulos (1996) and

Haykin (1994). Inputs enter the neuron and are multiplied by their respective synaptic.

Figure 2. Artificial Neuron Model

weights. They are then summed and processed by an activation function. The activation

function dampens or bound's the neuron's output, (Kartalopolous, 1996). Figures 3 and 4

represent two common activation functions which also happened to be used by the network

tested during this research. The first is the logistic or sigmoid function f(x) = 1/(1+exp(-X)).

The second is the gaussian function f(x) = exp (- 2X ).

Page 19: THESIS - Advanced Neural Network and Genetic Algorithm Software

5

Figure 3. Logistic Activation Function

Figure 4. Gaussian Activation Function

The final output of the neuron represents the output of the activation function. Large

numbers of interconnected artificial neurons have the ability to learn or store knowledge in

0

0.2

0.4

0.6

0.8

1

1.2

-6 -4 -2 0 2 4 6

-0.2

0

0.2

0.4

0.6

0.8

1

1.2

-4 -3 -2 -1 0 1 2 3 4

Page 20: THESIS - Advanced Neural Network and Genetic Algorithm Software

6

their synaptic weights. The learning ability of an artificial neural network will be discussed

later, however this property makes it ideal for trying to identify signals within a noisy data

flow. One example of such a data flow would be the closing price of the S&P500.

2. Objectives

The objective of this research was to examine the theory of Backpropagation neural

networks and then develop a model that would accurately predict the future closing price of

the S&P500 using a commercially available software package. Once this was accomplished,

the probability of an accurate forecast would be calculated. Given the accuracy of the

forecast, the benefits of the network to the investor would be determined.

3. The Research Question

The following research questions allow the research to meet the objectives proposed:

• What are the similarities between the Backpropagation neural network and thebiological systems after which they were designed?

• What is the mathematical theory behind the Backpropagation neural network?

• Can neural networks accurately forecast a stock market index?

• Can multiple regression analysis accurately forecast a stock market index?

• Can neural networks be used as a practical forecasting tool by individualinvestors?

Page 21: THESIS - Advanced Neural Network and Genetic Algorithm Software

7

4. Scope, Limitations and Assumptions

The potential combinations of financial market indices or stocks, and neural network

type are virtually limitless. For this reason, the research was limited to one stock market

index, one neural network type and one statistical forecast tool. This allowed the research

to build upon and validate previous research and place boundaries around the vast topic of

time series forecasting.

The single limitation in this research was the availability of data. Gately trained his

network on approximately four years of historical data. The Goldman Sachs Technology

Indicator Index for Semiconductors was added to the raw data set in 1996, so the availability

of data was significantly reduced. This limited the training and testing of the networks to two

years of data. However, this did not seem to reduce the effectiveness of the network.

It is assumed that the reader has little or no knowledge of neural networks or

statistical time series analysis.

5. Literature Review and Methodology

In his book Neural Networks for Financial Forecasting, Edward Gately describes the

methodology needed to develop a network to accurately forecast financial markets. As an

example, he develops a model that predicts the S&P500 closing value 10 days into the future.

This research provides an independent validation of Gately’s research and builds on it by

comparing the network output to a more traditional statistical tool, multiple regression

analysis. Additionally, model accuracy probabilities are examined using Bayes’ Theorem.

The methodology used while conducting the research is as follows:

Page 22: THESIS - Advanced Neural Network and Genetic Algorithm Software

8

• Conduct a literature search of books, magazines, and the World Wide Web onthe topic of neural networks.

• Identify the mathematical theory behind the Backpropagation neural networks.

• Identify a Stock Index to make forecasts upon.

• Determine what to forecast and the future point for the forecast (10 days intothe future).

• Determine the inputs to the neural network using economic theory and WardSystems Group Inc., NeuroShell 2 Professional Optimizer Package.

• Assemble the historical input data and preprocess it using Microsoft Excel.

• Using historical data, train and evaluate two different networks using WardSystems Group Inc., NeuroShell 2 Professional.

• If needed, reassess the network inputs, retrain and evaluate the networks usingWard Systems Group Inc., NeuroShell 2 Professional.

• Attempt to forecast using multiple linear regression techniques.

• Statistically compare network forecasts vs. regression forecasts.

• Determine the historical averages of the item being forecasted occurring usingMicrosoft Excel and data taken from the Omega Research, Wall StreetAnalyst historical data CD-ROM and Dial Data Downloader.

• Determine probabilities for a successful forecast using Bayes’ Theorem.

6. Organization of Study

The remaining portion of the thesis is broken up into the following chapters:

Literature Review and Theoretical Framework, Methodology, Presentation of Data Collected,

Data Analysis, and Conclusions and Recommendations. Within the literature review,

pertinent literature is reviewed and the history and theory of Backpropagation neural

networks is discussed. The methodology describes the steps taken to answer the research

Page 23: THESIS - Advanced Neural Network and Genetic Algorithm Software

9

questions. Presentation of Data Collected compiles pertinent tables and charts collected

during the research. Data analysis follows with a statistical and graphical review of the

information presented. The thesis closes with the conclusions and recommendations.

Page 24: THESIS - Advanced Neural Network and Genetic Algorithm Software

10

Page 25: THESIS - Advanced Neural Network and Genetic Algorithm Software

11

II. LITERATURE REVIEW AND THEORETICAL FRAMEWORK

A. LITERATURE REVIEW

The potential use of neural networks as a tool for predicting financial markets has

been marketed at increasing levels in recent years. Published research providing a step by step

explanation of input data identification through network architecture design and finally output

analysis is somewhat sparse, however. Kartalopoulos (1996), Dhar and Stein (1996), and

Ward and Sherald (1995) all mention to varying degree that neural networks have the

capability to forecast financial markets. Smolensky, Mozer, and Rumelhart (1996, p. 395)

provide Weigand’s thoughts on time series analysis and prediction. Although extremely

technical, it touches on financial market prediction and provides a good overview of time

series analysis. He breaks time series analysis into forecasting and modeling. Forecasting is

short-term prediction while modeling tries to identify features that accurately predict long

term trends. Wiegand states that these can be quite different and that the laws governing a

short-term forecast may not substantially relate to the long-term model or the actual

characteristics of the system.

More specifically, Weigand claims that the “…complexity of a model useful for

forecasting may not be related to the actual complexity of the system.” Potentially models

can accurately predict markets where they are substantially less complex than the market

itself. Lowe (1994) focuses on portfolio optimization and short term equity forecasting.

Some believe that efficient market theory causes predictions based upon historical price

patterns to be valueless. However, Lowe (1994) postulates that “A system which is

apparently random could have significant deterministic components embedded in its data.”

Page 26: THESIS - Advanced Neural Network and Genetic Algorithm Software

12

He states that a neural network’s “…ability to create nonlinear approximations to the

underlying generators of data…may be exploited.” Lowe (1994) concludes that it would be

possible to develop an “…automated trading system based entirely upon quantitative pattern

processing techniques capable of consistently outperforming professional traders.”

Lederman and Klein (1995, p. 65) provide Jurik’s thoughts on trading system

development. Although Jurik does not provide specific examples of trading systems, he

provides a wealth of advice on data preprocessing techniques. He states, “Strive for simple

models having only a few choice input variables.” He supports this by explaining that as the

number of model inputs increase, the degrees of freedom of the governing equation also

increases. While equations with high degrees of freedom have the capability to model the

training data effectively, they fail miserably when given test data. This is because models with

fewer degrees of freedom do not try to trace the data’s random scattering but only follow the

general trend. Jurik also states that “When trying to remove unimportant variables, sensitivity

analysis of nonstationary or nonlinear models has dubious practical value.” This is extremely

important because this is one of the standard techniques used in regression analysis. If applied

to a neural network model it could seriously fail. Jurik states there are only two ways to

correctly remove unimportant variables. The first is to use a genetic algorithm to develop

multiple combinations of input variables while only letting the most accurate survive. The

second is a manual method of systematically removing one variable at a time and recording

network accuracy. This technique is repeated until the accuracy of the model starts

decreasing.

Page 27: THESIS - Advanced Neural Network and Genetic Algorithm Software

13

While all these authors hint at the capability of neural networks in forecasting financial

markets, the researcher found only one text that meticulously tracks the development of the

neural network from data gathering and preprocessing to training and application of the net.

This text is Edward Gately’s Neural Networks for Financial Forecasting. This research uses

Gately’s (1996) techniques for developing a model to predict the closing price of the

S&P500. His model is slightly improved upon and compared to more standard regression

methods for forecasting. Additionally and potentially most importantly for the investor,

model accuracy probabilities were generated. This was done by combining historical market

movement probabilities with the model accuracy probability. This conditional probability

could prove to be a vital tool for investment decision making.

B. THEORETICAL FRAMEWORK

As described previously, a neural network is a computer program or hardwired

machine that is designed to learn in a manner similar to the human brain. Additionally, Figure

2 showed how an artificial neuron processes input data into an output signal. However, the

most important feature of a neural network has not been explained: how a neural network

learns. This research focuses on the Backpropagation algorithm learning method. The

following derivation is taken from the explanation provided by Dhar and Stein (1996). All

mathematical formulae refer to Figure 5 below. This figure depicts a single artificial neuron,

which learns using the Backpropagation learning algorithm.

Page 28: THESIS - Advanced Neural Network and Genetic Algorithm Software

14

Figure 5. Artificial Neuron Using Backpropagation Learning

The Backpropagation algorithm seeks to minimize the error term between the output

of the neural net and the actual desired output value. The error term is calculated by

comparing the net output to the desired output and is then fed back through the network

causing the synaptic weights to be changed in an effort to minimize error. The process is

repeated until the error reaches a minimum value. The network uses Equation 1 to update

the weight ijW from a given node iN to the current node jN ; where t refers to the number of

times the network has been updated and λ refers to the learning parameter. The learning

parameter, or learning rate, controls the rate the weight is changed as learning takes place.

The sensitivity of node jN to a change in weight ijW is represented by ijWε and will be

defined more fully below.

( )( )( )iijtijtij NWWW ελ+=+ ,)1,( (1)

Ni(1)

Ni(2)

W ij(1)

W2ij(2)

iji

ij WNS ∑=N1

jSje

N −+=

1

1

Dj

2)(2

1 ∑ −=output

jj DNE

( )jjj

jj

DNO

N

EO

−=

∂∂

=

ε

ε

( )jjjj

jj

NNOS

S

ES

−=

∂∂

=

1εε

ε

)()(

)()(

nijnij

nijnij

NSW

W

EW

εε

ε

=

∂∂

=

Page 29: THESIS - Advanced Neural Network and Genetic Algorithm Software

15

The total input to a node is described in Equation 2 as:

iji

ij WNS ∑= (2)

where jS is the sum of all inputs to a node, iN is the output of the previous node, and ijW is

the weight connection between the ith node of the previous layer.

This output is then transformed using the logistic activation function described in

chapter I and represented by Equation 3. The total output of node j is represented by jN .

Sjj eN −+

=1

1(3)

The overall error for a single pass of the neural network is represented by Equation

4, where jD is the desired output of the output node j.

( )2

2

1 ∑ −=Output

jj DNE (4)

Now that the error term for the entire network has been calculated, this information

is fed back through the network to reduce error. The simplified partial differential equations

required to change the connection weights are provided below; the original equation before

simplification can be found in Figure 5.

First, the error term for each output node jO must be calculated. Essentially we are

trying to identify how much the error term changes with respect to a change in each output

node. This calculation is simplified in Equation 5 below:

Page 30: THESIS - Advanced Neural Network and Genetic Algorithm Software

16

( )jjj DNO −=ε (5)

Second, the amount the error term changes as the input is varied to a given output

node must be calculated. This is done by determining how much Equation 4 changes when

the total input to the node (Equation 2) is changed. This calculation is simplified in Equation

6 below:

( )jjjj NNOS −= 1εε (6)

Next, the weight adjustment needed for ijW is calculated from a layer below the

current layer ( iN ) to the current node jN . The calculation is simplified in Equation 7 below:

ijij NSW εε = (7)

Finally this operation is continued on nodes in lower layers by allowing nodes in the

lower hidden layers to play the role of the output node. All errors from all inputs to the

hidden layer must be summed. Additionally, the error in the hidden node is calculated by

examining how the error of nodes above the hidden node change with respect to changes in

the hidden node. The simplified equation for calculating the weight update is provided in

Equation 8 below, where the subscript j represents nodes in the layer above the hidden layer.

ijj

ji WSH ∑= εε (8)

Dhar et al (1996) states, “In this manner the error of the network is propagated

backward recursively through the entire network and all of the weights are adjusted so as to

minimize the overall network error.”

Page 31: THESIS - Advanced Neural Network and Genetic Algorithm Software

17

Page 32: THESIS - Advanced Neural Network and Genetic Algorithm Software

18

III. METHODOLOGY

This section discusses the techniques used to develop the neural network and multiple

regression financial forecasting models. The combination of these models, with historical and

conditional probabilities, will allow the investor to make decisions based on probabilities of

success. The presentation first discusses the development of the models, followed by the

historical probability calculations and concludes with the conditional probability calculation.

The information to be forecast was first identified. Since this research extended and

verified Gately’s (1996) work with neural networks, a similar model output was chosen for

at least one model for comparison purposes. Two separate model outputs were chosen, the

first was the S&P 500 closing value ten days into the future—the output chosen by Gately,

and the second was the future S&P500 ten day percent change. As described by Gately, a

much more accurate forecast is possible when predicting the percent change versus the actual

closing value of a stock or index. For example, if the S&P500 index was valued at 1400

dollars and a model that predicted the closing value had a ten-percent error the potential

output inaccuracy would be 140 dollars. If the same index had made a ten-percent price

change and the model that predicted the percent change of price had a ten-percent error, the

potential output inaccuracy would be one-percent. For a ten-percent price change, from 1272

dollars to 1400 dollars, this inaccuracy would translate into approximately a twelve dollar

error.

The first neural network model, named Close Network, was chosen to be a

verification of Gately’s (1996) work and predicted the S&P500 index ten days into the future.

Page 33: THESIS - Advanced Neural Network and Genetic Algorithm Software

19

The inputs to the model where developed by first downloading the following raw data from

Dial Data using Data Downloader software from Omega Research:

S&P 500 Index *SPX

Dow Jones Transportation Index *DWT X

Dow Jones Industrial Index *DWI X

Dow Jones Utilities Index *DWU

Commodities Research Bureau *CRB

AMEX Oil Index *XOI

Gold and Silver Mining Index *XAU

The data set encompassed the trading days from March 1, 1991 to August 18, 1998.

The data was charted using stock charting software called Wall Street Analyst Deluxe

from Omega research. This established date integrity within each index. The indices were

then exported and saved as a text file from Wall Street Analyst. Using Microsoft Excel, each

index text file was combined into one spreadsheet. The resulting file was formatted such that

each index and its date was in a separate column with each row representing a trading day.

An example of a partial data set can be found in Appendix B. Date integrity is extremely

important to the neural network. To ensure integrity was maintained, each index’s date

column was checked for integrity against the S&P500 date using a simple “if then” rule in

Excel. If the dates were equal, it placed a zero in a row. If the dates were not equal, Excel

placed a 1 in a row. This function was copied down the entire data set and then summed at

the bottom. A sum of zero represented no date integrity discrepancies. A sum of anything

greater than zero indicated that a date discrepancy existed. The sum was zero for all indexes

Page 34: THESIS - Advanced Neural Network and Genetic Algorithm Software

20

with the exception of *CRB. Within *CRB it was found that one trading day was missing.

Instead of deleting the index, the trading day was added. The average closing value of the

day proceeding and following the missing day was chosen to represent the missing day.

The last column in the spreadsheet was titled “Future (10 day) S&P500 C.” This

represents the future closing price of the S&P500 Index and was the actual value the network

used to compare against its prediction during training. This “future” information was created

by simply copying the S&P 500 closing price into the last column of the spreadsheet deleting

the first 10 days of data and moving the remaining data up 10 rows. Once this was complete,

all date columns were deleted with the exception of the one associated with the S&P 500

data. The file was saved as an Excel 4 worksheet so it could be imported into Neuroshell 2

Professional. The following data was imported into the neural network software package as

a pattern file:

Date

S&P500 H

S&P500 L

S&P500 C

Dow Transportation Index C

Dow Utilities Index C

Amex Oil Index C

CRB CDow Industrial Index V

Gold and Silver Mining C

Future (10 days) S&P500 C

Page 35: THESIS - Advanced Neural Network and Genetic Algorithm Software

21

The pattern file was then altered using the software’s Market Indicator module to

include all the inputs described by Gately (1996). The following technical indicators were

added:

MvAvg (30) of Dow Industrial Index V

Lag (10) of CRB C

Lag (10) of Amex Oil Index C

Lag (10) of Dow Transportation Index C

These technical indicators represent a thirty-day moving average of the Dow Industrial Index

Volume and a ten-day lag of various other raw data.

Within the Define Inputs module of the Neuroshell2, each column of the data file was

identified either as Unused, Input, or Actual Output. The date and raw volume information

was excluded by defining it as Unused. The Future (10 days) S&P500 Close was defined as

the Actual Output and all others were defined as inputs. The minimum and maximum values

for each data column were then automatically calculated for use by the network. Next a test

set or “out of sample” data set was extracted from the data set. Every tenth data set was

chosen to represent the test data. There were 1700 training rows and 188 test rows. In the

Designing the Network module, the software recommended using a Ward Network. The

Ward Network is a backpropagation network with one input layer, three hidden layers and

one output layer. Each layer is called a slab. Each slab is made up of one to sixteen

individual neurons depending on the location within the network. Each slab also has a

different activation function as described below:

Page 36: THESIS - Advanced Neural Network and Genetic Algorithm Software

22

Slab 1 (input): Linear [-1,1], 13 Neurons

Slab 2 (hidden): Gaussian, 16 Neurons

Slab 3 (hidden): tanh, 16 Neurons

Slab 4 (hidden): Gaussian comp., 16 Neurons

Slab 5 (output): logistic, 1 Neuron

The learning rate was set to .05 and the momentum was set to .5. Within the Training

Criteria module, pattern selection was set to random, calibration interval was set to every 200

patterns and stopping criteria was set to stop training at 40,000 events since min average

error within the test set. Within the training module, the network was set to automatically

save the weights for the best test set. The network was then trained within the Training

module. The trained network was then applied to the 188 sample test patterns.

The network output is a file that contained three columns: Actual (1), Network (1)

and Act (1)-Net (1) representing the actual S&P500 closing value, the network prediction and

the network error. This file was opened and actual vs. predicted charts were created within

Excel. Additionally, the descriptive statistics for the network error were calculated. The

Close Network was able to make predictions with accuracy comparable to Gately’s (1996)

model.

The second network model, called Percent Network, was designed to predict the

future S&P500 ten day percent change taking advantage of the possible reduction in

prediction error. The network was provided the same raw data as the Close Network.

However, two new columns were created in the raw data file. The first column was defined

as the ten-day % change in the S&P500 Closing price. Starting on the 10th day, this was

Page 37: THESIS - Advanced Neural Network and Genetic Algorithm Software

23

calculated using the following formula (cell 1-cell 11)/cell 1*100. The second column was

defined as the future ten-day % change. Essentially, the ten-day % change column was

copied into the new column and the values were shifted back ten days. The future ten-day

percent change was the actual desired output of the net and was used during training to

calculate error.

The file was imported into Neuroshell2 and preprocessed. During preprocessing, the

following technical indicators were added to the data file:

MvAvg (30) of Dow Industrial Index V

Lag (10) of CRB C

Lag (10) of Amex Oil Index C

Lag (10) of Dow Transportation Index C

LinRegChange (10,5) of S&P500 C

LinRegChange (10,10) of S&P500 C

The technical indicator LinRegChange (x,n), as described in Neuroshell2 Professional,

represents “Predicted change between current value and the value time periods into the future.

Prediction is based upon the linear regression line calculated from the last n time periods.”

The test set extraction, network design and training settings were identical to the Close

Network. Essentially, the Percent Network would look at the same raw data, with added

indicators, as the Close Network but would predict a percent change versus a closing price.

The same out of sample data was used. When the Percent Network (1) was applied to the

out of sample data, it performed relatively poorly when compared to the Close Network.

Page 38: THESIS - Advanced Neural Network and Genetic Algorithm Software

24

To increase the accuracy of the Percent Network, the net inputs were changed. The

LinRegChange (10,5) of S&P500 C was removed and LinRegPredict (10,10) of S&P 500 10

day % Change was added. The technical indicator LinRegPredict (x,n), as described in

Neuroshell2 Professional, represents the “Predicted value x time periods into the future.

Prediction is based upon the linear regression line calculated from the last n time periods.”

After training and application to the out of sample data, Percent Network (2) showed only

slight improvement in prediction accuracy.

The network inputs were again adjusted to try and increase accuracy. The technical

indicator LinRegChange (10,10) of S&P500 C was removed as an input. After training and

application to the out of sample data, the Percent Network (3) accuracy decreased.

At this point, the decision was made to augment the moving average of the volume

with the raw volume data in the network. The Percent Network (5) performed only slightly

better after including raw volume.

A close review of the raw data used in Gately’s model and the Close Network showed

little if any input from the technology sector. A technology component was added to the net

to improve accuracy. This net was called Percent Network (5) and was based on the most

accurate network up to that point, Percent Network (2). It included an added indicator, the

closing value of GSM the Goldman Sachs Technology Indicator Index for Semiconductors.

Unfortunately, GSM has only been in existence since 1996, so the data set was significantly

reduced. The full raw data set begins on July 18, 1996 and ends August 12, 1998. Due to

the reduced amount of available data, every 5th data set was chosen to represent the test or

out of sample data. There were 419 training rows and 104 test rows. Percent Network (5)

Page 39: THESIS - Advanced Neural Network and Genetic Algorithm Software

25

was trained and applied to the out of sample data. The network showed significant

improvement, although the 2r value was still not as high as the Close Network.

In Percent Network (6), the ten-day lag of GSM C was added as an input to improve

prediction capability. The network was trained and applied to the out of sample data set.

Although its 2r value was slightly lower than Percent Network (5), it was chosen as the final

Percent Network because it had a lower percent error over 30% and there were predictions

within 5%.

The addition of the new GSM C data to the Percent Network had significantly

improved its accuracy, and could do the same for the Close Network. Also the networks

were using data from significantly different time periods, making comparison between the two

questionable. Therefore, the GSM C and Lag of GSM C was added to the Close Network

causing the data window to match the Percent Network. All data prior to July 18, 1996 was

discarded. In the Extraction Module, every 5th data set was chosen to represent the test or

out of sample data. Both models were now training on identical raw data. After training, the

network was applied to the out of sample data. The results showed a slight decrease in

2r value but fully 100 percent of the predictions were within five percent of the actual closing

value. This network was chosen to be the final Close Network model.

The actual and predicted values from both the Close and Percent networks were

placed into one spreadsheet. The predicted closing value of the S&P500 index was calculated

using the predicted % change provided by the Percent Network. This allowed comparison

of a single type of data between both networks. The two predicted closing values where

Page 40: THESIS - Advanced Neural Network and Genetic Algorithm Software

26

compared graphically and statistically. This completed the neural network portion of the

research.

A more traditional statistical forecasting tool is regression analysis. This method uses

the sum of the least squared errors to fit a curve to a data set. The decision was made to try

and predict the S&P500 closing value using the same data used in the Close Network. The

dependant variable was designated as the Future (10 days) S&P500 C column. The following

columns were listed as independent variables: S&P500 H, S&P500 L, S&P500 C, Dow

Transportation Index C, Dow Utilities Index C, Amex Oil Index C, CRB C, Gold and Silver

Mining C, GSM C, MvAvg(30) of Dow Industrial Index V, Lag(10) of CRB C, Lag(10) of

Amex Oil Index C, Lag(10) of Dow Transportation Index C, and Lag(10) of GSM C. Using

the data analysis tool within Excel, a multiple linear regression analysis was performed on the

data set.

When conducting multiple linear regression analysis, the following assumptions must

hold for the model to be correct: 1. Normality 2. Homoscedasticity 3. Independence of

Errors and 4. Linearity. Normality assumes the value of the Y (the dependant variable) must

be normally distributed for each value of X (the independent variable). According to Levine,

Berenson, and Stephan (1997), regression analysis is fairly robust against departures from the

normality assumption. One method of verifying the normality assumption is to construct and

examine a Normal Probability Plot for the dependant variable. The Normal Probability Plot

was created in Excel using the regression analysis tool. The points on the plot seemed to

deviate from a straight line in a random manner. This indicates normality. If the line had risen

Page 41: THESIS - Advanced Neural Network and Genetic Algorithm Software

27

more steeply at first and then increased at a decreasing rate it would have indicated a left

skewed data set. The opposite is true for a right skewed data set.

Homoscedasticity assumes variation or error around the regression line should be

similar for low and high values of the independent variable. This can be verified by examining

the residual plots for each independent variable. For each variable, there did not seem to be

major differences in the variability of the residual for different values of the independent

variable. Therefore, the Homoscedasticity assumption was valid.

Autocorrelation, or the likelihood that a certain type of error precedes or follows

another type of error, violates the independence of errors assumption. If errors are

correlated, there will be a pattern of positive errors following positive errors and negative

errors following negative errors. The simplest way to rule out Autocorrelation is to plot the

residuals over time. The residual vs. time plot showed no pattern and indicated the absence

of Autocorrelation. Therefore, the Independence of Errors assumption seemed valid.

The regression line fit plots indicated a probable linear relationship of varying degrees

between the dependant variable and each of the independent variables. This was verified

because there was no pattern in the residual plots for each independent variable. Therefore,

the linearity assumption seemed valid.

All four assumptions of regression analysis were verified so a linear regression model

seemed appropriate. When using Multiple Regression, the objective is to utilize only those

variables that have a significant relationship with the dependant variable. The first step in

determining a significant relationship between the dependant and independent variable was

to conduct an F test. The F test was used to determine if there was a significant relationship

Page 42: THESIS - Advanced Neural Network and Genetic Algorithm Software

28

between the dependant variable and the chosen independent variables. The null hypothesis

was that there was no linear relationship between the dependent variable and indeptendent

variables; the alternative hypothesis was that at least one regression coefficient was not equal

to zero. The null hypothesis is rejected at a certain level of significance if the estimated value

F is greater than the critical value of F. Excel’s ANOVA calculation provided the value for

F; it was 1416. For a 95% confidence interval, the value of the critical F was obtained from

Levin et al’s (1997) Critical Values of F table. The critical value for F(14,469) is

approximately 1.67. Therefore, F was greater than the critical value of F and the conclusion

can be made that at least one of the independent variables was related to the dependant

variable.

The next step was to test individual portions of the multiple regression model. If

individual variables have no significant effect on the model, they should be removed and a

new regression calculated. The t test was used to determine if an individual indepen-dent

variable had a significant effect on the dependant variable, taking into account the other

independent variables. The null hypothesis was that there was no relationship between the

independent and dependant variable; the alternative hypothesis was that there was a

relationship. The decision rule was to reject the null hypothesis if the estimated t was less

than negative t critical or greater than t critical. For a 95% confidence interval, the critical

value for t was obtained from Levin et al’s (1997) Critical t Table. The critical values for t

(.025,14) were –2.1448 and 2.1448. Eight of the 14 independent variables failed the t test and

did not have a significant relationship to the dependant variable. The regression was

recalculated using only those independent variables that passed the t test.

Page 43: THESIS - Advanced Neural Network and Genetic Algorithm Software

29

At this point, all assumptions were reevaluated and found to still be valid. The F test

was then repeated on the second regression model. The critical value of F(6,477) is

approximately 2.1. The model passed the F test. Therefore, at least one of the explanatory

variables was related to the dependant variable. The t test was then repeated on the second

regression model. The critical value of t(.025,6) is 2.4469. In reviewing the t values, it was

determined that there is a significant relationship between the dependant variable and all

independent variables with the exception of Gold and Silver Mining C. This input was

dropped and a third regression was calculated.

Again all regression assumptions were reevaluated and found to be valid. The F test

was then repeated on the third regression model. The critical value of F (5,477) is

approximately 2.21. The model passed the F test. Therefore, at least one of the explanatory

variables is related to the dependant variable. The t test was then repeated on the second

regression model. The critical value of t (.025,6) is 2.5706. In reviewing the t values, there

was a significant relationship between the dependent variable and all independent variables.

The final test of the validity of the multiple regression model is to verify there is no

multicollinearity between the independent variables. According to Levine et al (1997), when

two independent variables are highly collinear they can cause the regression coefficients to

fluctuate drastically if one or both are included in the model. It is difficult to separate the

effect of to two collinear independent variables on the dependant variable. The measure of

collinearity is the Variance Inflationary Factor (VIF). For each of the independent variables,

the VIF was calculated using excel. If sets of variables are uncorrelated, the VIF will equal

1. For highly intercorrelated variables, the VIF can exceed 10. According to Levine et al

Page 44: THESIS - Advanced Neural Network and Genetic Algorithm Software

30

(1997), a VIF greater than 10 indicates there is too much correlation between the independent

variables. In the third regression model, all VIF values were less than 10. Therefore, the

third regression model was fully optimized and verified and was chosen as the final model to

compare to the two neural networks.

With three working forecasting models, the next step was to calculate the probability

that each model’s prediction will be accurate. The calculation was based upon Bayes’

Theorem, or conditional probability. Bayes’ Theorem states that a probability depends upon

the environment in which it is based. A conditional probability is stated as given X what is

the probability of Y or XYP . First the researcher had to find something that could easily

be identified in the environment. It would be tedious to try and calculate probabilities for

individual S&P500 closing values or individual percent changes. However, one could

calculate the number of times the market rose or fell; this is potentially enough information

for the investor. The market rise or fall corresponds to percent change, which is the output

of the Percent Network. Percent changes can also be calculated from the output of the Close

Network and the Regression Model.

Therefore, the question used to calculate the probability that each model’s prediction

is accurate is: given a certain amount of historical daily market rises, when a model predicts

a market rise, what is the probability of it actually occurring. Mathematically this would be

stated as RiseHistoricalRiseForecastedP . Rather than using the mathematical form of

Bayes' Theorem, the conditional probability was calculated in a spreadsheet using a method

described by Dr. Katsuaki Terasawa of the Naval Postgraduate School. First, the historical

data was calculated within Excel from the raw data during the period from March 3, 1991 to

Page 45: THESIS - Advanced Neural Network and Genetic Algorithm Software

31

August 18, 1998. An if-then statement was used to identify a percentage rise. The statement

generates a one if the percent change is greater than zero or a zero if the percent change is

less than zero. Summing this column provides the total days with a percent increase. This

was subtracted from the total number of days in the data set to identify market falls. The

number of times the market rose and fell was calculated.

Next, the accuracy of each model was calculated. The output of each model for the

out of sample data was used. The if-then technique was used to identify when both the model

forecast and the actual data agreed or disagreed as to a market rise or fall. This data could

be entered into Bayes' theorem to obtain the conditional probability. However the accuracy

of the model was adjusted using the historical environmental data as described by Professor

Terasawa. Calculating the probability of accurately predicting a rise or fall in the S&P500

Index became a simple matter of dividing accurate rise or fall predictions by total rise or fall

predictions.

Page 46: THESIS - Advanced Neural Network and Genetic Algorithm Software

32

Page 47: THESIS - Advanced Neural Network and Genetic Algorithm Software

33

IV. PRESENTATION OF DATA COLLECTED

In this section the research data will be presented and important items will be

identified. The presentation begins with vital data for each of the forecasting models, follows

with the historical probabilities, and concludes by presenting conditional probabilities.

A. Close network

The following vital data given in Table 1 and Figures 6 and 7 is from the completed

training module:

Table 1. Training Module Output Close Network

Training Set Test Set

Learning events 559800 N/A

Learning epochs 1446 N/A

Minimum average error 0.0002282 0.0002896

Training Time 02:37 Minutes

Page 48: THESIS - Advanced Neural Network and Genetic Algorithm Software

34

Figure 6. Training Error on Close Network Training Set

Figure 7. Training Error on Close Network Test Set

The trained network was applied to the 99 out of sample test patterns. The results are shown

in Table 2.

Page 49: THESIS - Advanced Neural Network and Genetic Algorithm Software

35

Table 2. Close Network Output Statistics

R squared 0.9935

r squared 0.9935

Mean squared error 130.975

Mean absolute error 8.821

Min. absolute error 0.039

Max. absolute error 31.792

Correlation coefficient r 0.9968

Percent within 5% 100

Percent within 5% to 10% 0

Percent within 10% to 20% 0

Percent within 20% to 30% 0

Percent over 30% 0

Figure 8 is a graphical depiction of how the Close Network weighted the contribution of each

input to the model.

Page 50: THESIS - Advanced Neural Network and Genetic Algorithm Software

36

Figure 8. Input Contribution Factors Close Network

0

0.02

0.04

0.06

0.08

0.1

0.12

Network Inputs

Page 51: THESIS - Advanced Neural Network and Genetic Algorithm Software

37

Figure 9 is a graphical depiction of the Close Network’s forecast versus the actual S&P500

Close.

Figure 9. Close Network Actual vs Predicted S&P500 Close

600

700

800

900

1000

1100

1200

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

Time (trading days)

ActualS&P500 C

PredictedS&P500Close usingCloseNetwork

Page 52: THESIS - Advanced Neural Network and Genetic Algorithm Software

38

Figure 10 is a graphical depiction of the Close Network’s forecast error.

Figure 10. Close Network Error

The Close Network error was input into Excel and the Descriptive Statistics tool was used

to generate Table 3.

Table 3. Close Network Descriptive Statistics

Mean 0.175905208

Standard

Error

1.167902939

Median -0.257263184

Standard

Deviation

11.50250998

-40

-30

-20

-10

0

10

20

30

40

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

Time (trading days)

CloseNetworkError

Page 53: THESIS - Advanced Neural Network and Genetic Algorithm Software

39

Table 3 (Continued)

Sample

Variance

132.3077358

Kurtosis 0.240087928

Skewness 0.050247272

Range 61.15527344

Minimum -31.79174805

Maximum 29.36352539

Sum 17.06280518

Count 97

Confidence

Level(95.0%)

2.318270784

B. percent network

The following vital data given in Table 4 and Figures 11 and 12 is from the completed

training module:

Table 4. Training Module Output Percent Network

Training Set Test Set

Learning events 221400 N/A

Learning epochs 572 N/A

Minimum average error 0.0016160 0.0026779

Training Time 01:14 Minutes

Page 54: THESIS - Advanced Neural Network and Genetic Algorithm Software

40

Figure 11. Training Error on Percent Network Training Set

Figure 12. Training Error on Percent Network Test Set

The trained network was applied to the 99 out of sample test patterns. The results are shown

in Table 5.

Table 5. Percent Network Output Statistics

R squared 0.7872

r squared 0.7933

Mean squared error 1.449

Mean absolute error 0.919

Page 55: THESIS - Advanced Neural Network and Genetic Algorithm Software

41

Table 5 (Continued)

Min. absolute error 0.006

Max. absolute error 4.484

Correlation coefficient r 0.8907

Percent within 5% 10.309

Percent within 5% to 10% 6.186

Percent within 10% to 20% 20.619

Percent within 20% to 30% 11.340

Percent over 30% 51.546

Figure 13 is a graphical depiction of how the Percent Network weighted the contribution of

each input to the model.

Page 56: THESIS - Advanced Neural Network and Genetic Algorithm Software

42

Figure 13. Input Contribution Factors Percent Network

Figure 14 is a graphical depiction of the Percent Network’s forecast versus the actual

S&P500 Close.

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

Inputs

Page 57: THESIS - Advanced Neural Network and Genetic Algorithm Software

43

Figure 14. Percent Network Actual vs. Predicted Future 10 Day Percent Changeand Closing Price of S&P500

-8

-6

-4

-2

0

2

4

6

8

10

1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96

101

Time (trading days)

0

200

400

600

800

1000

1200

1400

Actual %Change

Predicted% Change

ActualS&P500 C

PredictedS&P500CloseusingPercentNetwork

Page 58: THESIS - Advanced Neural Network and Genetic Algorithm Software

44

Figure 15 is a graphical depiction of the Percent Network’s forecast error.

Figure 15. Percent Network Error

The Percent Network error was input into Excel and the Descriptive Statistics tool was used

to generate Table 6.

-3

-2

-1

0

1

2

3

4

5

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97

101

Time (trading days)

PercentNetworkError

Page 59: THESIS - Advanced Neural Network and Genetic Algorithm Software

45

Table 6. Percent Network Descriptive Statistics

Mean -1.081002006

Standard

Error

1.107737379

Median -0.437339914

Standard

Deviation

10.90994792

Sample

Variance

119.0269637

Kurtosis 1.792340417

Skewness 0.530272064

Range 68.62393946

Minimum -26.16139546

Maximum 42.462544

Sum -104.8571946

Count 97

Confidence

Level(95.0%)

2.198842999

Figure 16 is a graphical depiction of the both the Close and Percent Network’s forecast

versus the actual S&P500 Close.

Page 60: THESIS - Advanced Neural Network and Genetic Algorithm Software

46

Figure 16. All Network Models Actual vs. Predicted S&P500 C

Figure 17 is a graphical depiction of both the Percent Network and Close Network forecast

error.

6 0 0

7 0 0

8 0 0

9 0 0

1 0 0 0

1 1 0 0

1 2 0 0

1 3 0 0

1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101

Time (trading days)

ActualS&P500 C

PredictedS&P500CloseusingCloseNetwork

PredictedS&P500CloseusingPercentNetwork

Page 61: THESIS - Advanced Neural Network and Genetic Algorithm Software

47

Figure 17. S&P500 Closing Value Prediction Neural Network Model Error Chart

C. Multiple linear regression model

Multiple linear regression analysis was performed using the Data Analysis tool within

Excel. The output of this process for the final model is presented in Table 7.

Table 7. Regression Statistics

Multiple R 0.983432302

R Square 0.967139093

Adjusted R Square 0.96679536

Standard Error 25.81440036

Observations 484

-40

-30

-20

-10

0

10

20

30

40

50

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

Time (trading days)

CloseNetworkError

PercentNetworkError

Page 62: THESIS - Advanced Neural Network and Genetic Algorithm Software

48

Table 7 (Continued)

ANOVA

Df SS MS F

Regression 5 9374786.243 1874957.249 2813.63195

Residual 478 318531.2012 666.3832661

Total 483 9693317.444

Coefficients Standard Error t Stat P-value

Intercept 1523.248565 96.30217982 15.81738407 1.25634E-45

Dow

Transportation

Index C

0.173215277 0.008063272 21.48200959 3.79263E-72

Dow Utilities

Index C

-0.512956407 0.157214185 -3.262787046 0.00118219

Amex Oil Index

C

1.455027957 0.117440864 12.38945207 9.13351E-31

CRB C -5.159128047 0.28529288 -18.08362007 4.48872E-56

Lag(10) of

Amex Oil Index

C

-0.902950239 0.106686284 -8.463601907 3.19588E-16

Excel was also used to calculate the Variance Inflationary Factor (VIF). The results are given

below in Table 8.

Page 63: THESIS - Advanced Neural Network and Genetic Algorithm Software

49

Table 8. VIF for Regression Inputs

Dependant Variable R Square VarianceInflationary Factor

(VIF)Dow Transportation

Index C

0.918384 6.39

Dow Utilities Index

C

0.911393 5.90

Amex Oil Index C 0.942674 8.98

CRB C 0.855026 3.72

Lag(10) of Amex Oil

Index C

0.936325 8.11

The Normal probability plot, Line Fit Plots, and Residual Plots for the Multiple Regression

Model are provided in Appendix A.

Page 64: THESIS - Advanced Neural Network and Genetic Algorithm Software

50

Figure 18 is a graphical depiction of the Multiple Regression Model’s forecast versus the

actual S&P500 Close.

Figure 18. Regression Model Predicted vs. Actual S&P500 Close

600

700

800

900

1000

1100

1200

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

Time (trading days)

ActualS&P500 C

PredictedS&P500Close usingThirdRegressionAnalysis

Page 65: THESIS - Advanced Neural Network and Genetic Algorithm Software

51

Figure 19 is a graphical depiction of the Multiple Regression Model's forecast error.

Figure 19. Regression Model Error Chart

The Regression Model error was input into Excel and the Descriptive Statistics tool was used

to generate Table 9.

Table 9. Regression Model Descriptive Statistics

Mean 0.291446988

Standard Error 2.533807729

Median 0.001038339

Standard Deviation 24.95511202

Sample Variance 622.7576161

-80

-60

-40

-20

0

20

40

60

80

100

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

Time (trading days)

ThirdRegressionError

Page 66: THESIS - Advanced Neural Network and Genetic Algorithm Software

52

Table 9 (Continued)

Kurtosis 0.138974197

Skewness 0.071861212

Range 130.4937839

Minimum -56.84815562

Maximum 73.64562832

Sum 28.27035783

Count 97

Confidence

Level(95.0%)

5.029572436

Figure 20 is a graphical depiction of all mode forecasts versus the actual S&P500 Close.

Figure 20. Actual vs. All Model Predictions of S&P500 Close Ten Days Into Future

600

700

800

900

1000

1100

1200

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

Time (Trading Days)

ActualS&P500 C

PredictedS&P500Close usingCloseNetwork

PredictedS&P500Close usingPercentNetwork

PredictedS&P500Close usingThirdRegressionAnalysis

Page 67: THESIS - Advanced Neural Network and Genetic Algorithm Software

53

Figure 21 is a graphical depiction of all models' forecast error.

Figure 21. All Model Error Chart

D. Conditional probability

Historical data was calculated for the number of times the market rose and fell during

the period from March 3rd, 1991 to August 18th, 1998. The data in Table 10 applies:

Table 10. Historical Market Data

INITIAL KNOWLEDGE

Total Days the S&P500 Rose 1173

Total Days the S&P500 Fell 696

Total Days 1869

-80

-60

-40

-20

0

20

40

60

80

100

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101

Time (trading days)

CloseNetworkError

PercentNetworkError

ThirdRegressionError

Page 68: THESIS - Advanced Neural Network and Genetic Algorithm Software

54

The accuracy of each model was then calculated. The data in Tables 11, 12, and 13 apply:

Table 11. Close Network Accuracy

Accuracy of

Model

States of

Nature

Rise Fall Total

Rise 62 6 68

Close Network Model Fall 6 23 29

Total 68 29 97

Table 12. Percent Network Accuracy

Accuracy of

Model

States of

Nature

Rise Fall Total

Rise 65 3 68

Percent Network Model Fall 5 24 29

Total 70 27 97

Page 69: THESIS - Advanced Neural Network and Genetic Algorithm Software

55

Table 13. Multiple Regression Accuracy

Accuracy of

Model

States of

Nature

Rise Fall Total

Rise 54 14 68

Multiple

Regression Model

Fall 15 14 29

Total 69 28 97

The model accuracy was then adjusted using the environmental data. The data in

Tables 14, 15, and 16 apply:

Table 14. Close Network Environmental Adjustment

Adjustment

States of

Nature

Rise Fall Total

Rise 1069.5 144 1213.5

Close Network

Model

Fall 103.5 552 655.5

Total 1173 696 1869

Page 70: THESIS - Advanced Neural Network and Genetic Algorithm Software

56

Table 15. Percent Network Environmental Adjustment

Adjustment

States of

Nature

Rise Fall Total

Rise 1089.21 77.3333 1166.54

Percent Network

Model

Fall 83.7857 618.666 702.452

Total 1173 696 1869

Table 16. Multiple Regression Environmental Adjustment

Adjustment

States of

Nature

Rise Fall Total

Rise 918 348 1266

Multiple

Regression Model

Fall 255 348 603

Total 1173 696 1869

Finally the prediction accuracy probability was calculated for each model. The data

in Tables 17, 18, and 19 apply.

Page 71: THESIS - Advanced Neural Network and Genetic Algorithm Software

57

Table 17. Close Network Accuracy Probability

Prediction Probability

Close Network

Model

Market

Rise

88.1335

Market

Fall

84.21053

Table 18. Percent Network Accuracy Probability

Prediction Probability

Percent Network

Model

Market

Rise

93.37075

Market

Fall

88.0724

Table 19. Multiple Regression Accuracy Probability

Prediction Probability

Multiple Regression

Model

Market

Rise

72.51185

Market

Fall

57.71144

Page 72: THESIS - Advanced Neural Network and Genetic Algorithm Software

58

Page 73: THESIS - Advanced Neural Network and Genetic Algorithm Software

59

V. DATA ANALYSIS AND INTERPRETATION

Model accuracy can be compared across the three models for the following

characteristics:

• Coefficient of Multiple Determination.

• Combined Actual vs. Predicted S&P500 Close Chart.

• Error statistics, specifically the mean and standard deviation.

• All Model Error Chart.

• Conditional Probabilities.

Table 20 compares the ranked Coefficients of Multiple Determination for each model:

Table 20. Coefficients of Multiple Determination

Model R square

Close Network .9935

Regression Model .9671

Percent Network .7872

The R square value represents the proportion of variation in the dependant variable that is

explained by the independent variables. The better the model explains variation in the

dependant variable, the higher the R square value. Without further comparison, the Close

Network best explains variation in the dependant variable, followed by the Regression Model.

In examining Figure 20, Actual vs. All Model Predictions of S&P500 Close Ten Days

into the Future, it is relatively easy to visually verify that the two network models perform

better than the regression model. This differs from the model ranking due to R square values.

Page 74: THESIS - Advanced Neural Network and Genetic Algorithm Software

60

Both network models predict the closing value relatively accurately. However, it is difficult

visually to determine which of these is more accurate.

In Table 21, the ranked error statistics are provided for comparison. These statistics

are all based on closing price error. The Percent Network error was converted to closing

price error, so it could be compared to the other two models.

Table 21. Model Error Statistics

Model Mean StandardDeviation

Percent Network -1.08 10.9

Close Network .1759 11.50

Regression Model .2914 24.95

Ideally, the mean error would be zero and the standard deviation would be as small as

possible. All of the models' means are relatively close to zero. However, the breakout occurs

with standard deviation. Generally it can be said that there is a 95.44 percent probability of

the error values falling within two standard deviations of the mean. Therefore, the larger the

standard deviation the greater the range of error. Although it has a lower coefficient of

determination, the Percent Network is more accurate. This tends to support the theory that

predicting a percent change is more accurate than predicting the closing value.

Visually examining Figure 21, All Model Error Chart, clearly shows the Regression

Model has the greatest error variation. Differentiation between the two network models is

difficult, suggesting that the error statistics should provide the true ranking.

Page 75: THESIS - Advanced Neural Network and Genetic Algorithm Software

61

The final ranking test is the conditional accuracy probabilities for each model. Table

22 summarizes and ranks these probabilities for easy comparison.

Table 22. Conditional Probabilities

Probability of AccuratelyPredicting

Model Market Rise Market Fall

Percent Network 93.37 88.07

Close Network 88.13 84.21

Regression Model 72.5 57.71

Clearly, the prediction probabilities support the error statistics rankings and verify that the

Percent Network is the most accurate predictor of the S&P500 closing price.

Page 76: THESIS - Advanced Neural Network and Genetic Algorithm Software

62

Page 77: THESIS - Advanced Neural Network and Genetic Algorithm Software

63

VI. CONCLUSIONS AND RECOMMENDATIONS

A. CONCLUSIONS

It is clear from the model accuracy probabilities that neural networks can accurately

predict financial markets if given the proper data upon which to train. When compared to

regression analysis, neural networks are a better tool for the investor for the following

reasons:

• When using multiple linear regression, the governing regression assumptionsmust be true. The linearity assumption itself may not hold in many cases. Neural networks can model both linear and curvilinear systems.

• When using multiple linear regression analysis, the investor must have a deepunderstanding of statistics to ensure only the necessary independent variablesare used. This is true only to a limited degree with neural networks and canbe mitigated by the systematic removal method described by Jurik in VirtualTrading.

• For the models studied in this research, neural networks are significantly moreaccurate than multiple linear regression analysis.

However, the difficulty in identifying good raw data, preprocessing this data, training a

network and repeating this process until a good model is developed should not be discounted.

The individual investor should be warned that model accuracy is difficult to obtain and can

take months or years of investigation.

B. Recommendations

For individual investors to successfully use neural networks to predict financial

markets, they must undertake the following:

• As a minimum, read a basic text on neural networks to understand neuralnetwork theory and its limitations.

Page 78: THESIS - Advanced Neural Network and Genetic Algorithm Software

64

• Understand basic statistical measures and probability.

• Become extremely proficient with a spreadsheet software program so that datacan be preprocessed efficiently.

• Study financial market theory so that input data to the neural net is not choseninappropriately or at random.

• Obtain a neural network software program and test and evaluate many neuralnetworks. Practice by varying inputs and studying the effects on outputs.

• Once a network is developed, do not blindly follow its advice. As Gately(1996) states, try to verify it with other indicators before taking action. Inother words use multiple indicators. This could include using multiplenetworks incorporating different inputs to predict the same output.

Only by meticulously following these recommendations will individual investors improve their

potential profits by using neural networks.

Although outside the scope of this research, an important question for any forecasting

model is how does the model stand up in an actual trading scenario? Each of these models

should be historically tested as if being used for actual trading. Given the same initial capital

investment, what is the return for each of these models? What is the maximum drawdown

or capital loss for each of these models? If a model has a high return is it due to many steady

small gains or is it due to one huge gain surrounded by many losses? These issues revolve

around profit and not model accuracy. This raises the question of whether it is important to

design a network and train it to maximize profit vs. forecasting accuracy? These are all

critical questions that take the forecasting model from academic research into the actual world

of trading.

Page 79: THESIS - Advanced Neural Network and Genetic Algorithm Software

65

LIST OF REFERENCES

Beale, R.; Jackson T., Neural Computing: An Introduction, Adam Hilger, Bristol, England,1990.

Dhar, Vasant, Stein, Roger, ed., Intelligent Decision Support Methods: The Science ofKnowledge Work, Prentice Hall Business Publishing, Upper Saddle River, New Jersey, 1996.

Gately, Edward J., Neural Networks for Financial Forecasting, John Wiley & Sons, NewYork, New York, 1996.

Haykin, Simon, Neural Networks: A Comprehensive Foundation, Macmillian CollegePublishing Company, New York, New York, 1994.

Kartalopoulos, Stamatios V., Understanding Neural Networks and Fuzzy Logic: BasicConcepts and Applications, IEEE Press, New York, New York, 1996.

Lederman, Jess, Klein, Robert A., ed., Virtual Trading: How Any Trader With a PC Can Usethe Power of Neural Networks and Expert Systems to Boost Trading Profits, IrwinProfessional Publishing, New York, New York, 1995.

Levine, David M., Berenson, Mark L., Stephan, David, Statistics for Managers UsingMicrosoft Excel, Prentice Hall, Upper Saddle River, New Jersey, 1997.

Lowe, David, “Novel Exploitation of Neural Network Methods in Financial Markets,”Proceedings of the 3rd IEE International Conference on Artificial Neural Networks, IEEPublications, Aston, United Kingdom, 1994.

Smolensky, Paul, Mozer, Michael C., Rumelhart David E., ed., Mathematical Perspectiveson Neural Networks, Lawrence Erlbaum Associates, Mahwah, New Jersey, 1996.

Ward, Steven, Sherald, Marge, “The Neural Network Financial Wizards,” Technical Analysisof Stocks & Commodities, Reprinted, Technical Analysis Inc., Seattle, Washington, 1995.

Page 80: THESIS - Advanced Neural Network and Genetic Algorithm Software

66

Page 81: THESIS - Advanced Neural Network and Genetic Algorithm Software

67

BIBLIOGRAPHY

Braspenning P.J., Thuijsman, F., Weijters, A.J.M.M., ed., Artificial Neural Networks: AnIntroduction to ANN Theory and Practice, Springer, Hiedelberg, Germany, 1991.

Edwards, Robert D., Magee, John, Technical Analysis of Stock Trends, John Magee,Springfield Massachusetts, 1966.

Know, Harvey A., Stock Market Behavior—Technical Approach to Understanding WallStreet, Random House, New York, New York, 1969.

Sarle, W.S., ed., (1998), Neural Network FAQ, periodic posting to the Usenet newsgroupcomp.ai.neural-nets, URL:ftp://ftp.sas.com/pub/neural/FAQ.html

Ward, Steven, Sherald, Marge, ed., NeuroShell 2 Users Manual, Ward Systems Group, Inc.,Frederick, Maryland, 1996.

Page 82: THESIS - Advanced Neural Network and Genetic Algorithm Software

68