70) + (.375 x 55)= 64375and the fourth day,PUUP)4 = (.64375 X .70) + (35625 x 55)= 64656
 
 
which can now be seen to be converging. To generalize the probability of an up day, look —
at what happens on the ith day:P(up):++= [P@ap). x .70] + [A — P(up),) x 55] - .
 
FIGURE 2-6 Probability network.
 
PROBABILITY —~ oy
a SeSeSeSesSeeSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSsssSsSSSSSSSSSSSSSeee
eeTABLE 2-4a Counting the Occurrences of Upand Down Days
 
 
 
 
 
TodayUp Down ‘TotalUp 7s 60 135Previous dayDown 60 65 125TABLE 2-4b Starting Transition MatrixTodayUp Down TotalUp S85 444 1.00Previous dayDown 480.520 1.00
 
Because the probability is converging, the relationshipP(up)i+1=P(up):
can be substituted and used to solve the equation -Pup), = [P(up), x .70] + [.55 — P(up), x 55]
giving the probability of any day being up within an uptrend asPup); = 64705
‘We can find the chance of an up or down day if the 5-day trend is up simply by substitut-ing the direction of the 5-day trend (or n-day trend) for the previous day’s direction in theexample just given.
Predicting the weather is a more involved case of multiple situations converging andmay be very representative of the way prices react to past prices. By approaching the prob-lem in the same manner as the two-state process, a 4 probability is assigned to each situa-tion for the first day; the second day’s probability is
P(clear), = (.333 X .70) + (.333 x .20) + (.333 x .20)
= 3663P(cloudy); = (.333 x .25) + (.333 x .60) + (.333 x .40) ~= 41625P(rainy)2 = (.333 x .05) + (.333 x .20) + (.333 x 40)= .21645
Then using the second-day results, the third day isP(clear); = (.3663 x .70) + (41625 x .20) + (.21645 x .20)38295P(cloudy); = (.3663 x .25) + (.41625 x .60) + (.21645 x .40)=.42791 
- 28 BASIC CONCEPTS
iC CONESP(cainy)s = (.3663 X..05) + (41625 x .20) + (.21645 x .40)= .18815 '‘The general form for solving these three equations isP(clear),.., = [P(clear), x .70] + [P(cloudy), x .20] + [P(rainy), x .20]P(cloudy),.,= [P(clear), x .25] + [P(cloudy), x .60] + [P(rainy), x .40]P(rainy),,,= [P(clear), x .05] + [P(cloudy), x .20] + [P(rainy), x 40]
where each i + 1 element can be set equal to the corresponding ith values; there are thenthree equations in three unknowns, which can be solved directly or by matrix multiplica-tion, as shown in Appendix 3 (“Solution to Weather Probabilities Expressed as a MarkovChain”)? Otherwise, it will be necessary to use the additional relationship
 
P(clear), + P(cloudy), + P(rainy), = 1.00The results are
P(clear) = .400
P(cloudy) = 425
P(rainy) = 175
Bayes Theorem
Although historic generalization exists concerning the outcome of an event, a specific .cur-rent market situation may alter the probabilities. Bayes theorem combines the originalprobability estimates with the added-event probability (the reliability of the new infor-mation) to get a posterior or revised probability,
P(original and added-event)
P(added-event)
Assume that the price changes P(up) and P(down) are both original probabilities and thatan added-event probability, such as a crop report, inventory stocks, or money supplyannouncement, is expected to have an overriding effect on tomorrow’s movement. Then
New probability P(up | added-event) =
P(up and added-event)P(up and added-event) + P(down and added-event)
where up and down refer to the original historic probabilities, and P(A and B) is a jointprobability.
Bayes theorem finds the conditional probability even if the joint and marginal proba-bilities are not known.
 
New probability P(up | added-event) = -- P(up) x P(added-event | up) :‘P(up) x P(added-event | up) + P(down) x P(added-event | down)where P(added-event | up) is the reliability of the new event being a correct predictor ofan upwards move, and P(added-event | down) is the probability of prices going down
? 4 full mathematical treatment of Markov chains can be found in John G. Kemeny’s and J. Laurie Snell's FiniteMarkov Chains (SpringerVerlag, New York, 1976).
 
 
‘SUPPLY AND DEMAND: 29
when the added news indicates up. For example, if a decline in soybean planting by morethan 10% has a 90% chance of causing prices to move higher, then
P(added-event | up) = .90andP(added-event | down) = .10
would be used in Bayes theorem.
SUPPLY AND DEMAND
Price is the balancing point of supply and demand. To estimate the future price of anyproduct or explain its historic patterns, it will be necessary to relate the factors of supplyand demand and then adjust for inflation, technological improvement, and other indica-tors common to econometric analysis. The following sections briefly describe these factors.
Demand
‘The demand for a product declines as price increases, The rate of decline is always depen-dent on the need for the product and its available substitutes at different price levels. InFigure 2-74, D represents normal demand for a product over some fixed period. As pricesrise, demand declines fairly rapidly. D’ represents increased demand, resulting in higherprices at all levels. :
Figure 2-76 represents the demand relationship for potatoes for the years 1929-1939.In mést cases, the demand relationship is not a straight line; production costs and mini-mum demand prevent the price estimate from going to zero. On the higher end of thescale, there is a lag in the response to increased prices and a consumer reluctance toreduce purchasing even at higher prices (called inelastic demand). Figure 2-7¢ shows a
 
FIGURE 2-7 (a) Shift in demand. (b) Potatoes: U.S. average farm price on December 15thversus total production: 1929-1939. (c) Demand curve, including extremes.
Quantity
 
Price- (a)
i a
 
Source: Shepherd, Geoffrey S.,and G.A. Futrell. Agricuttural Price Analysis. (Ames, IA: lowa State University,1969, p. 53.) 
BASIC CONCEPTS30
rrrFIGURE 2-7 (Continued)
 
160
 
 
 
vided by the general8
 
 
price level
 
80
 
 
 
 
 
 
 
 
 
U.S. average price of potatoes
 
 
 
 
 
° 300 325 350 375 400 425U.S. production of potatoes in bushels (millions)(e)
 
ive demand curve, including extremes, where 100 represents the mini-mom acceptable ‘income for a producer. The demand curve, therefore, shows the rate atwhich a change in quantity demanded brings about a change in price.
 
Elasticity of Demand /Blasticity is the key factor in expressing the relationship between price and demand. It is
the relative change in demand as price increases,
aFIGURE 2-7 (Continued) .
 
- = Quantity {increasing >) . -
. ()ee LEU EE EIEIEEEE SSE RSE EEEREREEEEEE
span
SUPPLY AND DEMAND 3
__ felative change (%) in demand”” relative change (%) in price
A market that always consumes the same amount of a product, regardless of price, iscalled inelastic: as price rises, the demand remains the same and £p is negatively verysmall. An elastic market is just the opposite: as demand increases, price remains the sameand Ep is negatively very large. Figure 2-8 shows the demand curve for various demandelasticities.
If supply increases for a product that has existed in short supply for many years, con-sumer purchasing habits will require time to adjust. The demand elasticity will graduallyshift from relatively inelastic (Figure 2-86) to relatively elastic (Figure 2-82).
Supply
The supply side of the economic equation is the normal counterpart of demand. Figure 2-9a shows that, as price increases, the supplier will respond by offering greater amounts ofthe product. Figure 2-96 demonstrates the supply at price extremes. At low levels, belowproduction costs, there is a nominal supply by those producers who must maintain opera-tions due to high fixed costs and difficulty restarting after a shutdown. At high-price levels,supply is erratic. There may be insufficient supply in the short term, followed by theappearance of-new supplies or substitutes, as in the case of a location shortage. In mostcases, however, it is demand that brings price down.
Elasticity of SupplyThe elasticity of supply Es is the relationship between the change in supply and the changein price,p, = felative change (%) in supply‘*relative change (%) in price
The elasticity of supply, the counterpart of demand elasticity, is a positive number,because price and quantity move in the same direction at the same time.
Equilibrium
The demand for a product and the supply of that product meet at a point of equilibrium.The current price of any commodity, or any market, represents the point of equilibrium forthat product at that moment in time. Figure 2-10 shows a constant demand line D and ashifting supply, increasing to the right from S to S’.
———FIGURE 2-8 Demand elasticity. (a) Relatively elastic. (b) Relatively inelastic. (c) Normal market.
Relatively inelastic
       
Unit elasticity
 
g 8 8= ae & = RelativelyelasticQuantity Quantity Quantity =(a) (b) (
  
34 BASIC CONCEPTScause prices to reflect the pattern shown by the direction of the arrows on the cobweb,producing the sideways market shown in Figure 2-116. If the cobweb was closer to theptersection of the supply and demand lines, the volatility of the sideways price patternwould be lower; if the cobweb was further away from the intersection, the pattern wouldbe more volatile.
‘Most supply-demand relationships are not static and can be represented by lines thatcross at oblique angles. In Figure 2-12a, the cobweb is shown to begin near the intersec-tion and move outward, each shift forming a different length strand of the web, movingaway from equilibrium. Figure 2-12 shows that the corresponding price pattern is onethat shifts from equilibrium to increasing volatility. A reversal in the arrows on the cobwebwould show decreasing volatility moving toward equilibrium.
Building a Model
‘A model can be created to explain or forecast price changes. Most models explain ratherthan forecast. Explanatory models analyze sets of data at concuirent times, that is, theylook for relationships between multiple factors and their effect on price at the samemoment in time. They can also look for causal, or lagged relationships, in which pricesrespond to other factors after one or more days. It is possible to use the explanatory modelto determine the normal price at a particular moment. Although not considered forecast-ing, any variation in the actual market price from the normal or expected price couldpresent trading opportunities.
‘Methods of selecting the best forecasting model can affect its credibility. An analyticapproach selects the factors and specifies the relationships in advance. Tests are then per-formed on the data to verify the premise. Many models, though, are refined by fitting thedata, using regression analysis or shotgun testing, which applies a broad selection of vari-ables and weighting to find the best fit. These models do not necessarily forecast but aredefinitely using perfect hindsight. Even an analytic approach that is subsequently fine-tuned could be in danger of losing its forecasting qualities.
‘The factors that comprise a model can be both numerous and difficult to obtain.ure 2-13 shows the interrelationship between factors in the cocoa industry. Although thischart is comprehensive in its intramarket relationships, it does not emphasize the globalfnfluences that have become a major part of price movement since the mid-1970s. The
 
ESET nT SSP naFIGURE 2-12 Dynamic supply-demand cobweb. (a) Dotted lines represent a cobweb movingaway from equilibrium. (b) The price pattern shows increasing volatility.
Dynamic supply/demand
  
~Quantity - Time
aSource: Curtis McKallip, Jr. “Fundamentals behind technical analysis,” Technical Analysis of Stocks & Commodities,7, no. 11 (November 1989).© 1989 by Technical Analysis, Inc. Used with permission.
SUPPLY AND DEMAND.35change in value of the U.S. d‘ .S. dollar and the volatility of intere:: stinfluence | on Price than normal fundamental factors for many commutes far greaterat explain price movements must be construc 1I ‘ted from th iisupply and demand. A simple example for estimating the price of fall pokatoea ie rors ofPPPI=a+bS+cD
‘J.D. Schwager, “A Trader's Guide to Analyzing the Potato Futures Market,” 1981 Com
modity Research Bureau, New York, 1981). ity Yearbook (Com
 
FIGURE 2-13 Cocoa factors.
Price
             
Exogenous influences‘on new planting
 
Normal price
expectationsNewplanting
Productivetrees . Consumptionexpectations
Exogenousinfluences onconsumption
“consumptionProduction
‘Consumption
Exogenous
influences .
fon production Productexpectations
   
Inventoryexpectations
 
 
 
ble A is exogenous.te B is determined by variables A and C.Variable C is determined by variable B.
 
 
—_—_—_—
Source: ieice: F. N.Weymar, The Dynamics of the World Cocoa Market (Cambridge, MA: MIT Press, 1968, p.2) 
. BASIC CONCEPTS36where P is the average price of fall potatoes received by farmers; PPI is the: Produces PreeIndex: Sis the apparent domestic free supply (production less exports and diversions); Dis the estimated deliverable supply; and a, 6, and c are constants determine er
aS model implies that consumption must be constant (i.e., inelastic demand);
itly i i i i ly. Exports andimplicitly included in the estimated deliverable supplSeen eee tescnc.a sal part ofthe total production. The tac ofthe FP estersi ferm: whether the index was used as an inflator or defla .° general cel presented by Weymar,’ may be written as three behavior-based equa-
tions and one identity:(a) ConsumptionC,=fePr Pi) + ec,(b) ProductionHy = falPr, Pi) + &n,(c) Inventoryh=hatH,-G(d) Supply of storageanne i ice, P* is the lagged price, H is the production (har-eer oe icneonn P's the expected price at some pointin the future, and eis the cor
factor.rere Ret ewe equations show that both demand and supply depend on aren and/ori 5 i cons:i traditional macroeconomic theory; production an ‘eed eendent on past prices. The third equation, inventory level, is simply the total ofprevious inventories, plus new production, less current consumprion- me ast equatio 2.trates that people are willing to carry larger inve ;eee eee ee Substantially. The inventory function itself, equation (c), is com-posed o two separate relationships—manufacturers’ inventories and speculators’ inven-
tories. Each reacts differently to expected price change.
1968).5 BH. Weymar, The Dynamics of the World Cocoa Market (MIT Press, Cambridge, MA, 1968).
es
Regression Analysis
of data. An economist might want to know how the supply of wheat affects wheat
Prices, or the relationship among gold, inflation, and the value of the U.S. dollar. Ahedger or arbitrageur could use the relationship between two related products, such aspalm oil and soybean oil, to select the cheaper product or to profit from the difference, oryou can find the pattern that binds the Producer Price Index to interest rates. Regressionanalysis involves statistical measurements that determine the type of relationship thatexists between the data studied. Many of the concepts are important in technical analysisand should be understood by all technicians, even if they are not used frequently. The tech-niques may also be directly used to trade, as will be shown later in this chapter.
‘ Regression analysis is often applied separately to the basic components of a timeseries, that is, the trend, seasonal (or secular trend), and cyclic elements. These three fac-tors are present in all price data. The part of the data that cannot be explained by thesethree elements is considered random, or unaccountable. ~
‘Trends are the basis of many trading systems. Long-term trends can be related to eco-nomic factors, such as inflation or shifts in the value of the U.S. dollar due to the balance oftrade or changing interest rates. The reasons for the existence of short-term trerids are notalways clear. A sharp decline in oil supply would quickly send prices soaring, and a Sovietwheat embargo would force grain prices into a decline; however, trends that exist over peri-ods of a few days cannot always be related to economic factors but may be strictly behavioral.
Major fluctuations about the long-term trend are attributed to cycles. Both business andindustrial cycles respond slowly to changes in supply and demand. The decision to close afactory or shift to a new crop cannot be made immediately, nor can the decision be easilychanged once it is made. Stimulating economic growth by lowering interest rates is not acure that works overnight. Opening a new mine, finding crude oil deposits, or building anadditional soybean processing plant makes the response to increased demand slower thanthe act of cutting back on production. Moreover, once the investment has been made, busi-ness is not inclined to stop production, even at returns below production costs.
The random element of price movement is a composite of everything unexplainable.In later sections ARIMA, or Box-Jenkins methods, will be used to find shorter trends andcycles that may exist in these leftover data. This chapter will concentrate on trend identifi-cation, using the methods of regression analysis. Seasonality and cycles will be discussedin Chapters 7 and 8. Because the basis of a strong trading strategy is its foundation in realphenomena, serious students of price movement and traders should understand the toolsof regression analysis to avoid incorporating erroneous relationships into their strategies.
Rees analysis is a way of measuring the relationship between two or more sets
CHARACTERISTICS OF THE PRICE DATA
A time series is not just a series of numbers, but ordered pairs of price and time. There is aspecial relationship in the way price moves over various time intervals, the way price reactsto periodic reports, and the way prices fluctuate due to the time of year. Most trading strate-gies use one price per day, usually the closing price, although some methods will averagethe high, low, and closing prices. Economic analysis operates on weekly or monthly average 
38 REGRESSION ANALYSIS
 
eeFIGURE 3-1 A basic regression analysis results in a straight line through the center of prices.T
‘Seasonal highs
   
movinYear trendlineshows inflation trend
 
data, but might use a single price (e.g., “week on Friday”) for convenience. Two reasons forthe infrequent data are the availability of most major statistics on supply and demand, andthe intrinsic long-term perspective of the analysis. The use of less frequent data will cause asmoothing effect. The highest and lowest prices will no longer appear, and the data willseem more stable. Even when using daily data, the intraday highs and lows have been elim-inated, and the closing prices show less erratic movement.
‘A regression analysis, which identifies the trend over a specific time period, will not beinfluenced by cyclic patterns or short-term trends that are the same length as the timeinterval used in the analysis. For example, if wide seasonal swings occurred during the yearbut prices ended at about the same level (shifted only by inflation), a 1-year regression linewould be a straight line that split the fluctuations in half (see Figure 3-1).
‘The time interval used in regression analysis is selected to be long (or multiples ofother cycles) if the impact of short-term patterns is to be reduced. To emphasize the move-ment caused by other phenomena, the time interval should be less than one-half of thatperiod (e.g., a3- or 6-month trend will exaggerate the seasonal factors). In this way, a trendtechnique may be used to identify a seasonal or cyclic element. .
LINEAR REGRESSION
When most people talk about regression, they think about a straight line, which is the mostpopular application. A Jinear regression is the straight-line relationship of two sets of data.
- $$ $$ $$$
‘TABLE 3-1 Annual Average Corn and Soybean Prices
 
 
 
1956 1957 1958 1959 1960 1961 1962 1963 1964 1965Corn 1.27 1.19 1.40 1.10 1.05 _ 1.00 98 1.09 12 1.18Soybeans 243 2.26 215 2.07 2.03 245 236 2.44 2.52 2741966 1967 1968 i969 1970 1971 1972 1973 1974 1975Corn 116 1.24 1.03 1.08 1S 1,33 1.08 1.57 255 3.02Soybeans 2.98 2.93 269 263 = 2.63 3.08 3.24 622 612 6.331976 1977 1978 1979 1980 1981 1982Corn 254 2s 2.02 225 252 3.1 2.50
Soybeans 492 68! 588. 6.61 6.28 7.61 6.05
Source: 1956-1965: Hiinois Statistical Service; 1966-1982: Commodity Research Bureau Commodity Yearbook.
 
dinsrees
METHOD OF LEAST SQUARES 39It is most often found using a technique called a best fit, which selects the straight line thatcomes closest to most of the data points. Using the prices of corn and soybeans as an exam-ple, their linear relationship is the straight-line (or first-order) equation (see Table 3-1).
Y=a+bx
where Yis the price of corn (dependent variable)X is the price of soybeans (independent variable)@ is the intercept (where the line crosses the Y-axis)b is the slope (angle of the line)
METHOD OF LEAST SQUARES.
The most popular technique in statistics for findin; i: g the best fit is the method of Isquares. This approach produces the straight line from which the actual data fois vay¢ least. To do this, calculate the sum of the squares of all the deviations from the line
value and choose the line that has the smallest total deviation. T -i2 che -viation. The mathematical expres-
S=> (1-5), while all uses of imply
S is the sum of the squares of the error of each of the data ii sets, and the value y, — J, is thtdifference between the actual value of at x, and the predicted line value f,. Graphically,the individual deviations, or errors, for four points may look like those in Figure 3-2. Eachacrual data point is @, ¥), 2, Y2)) Os» ws) and (2, ys), and the approximated position on¢ line is (x1 94), (x F2), Cs, Js) and Gs, H.). The sum of the squares of the errors is$= L045?
= 1 -Sy? + (2 -HaY? + (Ws - In)? + (4 -Fay®
FIGURE 3-2 Error deviation for method of least squares.
            
Actual point (observed)
Ne
Approximated point
NN -
Value (points)
a y x x 
“40
REGRESSION ANALYSIS.
‘The line that causes § to be the smallest possible value will be the best choice for thesedata points. The square of yi J: is always positive, thereby magnifying the importance ofthose data points that are farther from the approximated line on either side and reducingthe significance of those points for which the approximation is good. —
To use the least-squares method for solving the corn-soybean price relationship, look
for the solution to the straight line, y =a + bx, expressed asp- Nord Dy~ 2wSe-(Sa)
2 (S9-65s}Here, NV is the number of data points and S represents the sum over N points. To solvethese equations, construct a table of corn and soybean values and calculate all the uniquesums in the preceding formulas individually! (Table 3-2).
Substitute these values into the formulas and solve for a and b.27(202.35) ~ (106.46) (43.38)27(512.95) — (106.46)(106.46)
 
= 5463.45 ~ 4618.23 _~13849.65 — 11333.73 _
= 336= a (43.38 — .336 x 106.46)
 
277.61.27282 .The equation for the least-squares approximation is
y= 282 + 336Selecting values of x and solving for y gives the results shown in Table 3-3. ;
‘The results of the linear approximation are shown in Figure 3-3. The slope of .336 indi-cates that for every $1 increase in the price of soybeans, there is a corresponding increaseof 33.6¢ in corn. This is not far from what would be expected for farm income. Because thecorn yield per acre is 2.5 times greater than the soybean yield in most parts of the UnitedStates, the ratio 1/2.5 should yield a slope of about .4. Considering areas where soybeans“gre alternatives to cotton and other crops, and the tendency for midwest farmers to plantmostly corn, a relatively higher price for soybeans is n6t surprising.
 
Letting the Computer Do the WorkHaving methodically worked through the calculations for linear regression, it should notbe a surprise that the solution is readily available on any spreadsheet program or in strat-
\ Appendix 2 offers a computer program to solve the straight-line equation using the method of least squares, aswell as the nonlinear examples.
 
METHOD OF LEAST SQUARES 41
 
TABLE 3-2 Totals for Least-Squares Solution
 
 
 
Com Soybeansi vi x x? xy ye
1956 1 1.27 243 5.90 3.09 tel1957 2 119 226 5.1 269 1421958 3 110 215 4.62 2.36 4211959 4 Lio 2.07 4.28 2.28 121960 5 1.05 2.03 412 213 1.101961 ‘6 1.00 245 6.00 245 1.001962 7 98 2.36 5.57 231 9%1963 8 1.09 244 5.95 2.66 Lag1964 9 12 252 6.35 2.82 1251965 10 118 274 751 3.23 1391966 " 116 2.98 8.88 3.46 1341967 12 124 293 858 3.63 1s41968 13 1.03 2.69 7.24 277 1.061969 4 1.08 2.63 6.92 284 171970 15 Lis 263 692 3.02 1321971 16 1.33 3.08 9.49 4.10 71972 17 1.08 3.24 10.50. 3.50 171973 18 157 622 38.69 9.76 2461974 19 255 6.12 37.45 15.61 6.501975 20 3.02 633 40.07 19.12 9.121976 2 254 492 24.21 12.50 6.451977 22 215 681 46.38 14.64 4621978 23 2.02 5.88 3487 11.88 4.081979 24 2.25 661 43.69 14.87 5.061980 25 252 6.28 39.44 15.83 6351981 26 34l 761