57.91 23.67 9.671982 27 250 6.05 36.60 15.13 6.25
zy =x Ex? hey zy?= sums 43.38 106.46 512.95 202.35 82.27
 
egy testing software. Nevertheless, it is difficult to use the results of these programs unlessyou can interpret the answer. Spreadsheet programs simply require that you indicate thetwo columns that represent the independent and dependent variables. If you simply wantto have time as the independent variable, you can create a column of sequential numbers:1, 2, 3, and so forth. The spreadsheet program will give you a table of statistics includingthe slope, y-intercept, and correlation coefficient (discussed in the next section), and alevel of confidence. Look for a Regression Dialog Box in your spreadsheet program and fol-low the instructions. It is often found under Tools| Numeric Tools |Regression.
Programming Tools
More specific tools are available in strategy testing software, although all of it is restrictedto linear regression. You should expect to find functions that will find the following:
TABLE 3-3 Least-Squares Relationship for Corn and Soybeans: 1956-1982
Soybeans ~ x 4.00 2.00 3.00 4.00 5.00 6.00 7.00Corn y 61 95 1.29 1.63 197 231 2.65
  
“42 REGRESSION ANALYSIS.FIGURE 3-3 Scatter diagram of corn, soybean pairs with linear regression solution.3.00
2.00
1.00
Corn price ($/bushel)
      
1.00) 2.00 3.00 4.00 5.00 6.00 7.00)‘Soybean price ($/bushel)LEE
Linear regression slope—returns the slope of the straight line given the data series (€.g.,the closing prices) and the period over which the line will be drawn (¢.g., 20 days).
Linear regression angle—the same as the slope function but the answer is expressed ~
in degrees.
Linear regression value—calculates the slope of the regression line then projects that .
line into the future, returning the value of the future point. This requires the user tospecify the data series, the period over which the line will be calculated, and the num-ber of periods into the future. Projecting the value can also be done by finding theslope, s, and performing the following calculation:
Projected price = starting price + s x (calculation period + projection period)where the starting price is at the beginning of the calculation period.
LINEAR CORRELATION _
Solving the least-squares equation for the best fit does not mean that the answer can beused. There is always a solution to the least squares method, but there might not be a validlinear relationship between the two sets of data. You may think that two data items affectone another, such as the amount of disposable income and the purchase of television sets,but that might not be the case. The linear correlation, which uses a value called the coef-{ficient of determination r?, or the correlation coefficient, expresses the relationship of the‘data on a scale from +1 (perfect positive correlation), to 0 (no relationship between thedata), to -1 (perfect negative correlation), as shown in Figure 3-4.
‘The correlation coefficient is derived from the deviation, or variation, in the data. It isbased on the relationship -
Total deviation = explained deviation + unexplained deviation
where total deviation is ¥, (9:3), the sum of the individual differences from the average;explained deviation is ©, (3, - 9), the sum of the differences between the points
on the fitted line and the average;unexplained deviation is ¥. (y,—), the sum of the remaining forecast error terms.
Changing this into a ratio gives_unexplained deviation _ | _ Lor”total deviation Lou- Hy?
2
 
ral
 
LINEAR CORRELATION4a
LLFIGURE 3-4 Degrees of correlation. (a) Perfect positi
c . positive linear correlation (r? = 1). (b) Some-what positive linear correlation (r? = .5) = re eensTe paste linea corral (r? = .5). (©) and (d) No correlation (r? = 0). (e) Perfect negative
 
 
Price series 2Price series 2
  
Price series 1 Price series 1a (o)
Price series 2Price series 2
 
 
Price series 1@)
 
 
Price series 1e)OO
The value r? can also be determined usi a iiing the following fom using sums already calculated in Table 3-2, by apply-
NS xy- Dx Ly
peels ET].
This is easy to calculate; it requires onh i iti ilate; ly one sum in addition to the soluti -squares problem. The results r? are interpreted as follows: olution of the least
 
 
re=t1 A perfect positive linear correlation. The d: igtA ‘ . lata points are along a straightline going upward to the right (Figure 3-42). 8 en
2 i t
+1>r?>0 The scattered points become more uniformly distributed about a positiveapproximation line as the value of r? becomes closer to +1 (Figure 3-4b).
oO No linear correlation exists (Figures 3-4c, 3-4d).
-1<r?<0 The scattered points become more uniformly distributed about a negative
. approximation line as the value of r? becomes closer to -1.
r?=-1 A perfect negative linear correlation, the line going down’ ij
Chae sae going ward to the right
 
r44
 
REGRESSION ANALYSISApplying the formuld to the corn-soybean data and using the sums from Table 3-2 gives2 [27(202.35) — (106.46) (43.38)]* . 'r= 127(612.95) — (106.46)"][27(82.27) — (43-38)"](5463.45 — 4618.23)= "(73849.65 - 11333.73) (2221.29 — 1881.82)
714396.84~ (2515.92)(339.47)_ £ soybi d corn. Thetrong relationship between the prices of soybeans and corn. Thvalue of say saobe considered as having accounted for 83.6% of the price relationship
between the two products.
 
Computer Programs to Find Correlations
ession, both spreadsheets and trading strategy software have func-
a an ine cone calculations on your part. Spreadsheets
i i fficient with notions to return the correlation coe! th no 1 ‘include the correlation as part of the statistics given when the regression tool is used. If ,only the correlation is needed, for example, to create a correlation matrix, then you canuse the function @correl(coll,col2), which calculates only the correlation coefficient for
the two series in columns 1 and 2. | , |i. The same facility exists in trading strategy software, in which you can use a function
that specifies the independent series, dependent series, and the time period over whichthe regression will be calculated. For example, you might specify , R2,two series, datal and data2, over the past 45 days as:
R2 = @correlation(close of datal, close of date2, 45)
Correlation Adjustments When Using a Time Series
Because most price analyses involve the use of two time series, precautions should 1 beid a dominant trend that can distort the results. A long-term upwar
ward wend wil gnershadow the smaller movements around the trend and exaggerate the
correlation. The following methods may be used to correct the problem:
iti De be correlated.1. The deviations from the trend (J;—y,) may2. The first differences ((J:—Js-), (9-1-1) May be correlated.3. The two series may be adjusted for trend.i ich is alsc fective. You should expect any com-implest method is number 2, which is also very e any com-eat Roftware to detrend the data before calculating the correlation coefficient; how-ever, it is always a good habit to check it. -
Forecasting Using Regression -
A distinct advantage of regression analysis is ‘hat t allows the a ‘o forecast pricecase of the linear regression, the forecas' simy :
elias rater 2 this book, there will be other nonlinear solutions that are used to predict
ns.more aera forecast is the basis for the probabilistic model. Instead of the corn-
soybean relationship, regress the price of soybeans against time using the linear leastsquares method on the data in Table 3-2. The result is
y= 987 + .221x
NONLINEAR APPROXIMATIONS FOR TWO VARIABLES 45
where y is the price of soybeans for the year x. Because the solution substituted the valueOf 1 for 1956 and 27 for 1982, the average farm income per bushel of soybeans is forecastas 7.32 in 1985 (x = 30) and 8.38 in 1990 (x = 35).
Confidence Bands
Regression analysis includes its own measure of accuracy called confidence bands. It isbased on a probability distribution of the errors in the fitted equation and the size of thedata sample. Looking at Figure 3-3, the straight line cannot touch all the points, but itsS00dness of fit may be measured by using the standard deviation of the errors to deter.mine the variance over the total number of data points N. If the actual data points are y,and their corresponding value on the fitted line f, then
= W- IiReferring to the table of normal distribution (Appendix 1), the 95% level is equivalent to1.96 standard deviations. Then, a confidence band of 95%, placed around the forecast line,is written
95% upper band = y; + 1.960
95% lower band = y,— 1.960
Figure 3-5a shows the soybean forecast with a 95% confidence band. The points that areoutside the band are of particular interest and can be interpreted in either of two ways.
1, They are not representative of normal price behavior and are expected to correctthe levels within the bands.
2. The model was not performed on representative or adequate data and should bereestimated.
Figure 3-5b also indicates that the forecast loses accuracy as it is further projected; theforecast is based on the size of the sample used to find the regression coefficients. The moredata included in the original solution, the longer the forecast will maintain its accuracy.
NONLINEAR APPROXIMATIONS FOR TWO VARIABLES.
Data points that cannot be related linearly may be approximated using a curve. The gen-eral polynomial form that approximates any curve is
VA Ay+ Axe + a,x? + +a,x"
The first two terms on the right side of the equal sign form the first-order equation for astraight line. By adding the next term a,x”, the shape of the resulting line changes to a par-abolic curve, one with a single, smooth change of direction. The third teem 3x? adds aninflection to the pattern. For most price forecasting, the second-order equation, also calledcurvilinear, is sufficient (Figure 3-6). The corn and soybean prices from Table 3-1 will beused to give examples of this and other nonlinear approximations.
The curvilinear form
Y=at bur ox
must be solved for the coefficients a, &, and c using the simultaneous equations 
6 REGRESSION ANALYSIS
 
LLFIGURE 3-5 Confidence bands. (a) Soybeans with 95% confidence band. (b) Out-of-sampleforecasts lose confidence. '
“Outliers” ©
 
 
Na+b> xte> => y .
ad xtb > tte =>d °
a> 2th > ete S xt=> xy‘The calculations from Table 3-2, including the additional sums for x>, x‘, and x?y, can besubstituted into the preceding equations. The system of simultaneous linear equations canbe solved by the process of matrix elimination,” a technique that should not be performedwithout the help of a computer. An alternate solution can be obtained by continuing withthe already familiar least-squares method.
SECOND-ORDER LEAST SQUARES ~ _
The concepts of least squares can be extended to the curvilinear (second-order) equationby minimizing the sum of the errors?
xS=>) Qi- a bx, - cx}?
? See Appendix 3 for examples of matrix solutions.> ER. Ruckdeschel, BASIC Scientific Subroutines, Vol. 1. (Byte/McGraw-Hill, Peterborough, NH, 1981).
 
SECOND-ORDER LEAST SQUARES47
 
FIGURE 3-6 Curvilinear (parabolas).
Curvilinear (Second Order)(@. 6, x>0) (x>0)y
 
 
 
 
 
Yaar bxs ox? yo
 
First, it is n to separa interm ition for a, Bando. sade se] ite the various intermediate sums before expressing the solu-
 
 
S25 enw -Sy 5S C-B-F) -SES OW7 we S GRO *) .Seo ZS @i-=yKE O-DEIR-®)
The constant values can then be found by substitution into the following equations
SxySz2x2 — Syx2S ext
© SexSse = Soe)?
c= SzxSyx? — Sux?Sxy
SuxS2xt ~ Sex?)*a=F-b3-
The procedure is identical to the linear least-squares solution. Fortunately, there are simple
computer programs that have already been written to solve these singn problems. Using a methsimilar to the program found in Appendix 2, the result is ee
y= .310 + 323% + .002x7 
48 REGRESSION ANALYSIS
Table 3-4 shows the relationship using selected values of x. Notice that this relationship isessentially linear due to the small second-order coefficient. It is not necessary to solve boththe linear and curvilinear models, because the second-order equation can be used in thelinear form when this situation occurs.
Transforming Nonlinear to Linear
‘Two curves that are often used to forecast prices are logarithmic (power) and exponentialrelationships (sce Figure 3-7). The exponential, curving up, is used to scale price data thatbecome more volatile at higher levels. Each of these forms can be solved with unique equa-tions; however, both can be easily transformed into linear relationships and solved usingthe method of least squares. This will allow you to fool the computer into solving a non-linear problem using a linear regression tool.
   
LogarithmicGeneral form y=orTransformed Iny=Ina+binxLinear form yoo+ bx
rey=Inya=Ina
where y= Iny
 
‘The significant difference in the transformations is that the value of x is not scaled for theexponential. Taking the original data and performing the appropriate natural log func-tions, In results in the linear form that can be solved using least squares. Selected resultsfrom the computer program in Appendix 2 are shown in Table 3-5.
EVALUATION OF 2-VARIABLE TECHNIQUES
Of the three curve-fitting techniques, the curvilinear and exponential results are very similar,both curving upward and passing through the main cluster of data points at about the sameincline. The log approximation curves downward after passing through the main group ofdata points at about the same place as the other approximations. To evaluate objectivelywhether any of the nonlinear methods are a better fit than the linear approximation, find thestandard deviation of the errors, which gives a statistical measurement of how close the fit-ted line comes to the original data points. The results show that the curvilinear is best; thelogarithmic, which curves downward, is noticeably the worst (see Figure 3-8).
In the case of the corn-soybean relationship, the model with the smallest variancemakes the most sense. Prices will usually remain within the range tested, and the realities ofthe production-price relationship support the selection of the linear (or curvilinear) values.
The use of regression analysis for forecasting the price of soybeans alone has a differ-ent conclusion. Although 27 years were used, the last 10 showed a noticeable increase insoybearr prices. This rising pattern is best fit by the curvilinear and exponential models.However, forecasts using these formulas show pricés continuing to rise at an increasingrate. Had inflation maintained its double-digit rate, these forecasts would still lead to unre-alistically high prices. The logarithmic model, which leveled off after the rise, turned out to
———$— ns
TABLE 3-4 Curvilinear Values for Corn and Soybeans =
‘Soybeans x 1.00 2.00 3.00 4.00 5.00 6.00 7.00Corn y 63 96 1.29 1.63 1,97 231 2.66nn
 
EVALUATION OF TWO-VARIABLE TECHNIQUES, 49
FIGURE 3-7 Logarithmic and exponential.
Logarithmic (Power)(@, b, x, all > 0) (a, x>0, b<O)y
 
-1<b<04
    
‘'t''
 
 
 
x ° 1 xy= axPoriny=Ina+binx(a) ®Exponential(b> 0)y y (b<0)
 
    
?''''
 
 
 
 
 
0 1b x o 1b xy= act orin y= in a+ bx© (a)aSSource: Cuthbert Daniel and Fred S, Wood, Fittin i is tifacte . |, Fitting Equotions to Data: Computer Analysis of Multifactor Data,ed. (New York: John Wiley & Sons, 1980, pp. 20, 21). Reprinted with permission. ee of "Pete, 2nd
be the best for the actual situation. This shows th:the a uation. at the problem of forecasting is morecomplex than this naive solution. The logarithmic model, which showed the worst statistical results, provided the best forecast. Major factors that cause significant price shifts, suchas interest rates, inflation, and the value of the U.S. dollar, must be monitored carefullye model must be reestimated whenever these factors change. The section “MultivariateApproximations” will discuss this in more detail. anes eon _ ue
Direct Relationships‘The price at which a market trades is limited by the cos' i
: t of production and dependentupon the prices of other markets that provide a substitute product. Arbitrage is based on
TABLE 3-5 Log and Exponential Values for Corn and Soybeans
 
Soybeans x 1.00 2.00 3.00 4.00
z r ; ’ 5.00 6.00 7.00Corn (log) y A 94 130 1.64 1.96 2.26 2.56(exp) y 84 1.02 124 1.50 1.83 222 2.70 
“50 REGRESSION ANALYSIS
FIGURE 3-8 Least-squares approximation for soybeans using linear, curvilinear, logarithmic,and exponential models. ‘
14.00
12.00
7 ExponentiatCunvilinear
Soybean prices ($/bushel)
      
1956-1960 «1965.~=«1970.s«1975 = 198019851990Years 1956-1990
 
ili titute one product for another after transaction costs, which can includeae en enorees chipping. inspection, and commissions. These relationships are carefullymonitored and arbitrage opportunities are quickly acted upon by waders. This processkeeps futures and cash prices together and prevents the price of gold in New York, Lon-don, and Hong Kong from drifting apart any further than the cost of buying gold in onelocation and delivering it to another. For interest rate markets, strips prevent the largepool of 3-month vehicles, notes, and bonds from offering widely different returns for thesame maturity. The Interbank market provides the same stability for foreign exchange mar-kets, while in agriculture the soybean crush and other processing margins do not stay out-offline for long, The following nonfinancial markets have close relationships that can befound using regression analysis.
_————Products Related Reason
 
Relative income for farmers
Grain ° Protein substitution for feedLivestock to feedgrains Feed, cost of productionLivestock Food substitutionSugar and corn ‘Sweetener substitution .Hogs and pork bellies _ Product dependency | :
i Investor's inflationTee ee aed fctls The stock market and foreign exchange are strongly influenced by changes
in interest rates.
 
MULTIVARIATE APPROXIMATIONS St
MULTIVARIATE APPROXIMATIONS
Regression analysis is most often used in complex economic models to find the combina-tion of two or more independent variables that best explain or forecast prices. A simpleapplication of annual production and distribution of soybeans will determine whetherthese factors are significant in determination of soybean prices. Because the demand forsoybeans and its products is complex, a high correlation should not be expected between
the data. However, there is no way of knowing how much impact other factors have on theprices over a long term.
Using the method of least squares, which was employed for a simple linear regression,the new equation isYHat bx, + cx,where ¥» is the resulting price%, is the total production (supply)2 is the total distribution (demand)@, b, and c are constants to be calculated
As in the linear approximation, the solution to this problem will be found by minimiz-ing the sum of the squares of the errors at each point
S=> (1-50?
mt
Substituting j from the previous equation,S=> (i- @+ bx, + x2)?= .
The solution to the multivariate problem of two independent variables x, and xrequires the following three least-squares equations:
antb>Sm +¢5m =SyaS mtb xt +eDmm= DixyaS mtb SamteS x} =S xy
The procedure for solving the three simultaneous equations is the same as the curvi-
linear method of coefficient elimination. The sums are calculated in Table 3-6, then substi-tuted into the last three equations:
12.00a@ + 13.546b + 12.582c = 44.413.554 + 15.980b + 14.75c = 53.2812.584 + 14.756 + 13.86c = 49.264The coefficient matrix solution is‘ -
 
13.55 15.98 14.74 53.2812.58 14.74 13.86 49.26,
(: 1.239 1.048 28)
(33 13.55 12.58 5%)
O- 6798 5451 3.1450 .5451 6720 2.714
* Matrix elimination is the necessary solution to the multivariate problem. Appendix 3 contains the computer pro-‘grams necessary to perform this operation. 
"52 2
REGRESSION ANALYSIS
~ - " ——TABLE 3-6 Totals for Multivariate Solution
 
 
 
 
SoybeansSupply Demandx x xt 4 XX xy xyy (Billions) (Billions) (Millions)8 ATA 1.869 1.808267 700 $77 490 AS1965 a 2.88 B45 738 74 545 624 2434 2 i 251966 3 2.98 928 839 861 08 7 27652500293 978 874 953 J 4308 3 2.69 1.107 900 1,225 a 1 9 8 2978 242i6 2.63 1.133 946 1.284 4 x . 488i970 7 2.63 1.127 1.230 1.270 1513 1.386 2364 3 2351971 8 3.08 1176-1258 1383 1.583 1.479 nen 38751972 9 3.24 1.271 1.202 161s 1445 1,528 418 39941973 to 6.22 1.547 1.283 2.393 1.646 1.985 902 7.9801974 IL 6.12 1215 1.435 1476 2.059 L744 7436 a7e21975 126.33 1521 1.200 2.313 1.440 4 .
 
=z 4440 13.546 12.582 15.977 13.862 14.745 53.276 49.265ee
O 1 8018 4.62640 0 .2349 1922,
- {1 0 0 -1.6410 1 0 3.9703Oo ol -8183.
The results show @ = —1.641, b = 3.9703, and c = .8183, so that the multiple linearapproximation of the price is
p= 8183. x
p= 1.641 + 3.970321 + a —where x, is the production in billions of bushels and x, demand in ions of bushels. Thecoefficient of supply is the principal factor in the determination of price. Had ei ther coe:
i indicated a lack of significance.ficient of x; or x, been small, it would have in: c if 4 ectionini i ents is not obvious and may re:of which data to try when determining price compon may result inexam -and-demand figures were chosena useless answer. In the iple, supply-ane i s hosen f0 determinei ly and inflation or demand and inflation wou!Soted our sihich sets nf lata are best, each combination would have to be tested and thed. =, . 5,ren Comer programs are available that perform multivariate analysis and allow a laegenumber of items to be input as potentially relevant factors. This program is availa le in spe-cial mathematical applications packages. You should be warned that the culation imeionshi included. Recently, neural ni juickly as more data relationships are inclused to find ‘solutions to complex problems of supply and eaips eS anei lution that fixes the relationshiyadvantage of not being bound to a solutio relationships of cach ofthe inputsvalue. That-is, the multivariate answer to the soyt <
ctiect of supply is always four times greater than the effect of demand; but the 5 neural petsolution may say that, in most years when supply is not threatened by weather, the deis the primary factor. Neural nets are discussed in Chapter 20.
(oi 1429 “Sezes)
 
MULTIVARIATE At
 
1OXIMATIONS
Select
  
g Data for an S&P Model
orchestrated by the Central Bank.
To create a robust S&P model, whether using multiple regression or, as we will discussJater, neural networks, it is necessary to select the most meaningful data. The following wasSuggested by Lincoln to be used for a 6-month S&P forecast:
1. SGP prices—the closing prices of the Standard & Poor’s 500 cash index2. Corporate bonds/Treasury bonds—the BAA corporate bond yield divided by the30-year Treasury bond yield, normalized by subtracting the historical mean3. Annual change in the dollar—the 12-month change in the dollar, minus 1, whichmight be based on the Dollar Index traded on the New York Futures Exchange, ora comparable weighting of major currencies4. Annual change in Federal funds rate—the 12-month change in the Fed funds rate,minus 15. Federal funds rate/discount rate—the Fed funds rate divided by the discount rate;normalized’ by subtracting the historical mean6. Money supply—M1 money supply, not seasonally adjusted7, Annual Consumer Price Index—the 12-month change in‘the CPI, minus 18. Inflation/disinflation index—the annualized _1-month change in the CPI dividedby the 12-month change in the CPI, minus 19. Leading economic indicators—the 12-month chahge in the leading economic in-dicators, minus 110. One-month versus 10-month oscillator for the S&P cash index—the difference be-tween the monthly average and the past 10 months, approximately 200 days
commercial loans
Lincoln used 20 years of monthly values to forecast the S&P price 6 months ahead.Some of this data is available on a weekly basis and might be adapted to a shorter timeframe; however, it is unreasonable to think that an accurate daily forecast is possible usingweekly or monthly data. It is also likely that the use of more frequent S&P price data isinconsistent with the monthly statistics and will introduce more noise and make the results.less reliable.
One element that is missing from the 11 items listed is a volatility adjustment. Therehas been a 600% increase-in the S&P price over 20 years, and volatility is clearly muchhigher. A simple percentage relationship may not describe this change adequately, but mayre or less‘Volatile as prices move higher and lower must be corrected using a volatility-normalizingfactor. For example, if we consider the initial yolatility when the S&P was 100 at the begin-ning of the data as normal, then when the Price is 800 we will divide the current volatilityby 8 to normalize, or even take the square root if the increase in volatility is nonlinear. Thistype of adjustment would apply to nearly all the items except money supply and the infla-tion/disinflation index. Don’t forget that, where applicable, yields must always be used, notprices.
° Thomas H. Lincoln, “Time Series Forecasting: ARMAX," Technical Analysis of Stocks and Commodities (Sep-tember 1991), 
54 REGRESSION ANALYSIS
Generalized MultivariateIn general, the relationship between 7 independent variables is expressed as
YH Ay + AyXy + Qt + An Xn
The solution to this equation is an extension of the problems in two variables. The n +