Skip to main content

Analysis of Variance - An Empirical Study of Relative Means and Their Implications on Price Action

ANOVA


In statistics, the analysis of variance - more commonly referred to as an ANOVA - tests the relationship of multiple sets of means to determine if their respective populations are significantly different from one another and, therefore, independent.

Means are a ubiquitous analytical tool.  For the purposes of quantitative trading, changes in means and their delineation of interval trends are commonly cited factors when trying to determine future price paths; these are more commonly referred to as moving averages.  When interval moving averages are observed on a relative basis, we can conduct a 'technical analysis of variance.'

In plain English, we can easily observe the 20 day moving average of a stock to get a basic understanding of its recent direction and momentum.  We can similarly observe the 50 day moving average to understand the stock's longer term direction and momentum.   Additionally, we can measure the dispersion of the stock's price to these historical means.  These are all ex-post observations in that we are studying past behavior. However, when we observe the relationship of means to one another, we can conduct ex-ante analyses about likely future events.

To be clear, this 'technical ANOVA' is not a test of population independence... by their very nature, we know that interval moving averages are derived from the same population of price data and, therefore, are not independent.  Rather, the purpose is to make deductions about the timing, direction and magnitude of future price changes.


THEORY OF RELATIVITY

Einstein's theory of general relativity made its way back into mainstream news recently as scientists observed the presence of gravitational waves that are creating curves in the space-time continuum.  The geometric theory of gravitation is an extension of special relativity to account for non-inertial frames of reference... or so I'm told.  Basically, the theory of relativity describes motion between two frames of reference.

Equity prices typically move in one of two ways... barely at all or all of a sudden.  Modest movements in prices can be characterized by prices that stay within an expected range over a given period of time as generalized by a realized standard deviation.  Whereas, dramatic price changes will move outside of that expected range... sometimes violently so, as in the case of idiosyncratic catalyst events or systemic market corrections.  To the naked eye, these movements can appear to be completely random.

However, when we observe the movements of equity prices - which we know to be stochastic and assume to be lognormal - we notice the motion of interval means through the incorporation of technical analysis.  Here's a link to a piece I wrote on simulating equity prices:

http://tancockstradingblog.blogspot.com/2015/08/projecting-equity-prices-using.html

The motion of these measurements relative to one another tends to create energy that can directly influence price action.  This brings us back to our technical ANOVA; the purpose of which is to understand when prices are likely to release energy and move outside of their standard ranges.


THE ENERGY FORMULA

Einstein would derive his theory of special relativity to express the relationship between mass and energy... we have come to recognize this expression by its famous formula, E=MC^2.

To understand how equity markets display energy, let us first define a few variables:













Where:
  • 20 Day Moving Average: The arithmetic mean of prices over the previous 20 days
  • 50 Day Moving Average: The arithmetic mean of prices over the previous 50 days
  • 20 Trend: A normalized measure of the change in the 20 day moving average
  • 50 Trend: A normalized measure of the change in the 50 day moving average
  • 20 Day Variance: A normalized measure of absolute dispersion between the current price and 20 day moving average
  • 50 Day Variance: A normalized measure of absolute dispersion between the current price and 50 day moving average
  • Moving Average Variance: A normalized measure of the dispersion between moving averages
  • Moving Average Variance Delta: The rate of change in the moving average variance
Note that many of these variables are 'normalized measures'... this is done for the sake of principal component analysis (PCA).  PCA is a technique used to emphasize variations in large data sets... it is a form of factor modeling that is closely related to multi-variate regression.  In plain English, PCA gives us a tool to effectively compare apples to oranges... or in our case, to compare the movements of high volatility stocks to low volatility stocks.

Next, let's observe some recent price action in the S&P and note the motion of relative means.  Here's a chart of the SPY:


Our relative means are exhibited in the forms of curved lines which represent interval moving averages.

Below, are a few more visual representations of quantified variables used in my principle component analysis:

20 Day Variance:


The red lines represent points where the normalized measure of dispersion between price and moving average would be high.




 Moving Average Variance:


Here, the red lines show areas of wide dispersion between moving averages.






Moving Average Variance Delta: 

Here, we see both expanding and contracting moving average deltas.








SPLITTING ATOMS & SPLITTING MEANS, BOTH RELEASE ENERGY

On July 16, 1945, Robert Oppenheimer split the Plutonium atom to instantaneously release the equivalent of 20 kilotons of TNT in the New Mexico desert.  Years after the successful Trinity test, Oppenheimer darkly equated his feelings following the world's first uncontrolled release of atomic energy to the Hindu scripture Bhagavad Gita by saying, "'Now I am become death, the destroyer of worlds.'"

On a lighter note, we can also think of equity price action in terms of releasing energy.  Going back to our chart of the SPY, we notice three distinct dramatic moves that have all taken place over the course of the past six months:


The first (left-most) and third (right-most) moves represent almost identical retracement and subsequent breakout patterns that followed bouts of dramatic selling.  The second movement represents the most recent round of market volatility that shook the S&P back in January. 

Let's start by looking at the first move and breaking it down into three component parts:
  • The first move is the market's retracement off of a low.  The market has expended a lot of energy to get to this point and is beginning to recoil.  Here, the index has large 20 and 50 day variances, a large negative moving average variance and the move begins at the point where the difference between the averages begins to shrink, or the moving average variance delta statistic changes from negative to positive.
  • The second part of the move is a basing period where volatility recedes and markets consolidate and store energy again.  Here, the variance statistics are getting smaller.
  • The last segment of the move is a breakout.  The averages have crossed and are the variance between them is growing as the market expends energy again until the point where the variance statistics are large again.
Now, let's examine the characteristics of the second move to understand how relative means can forecast the timing of market movements.

Prior to the January breakdown, the S&P pulled back a total of four times following its most recent high.


Why didn't the index break down at any of these moments?
  • The moving average variance statistic is widely positive during the first two pullbacks and actually positive (even if barely so) during all four.  A wide Moving Average Variance is the result of recent price action where energy has been used.
  • As the average variances contract, the market moves become larger as the index has recouped energy.
  • Finally, after the averages cross again and begin to expand to the downside, market energy expands to the downside and another round of selling follows.


Lastly, let's look at the third movement:
  • This should look familiar as we saw an almost identical move following last summer's market volatility.
  • The three segment moves follow the same patterns as last fall's move with the same accompanying statistics.
  • This is the basis for an expected continuation of the breakout pattern... history suggests that prices will continue to expand as the market releases energy until the variance statistics become inflated once again.

The argument could be made that these examples are anecdotal... and it's true that there are always exceptions to general rules.  Fundamental market factors cannot be ignored.  However, when patterns appear consistently throughout history and the same set of variable measurements accompany them, deductions can be made about future price action.

Comments

Popular posts from this blog

Modeling Credit Risk...

     Here's a link to a presentation I gave back in August on modeling credit risk.  If anyone would like a copy of the slides, go ahead and drop me a line... https://www.gotostage.com/channel/39b3bd2dd467480a8200e7468c765143/recording/37684fe4e655449f9b473ec796241567/watch      Timeline of the presentation: Presentation Begins:                                                                0:58:00 Logistic Regression:                                                                1:02:00 Recent Trends in Probabilities of Default:                              1:10:20 Machine Learning:                                                                  1:15:00 Merton Structural Model:                                                        1:19:30 Stochastic Asset Simulation Model:                                        1:27:30 T-Year Merton Model:                

Modeling Black-Litterman; Part 1 - Reverse Optimization

  "The 'radical' of one century is the 'conservative' of the next." -Mark Twain In this series, I'm going to explore some of the advances in portfolio management, construction, and modeling since the advent of Harry Markowitz's Nobel Prize winning Modern Portfolio Theory (MPT) in 1952. MPT's mean-variance optimization approach shaped theoretical asset allocation models for decades after its introduction.  However, the theory failed to become an accepted industry practice, so we'll explore why that is and what advances have developed in recent years to address the shortcomings of the original model. The Problems with Markowitz For the purpose of illustrating the benefits of diversification in a simple two-asset portfolio, Markowitz's model was a useful tool in producing optimal weights at each level of assumed risk to create efficient portfolios.   However, in reality, investment portfolios are complex and composed of large numbers of holdin

Evidence the SPY is Overbought...

 A quick note on the recent market rally here of late.  It's plain to see the markets have been on a tear for the month of June (and going back into May for the QQQ) as the SPY closed today at its highest level in almost fourteen months. If we start to look at the historical levels, however, it appears the SPY may be overbought in the short-run and susceptible to a mean-reverting pattern. Here's the daily chart of the SPY as of today's (6/15/23) close... When looking at the distance between the closing price and the 50-day moving average (illustrated by the yellow bar), we're noticing a large gap... this can be measured by a statistic I developed which I casually refer to as "variance"... or the distance between current prices and their respective moving averages. Historically, throughout the life of the SPY (which debuted in January of '93), the variance over the 50-day moving average has peaked at a reading of 3.20... today's reading posts up at 2.49