home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1
/
HamRadio.cdr
/
tech
/
gaf
/
gaf.doc
< prev
Wrap
Text File
|
1987-11-24
|
7KB
|
131 lines
A Program for Generalized Adaptive Filtering
C Copyright 1984, American Association of Individual Investors
Several months ago, a reader asked if we could provide a program
listing for, "generalized adaptive filtering (GAF)." (What in the
world, you may ask, is, GAF?... Well read on.) It took us awhile to
find a reference that had enough information from which to
develop a sample program listing, and in the meantime I've
misplaced the letter. But, for that reader, and, hopefully, for
many others, here's the program.
Students of securities markets would like to be able to make
predictions about future market prices, and there are numerous
techniques, statistical and otherwise, for doing just that. GAF
is one such technique; it's based on a method of optimization
borrowed from control theory, which, in turn, is a branch of
electrical engineering. The optimization employs what is called a
"steepest descent algorithm" in order to generate an equation that
makes a prediction of what future prices, or, for that matter, any
future event which can be expressed as a numerical quantity.
Using GAF we could just as well, for example, forecast interest
rates or the expected inflation rate.
GAF is one of a class of forecasting techniques that fall into a
category called time-series analysis. Times-series forecasts
use data from past observations of the time-series under
consideration to make a forecast of future values of the
time-series. Interest rates, stock market prices and the money
supply are all candidates for forecasting by time-series methods.
Moving averages and exponential smoothing are techniques often
used by securities market technical analysts. Under many
circumstances GAF should, in theory, provide a better forecast.
In order to understand how GAF works, lets look at how a
statistician or economist would view the problem of making a
forecast. First, take the case of a set of numbers:
1,2,3,4,5,6,7,..? Based on past evidence, what is the next number
likely to be? (Eight, you say. Good, you've passed the course.)
If we have a completely determinate set of numbers, then we could
forecast the next number. If our forecasting program is any good,
it would also have come up with the number "eight." However, in
the real world of investments, and other economic events, such as
future interest rates, there's no necessity that the next number
has to be "eight."
If a series of numbers, or economic events, was completely
random, then we would like to make a forecast that was closest to
the actual number that occurs when the event actually happens. In
the case of a completely random set of events, or numbers, it
turns out that the "best" forecast, the one that minimizes error,
is the value of the last known data point in the time-series.
Economists and statisticians are in general agreement that there
is a high degree of randomness in economic data. So researchers
develop methods that will make forecasts that are as accurate as
possible after taking into consideration the randomness of the
data. GAF is one such method; as we previously stated it uses
only the time series of the past data to make a prediction. The
method searches for a forecasting equation by making a trial
forecast equation from past data, measuring the error, then
making a new trial forecast. This process proceeds until it is no
longer possible to significantly reduce the error remaining after
the forecast is compared with the actual data. The resulting
forecasting equation is then used to make prediction of future
values. For the investor, forecasts are most likely to be made
for market prices.
GAF represents a relatively recent development in the forecasters
toolkit. Since the computer does the searching for the forecast
equation by successive approximation, there is no necessity to
impose an explicit functional form, such as with exponential
smoothing. The general form of the forecasting equation is:
X(t) = a(t-1)X(t-1) + a(t-2)X(t-2) +....+ a(t-n)X(t-n)
Given the general form, a GAF equation can have several lagged
time periods and coefficients in the forecasting equation.
Although, in practice usually one or two periods are specified.
In some cases the program may not converge, i.e., settle down to
an equation with minimum error. If this is the case, you might try
taking the first differences of the original data and then using
the last value of the time series plus the difference forecast by
the program for a forecast one period ahead.
(GAF falls into a category of time series processes called
auto-regression, which means that the time series is regressed
(fitted) onto itself. The number of lagged periods being used is
called the "order" of the process. The determination of the order
of the process is called "model identification." Model
identification is too complex a subject to be covered here. For a
detailed discussion of model identification, as well as a detailed
discussion of GAF, the reader is referred to: Forecasting Methods
and Applications by Makridakis and Wheelwright, published by John
Wiley, 1978.)
The program is written in a subset of Microsoft BASIC, and should
run on a wide variety of computers with little or no
modification. When you first run the program, you are asked to
input your data, which may have up to 150 observations. Type in
"X" if you wish to re-enter a data point and "F" when you are
finished entering your data. (As written, the program will not
work with lower case letters.) Next, you are asked for the number
of parameters, which is the order of the time series or number of
lagged data values to include in the estimation process. As
written, the program makes a forecast for six time periods ahead.
The forecast period can be changed by changing the value assigned
to "M" in statement 610 of the program.
Although it may seem so, there is no magic in the forecasts
generated by this program. If the data are highly random, as is
likely to be the case with securities market data, the forecast
value and the actual outcome will most likely be considerably
different. (However, the forecast should, in theory, be better
than with many other techniques.) Also, the accuracy of the
forecast can be expected to deteriorate rapidly as the number of
time periods being forecast increases.
A good method of testing the forecasts generated by this program
is to initially use fewer than the total number of data points
that you have collected to generate a forecast. Then make a
comparison of the actual data and the forecasts. In this way the
accuracy of the forecast can be measured and compared with
forecasts generated by alternative methods.
As the program runs, it will go through cycles of successive
approximations (iterations). The number of cycles has been set to
100, although this can be changed. At present, the program is
really "barebones." We would like to hear about any additions
that our readers make to the program.