Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle Modeling with pattern recognition decision rules by Ted C. Earle M ost of the interest in using mathematical models in finance and economics involves models based on hypothetical causal relationships described by quantitative mathematical functions. When these models work they may reflect substantial understanding of the system being simulated and provide a wealth of information about the internal relationships of the various factors included in the model. Many of these models have mathematical characteristics which allow them to be solved for optimal results. In the areas of finance and economics, however, the quality of data is often so poor and the complexities of the relationships so difficult to express that such models frequently seem to be unreliable oversimplifications of the real world. Another scientific tradition, empirical modeling, should then be considered for wider utilization in the areas of finance and economics. Empirical models may be of value when the more formal theoretical models are deemed inadequate because of high uncertainties or an inability to adequately express the complexities. Empirical models are developed by analyzing experimental data (in the case of finance and economics, historical data). These models provide little insight or understanding of the cause and effect relationships of the process being studied, but they do recognize identifiable events which can then predict other events in the process with various degrees of accuracy. The methodology of theoretical modeling relies on the statistical relevance of quantitative results derived from mathematical functions used to test hypothetical causal relationships. Empirical modeling simply tests the statistical relevance of qualitative correspondence between observed events. To the extent that the model is accurate, an empirical model may be all that is required by its users. A good analogy may be found in the field of instrumentation. When the EKG was first used in monitoring the heart, the recorder would print results on a moving tape which initially looked like nothing more than oscillating pen strokes. The instrument was recording a great deal of information but no we knew how to read and interpret it. Eventually, after studying thousands of cases, analysts learned how to read and interpret the squiggles. Different patterns reflect different types of heart conditions. The results won't always be identified correctly, but generally speaking, the test has proved to be reliable and useful. The useful knowledge about the technique was developed empirically. That is actually how most theoretical modeling begins. To quote Karl Brunner on methodology in economics: "We begin with empirical regularities and go backward to more and more complicated hypotheses and theories." Modeling with pattern recognition decision rules is an application of the empirical modeling methodology. Patterns may be usefully defined as any repetitive events in a time series. Patterns may be seasonal, cyclical or other recurring variations in the data field series. Pattern recognition decision rules utilize the identification of patterns in a set of indicator series to predict the occurrence of patterns in the forecast series. Through research, the decision maker knows that the occurrence of a pattern in the indicator series has foreshadowed the occurrence of a pattern in the forecast series with a known degree of historical correlation. Researchers can identify indicator patterns by analyzing historical time series2,3. Pattern recognition Article Text Copyright (c) Technical Analysis Inc. 1 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle indicators are discovered by observing changes in the data series which have occurred at about the same time as the events which the researcher is trying to predict. The series studies can be anything that the researcher believes to be relevant or useful to identifying the events predicted. By testing the patterns as indicators of events statistically, the researcher can confirm or reject the existence of a useful qualitative correspondence between the indicator patterns and the predicted events. The acceptance criteria are based on the degree of reliability of the indicators. Pattern recognition decision rules contain some common characteristics and some significant differences from another research approach—technical analysis. Technical analysis assumes that there are patterns in market price action which will recur in the future and thus these patterns can be used for predictive purposes. To this extent, technical analysis is a type of empirical modeling. When models work, they may reflect substantial understanding of the system being simulated. But typical technical analysis studies have at least two characteristics which exclude them from the status of modeling. First, most technical analysis rules are not well-defined. Without a clear definition, technical analysis procedures cannot be unambiguously utilized by different people. This is especially true when the medium of analysis used consists of charts instead of numerical systems. Thus, identical technical analysis procedures are subject to different interpretations and applications by different users. Secondly, most adherents of technical analysis tend to test their systems over a very short period of recent history. With so little testing, the statistical validity of the system can rarely be ascertained. Pattern recognition decision rule modeling emphasizes precise definitions and adequate historical testing as well as pattern recognition. Technical analysis has been severely criticized for reasons other than imprecise definitions and inadequate historical testing. Even the weak form of the efficient market hypothesis (EMH) states that past market prices provide no information about the future prices which would allow a short-term trader to earn a return above what could be attained with a naive buy-and-hold strategy4. A data series is considered to be random precisely because it does not exhibit a pattern or structure. Obviously the very concept that patterns do not exist in the data contradicts the foundations of both technical analysis and pattern recognition decision rules when applied to price series (as in the upcoming gold market example). Weak EMH strictures do not apply to pattern recognition decision rules when the indicator series are different and not derived from the series for which the identification of patterns is being tested. For example, a pattern recognition decision rule model which used interest rates as the indicator series for identifying patterns in the stock market would not contradict the weak version of the efficient market hypothesis, but the postulate that short-term patterns exist in the stock market does. Concerning the existence of short-term patterns in financial time series, the key word for the weak EMH theory is short-term. The weak EMH theory does not deny the existence of long-term patterns and trends such as those associated with the business cycle5. This fact is often overlooked in discussions of the efficient market hypothesis. For example, long-term, cyclical trend changes in the Standard & Poor's 500 Stocks Average have been observed to be one of the most reliable leading indicators of the gross national Article Text Copyright (c) Technical Analysis Inc. 2 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle product (GNP). Thus, if the existence of cyclical patterns and trends can be defined in a series, both technical analysis procedures and pattern recognition decision rules can be used to identify them. This article will deal with such long-term patterns. A technical analysis procedure that is developed and tested with charts for only one business cycle has a very weak foundation, but a set of pattern recognition rules tested successfully over 27 business cycles represents a significant empirical finding. This leaves open the question as to what constitutes the short-term and long-term. As a result, the time horizon limits of the short-term conditions in the weak EMH are undefined. Because the duration of business cycles is sufficiently long to be long-term under EMH theory, there is at least the feasibility of developing pattern recognition decisions that identify trends associated with the business cycle. The very nature of empirical modeling results in certain advantages and disadvantages. If a pattern recognition decision rule simply works consistently, it can be extremely useful, particularly if it either out-performs existing theoretical models, or no theoretical model exists. Empirical models are not subjective; they can be explicitly duplicated and tested by someone else. When tested on the same historical time series data, they will always yield identical results. If the model is tested over a sufficiently long period of time to give statistically significant results, it should acquire a certain degree of confidence from its users. The same testing standards can be applied to more theoretical models for a direct comparison of the reliability of the models. It is even possible to formulate some hypothetical relationships as pattern recognition decision rules for testing, so that if the test is rejected the relationship can be disproved. If the pattern recognition formula of the hypothetical relationship is accepted, it will not prove the existence of the relationship, but will lend more support to that theory. Similarly, if a set of pattern recognition decision rules indicate a strategically significant qualitative correspondence between two series, it may suggest the possibility of a causal relationship. Pattern recognition models, however, will not provide anything more than the most superficial understanding of the system being modeled. While it is feasible to find an "acceptable" model with decision rules, it is nearly impossible to find an optimum solution or to know if an optimum solution has been accidentally discovered. The non-functional nature of decision rule models also provides few clues as to how to improve the performance of the model. Because the decision rule models and their results contain so little insight into the process being modeled, there is little guidance as to how to proceed to improve the model. Typically, improvements are the result of trial and error adjustments rather than systematic, incremental changes. Thus, the inefficiencies inherent in altering and retesting can potentially incur large costs without developing an acceptable model. Finally, as with all models in finance and economics, past success is no guarantee of future success. With these factors in mind, the researcher can decide whether or not embarking on the development of a pattern recognition decision model is one of value. Before outlining the procedures of decision rule modeling and presenting a practical example, look at some potential applications. In economics, identification of a consistent pattern of changes in the leading and lagging economic indicators could be used to provide a decision rule definition of the peaks and troughs in the business cycle which might be both more timely and consistent than the proclamations of a committee. A decision rule model might be well suited to the monetary analyst in assessing the weekly Article Text Copyright (c) Technical Analysis Inc. 3 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle Condition Statement of the Federal Reserve Banks and other data in determining whether the Fed has really "loosened" or "tightened" its policies concerning the rate of expansion of money and credit. The industry or company analyst could examine the relevance of changes in the industry statistics or in the balance sheets and income statements of companies in the industry to the price of shares of those companies. Similarly, the usefulness of trading rules of the "technical" analyst can be tested for relevance. Finally, a strong case can be made for developing and using your own decision rules for investment purposes for two reasons. First, when you develop rules yourself, you will have more confidence in them and will be more likely to use them than you would be inclined to act on someone else's advice. Secondly, when an advisor is so well publicized that too many people are acting on his advice, the system can become ineffective due to its own success. The trade-off here is that developing decision rules, even with computers, is hard work and very time consuming. In this article, a demonstration study of a set of decision rules for trading the gold market will be provided. In conducting a pattern recognition research study, there are six phases which are generally common to all types of mathematical modeling: 1. formulating the problem 2. collecting or mathematically creating the data series to be used in identifying and indicating the patterns to be studied 3. developing decision rules which will identify the initiation of patterns from the indicator series 4. testing the decision rules and evaluating the predictive results in the forecast series 5. establishing control over the use of the decision rule, and 6. proceeding to implement the actual use of the decision rules. Each of these phases generally consist of several steps which are subject to frequent re-evaluation and re-working as a study progresses. Formulation of the problem The first phase consists of defining the subject of the study and how it is to be conducted. In the example study, the objective was to find an "acceptable" set of decision rules for trading gold. Acceptable decision rules are defined as participating in as many long and short trading opportunities as possible with a profit potential in excess of that which could be earned while investing in the money market over the same period. These rules should make profits in more than one-half of the trades so that the overall return would significantly exceed the return available by simply investing in the money market. The test period chosen was 1861 through 1985, a period of 125 years. In order to attain this objective, the study will analyze the smoothed difference between a fast and a slow smoothed series of the price of gold itself. Smoothed series can be obtained in a number of ways, such as moving averages, moving least square linear fitting, and exponential smoothing. A fast smoothed series gives more weight to recent prices, while a slow series places more weight on older prices (for instance, a 5-period moving average is faster than a 40-period moving average). In the demonstration study presented in this article, the fast series is a single exponentially smoothed series (column 3) with a factor of 0.142857 (approximately a 13-week moving average), and the slow series is a single exponentially smoothed series (column 4) with a factor of 0.074074 (26-week moving average). Article Text Copyright (c) Technical Analysis Inc. 4 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle "Empirical modeling simply tests the statistical relevance of qualitative correspondence between observed events. " Data collection The second phase involves actually collecting the gold prices and generating the indicator series on worksheets for analysis. After obtaining a set of gold prices, a computer program was written to generate the indicator series (single exponentially smoothed gold prices) and arrange them alongside the raw gold prices for analysis. The results are shown in Table A. For each year there are seven columns of information. The first column gives the year and the week number. The second column gives the closing price of gold for that week. The third column gives the fast smoothed gold price derived from column 2. The fourth column gives the slow smoothed gold price also derived from column 2. Column 5 is the difference obtained by subtracting column 4 from column 3. Column 6 is the fast smoothed series of the data collected in column 5. Column 7 is the one-week momentum (decimal fraction or ratio of the current period's value divided by the previous period's value) of column 6. Column 8 contains the ratio of column 5 divided by column 4, providing a measure of volatility. Columns 7 and 8 are the series to be tested. This table can either be created by the computer and printed out for visual study, or developed in the computer and held in memory for computerized analysis. Decision rules The third phase involves developing a set of decision rules for the indicator series to be tested for their effectiveness in identifying patterns in the gold price series. The decision rules are displayed in Figure 1. Testing and evaluation In the fourth phase, the indicator and gold series are screened through the decision rules. There are several ways in which testing of the rules can be implemented. The rules can be tested incrementally over several time periods (say ten year intervals or business cycles). They can be tested first over Friday quotations and then retested against quotations for other days of the week. Procedural refinements of this type can be used to reduce the possibility of overfitting the model so that it will not be whipsawed by noise in real-time applications6. The results of the fourth phase are shown in Tables B and C. Table B details the essential characteristics of each trade. Column 1 enumerates each trade chronologically. Column 2 indicates the entry and exit date for each trade. The first item (104, 1861) is January 4, 1861. Column 3 indicates the three kinds of transactions included in the study. Out-of-market transactions were periods where liquid funds were invested in high-quality commercial paper. Column 4 indicates the duration of each transaction in weeks. Column 5 indicates the price of gold on the entry and exit date of each transaction. Performance of other transactions is recorded in columns 6 and 7. The profit or loss of a transaction in the gold market is given as the market return, while the yield of commercial paper over the same period is indicated as COM PAP. Finally, columns 8 and 9 indicate date, number of weeks from entry and magnitude of the maximum temporary loss which one would have had to endure for each transaction. Table C is a trading performance summary of Table B. The rules developed for gold bullion for the period from 1861 through 1985 resulted in a total of 55 transactions over the 125 years. One-half (27) of Article Text Copyright (c) Technical Analysis Inc. 5 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle the trades were out-of-market trades valued by investing in high grade commercial paper as an alternative to gold. The other 28 transactions consisted of 18 long and 10 short trades in gold. Out-of-market periods predominate because of the long periods with little change in the price of gold from 1879 through 1933 and from 1935 through 1967. As a result, the out-of-market periods account for 86 percent of the 125-year period studied. Investing in commercial paper over these out-of-market time periods results in an average interest income of 4.4 percent per year. In contrast, of the 10 short sale transactions, six were profitable resulting in an average annualized performance of 11.3 percent per year over a total investment period of seven years or 357 weeks. The long trades were more reliable than the short trades (14 of 18 or 78 percent profitable trades), and the overall performance is significantly better (35.1 percent per year for a total investment period of 11 years or 572 weeks). The combined return of long and short trading was 25.4 percent per year over 18 years or 929 weeks in the market with 71 percent of the trades (20 out of 28) making a profit. The remainder of Table C provides some perspective as to the quality of the rules as compared to the potential of not trading gold. The overall performance of the trading rules over the entire study period was 7.2 percent per year. If you had simply bought gold in 1861 and still held it today, your performance would have been 2.2 percent per year. If you had never bought gold and always invested in the money market, your return would have been 4.9 percent per year. During the 18 years of long and short trades, the return for investing in the money market was 7.7 percent per year. Although there is an increase in risk with some losing trades, overall, trading gold with these rules increased the total return from 4.9 percent per year in commercial paper to 7.2 percent per year, while simply buying and holding gold would have only returned 2.2 percent per year. Furthermore, during the 18 years when gold was being traded, the combined return was 25.4 percent per year as opposed to a commercial paper return of only 7.7 percent over the same periods. When the price of gold has not been fixed, trading gold with these rules has far surpassed the returns expected from commercial paper. Table D provides information to assess the quality of the trading rules as compared to the potential of perfect cycle timing. In total, there have been six rising phases (we have begun the seventh) of gold market cycles and five declining phases totaling 1,896 weeks or just over 36 years. Perfect timing would have yielded a 9.3 percent per year return on short trades, and 50.7 percent per year on long trades for a combined performance of 24.8 percent per year over 1886 weeks or 36 years. Combined with out-of-market periods, the total return with perfect cyclical timing would have been 9.5 percent per year, nearly double the return of only investing in the money market. In contrast, trading rules had a total performance of 7.2 percent per year. During the active trading periods, the rules earned 25.4 percent per year as opposed to 24.8 percent per year with perfect cyclical timing, but the trading rules w ere only invested for 929 weeks while perfect: cyclical timing would have earned a comparable return over 1,886 weeks. Developed from a set of decision rules (Figure 1), the performance can be evaluated. As a result of reviewing the performance, alteration in the formulation (phase 1), the indicator series (phase 2) or the decision rules (phase 3) may be considered. Repeating phases 1 through 4 is the essence of a decision rule research study. The amount of time spent on repeating these steps to explore for an acceptable or an improved set of decision rules must always be monitored by the researcher. The research study will usually be terminated by considerations of cost versus expected value. There are an infinite number of relationships from which to choose in using this approach. Selecting the relationships to be tested, and the ability to modify the tests (after reviewing the preliminary results), Article Text Copyright (c) Technical Analysis Inc. 6 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle determines how efficiently the study effort is conducted. Experience in utilizing the empirical approach, familiarity with the market to be studied and the ability to spot unexpected quirks in the data greatly help in conducting a study. The indicator pattern for which we are searching is defined by the decision rules. The decision rules obtained (Figure 1) were the best results found after performing several tests, but they are by no means the best possible results or the end result of testing all possible relationships. The rules in Figure 1 were simply considered to be suitable for demonstrating this method. The standards of historical performance suitable for accepting or rejecting the use of a set of decision rules will vary greatly according to the objectives of the study. Decision rule controls Phase 5 involves establishing controls over the use of the rules. These are necessary because no matter how well the rules work on the historical data, they will not always work in the future. Thus, guidelines must be established as to what to do when the rules don't work. For instance, in the case of the gold trading rules, guidelines might be established for protective sales whenever a five percent loss is exceeded. Similarly, if there were two consecutive losing trades, use of the rules might be suspended until the rules were revised to successfully work with both the original data and the new data. Finally, phase 6 involves putting the rules to work. Conclusions A major pitfall of financial and economic model building can be failure to test the model with data. While an historically successful model has no guarantee of working in the future, any model which does not work historically (when based on the same information and assumptions) is certainly a questionable model for use in the future. Similarly, if a theoretically based model cannot pass muster on historical data, then something is wrong with the theory or the expression of the underlying assumptions. These pitfalls can be sidestepped by supplementing research with historical testing procedures. By utilizing statistical standards for validation, empirical models which meet or exceed the same standards as the theoretically based models can be developed. Pattern recognition decision rules and other empirical modeling approaches can be used effectively for financial and economic applications. References 1 Arjo Klamer, Conversations with Economists (New Jersey: Rowman & Allenheld Publishers, 1984), p. 195. 2 Ted C. Earle, "A Historical Review of Business, Credit and Stock Market Cycles," Cycles, August 1981, pp. 155-166. 3 Anthony F. Herbst and Craig W. Slinkman, "Political-Economic Cycles in the U.S. Stock Market," Financial Analysis Journal, March-April 1984, pp. 38-44. 4 Jack Clark Francis, Investments: Analysis and Management (New York: McGraw-Hill Book Company, 1972), p. 368. 5 Ibid., p. 369. 6 David R. Aronson, "Artificial Intelligence/Pattern Recognition Applied to Forecasting Financial Market References Copyright (c) Technical Analysis Inc. 7 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle Trends," Market Technicians Association Journal, May 1985, pp. 91-131. FIGURE 1A: Figures Copyright (c) Technical Analysis Inc. 8 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle FIGURE 1B: Tables Copyright (c) Technical Analysis Inc. 9 Stocks & Commodities V. 4:3 (111-119): Modeling with pattern recognition decision rules by Ted C. Earle Tables Copyright (c) Technical Analysis Inc. 10