State Space Models

All state space models are written and estimated in the R programming language. The models are available here with instructions and R procedures for manipulating the models here here.

Friday, October 19, 2012

What Caused The 1987 Flash Crash?



Today is the 25 Year Anniversary of the October 1987 Flash Crash (referred to as Black Monday) when the Dow Jones Industrial (DJI) Average lost 22.6% in one trading session. Since there was also a 2010 Flash Crash, there is some concern that flash crashes are becoming a repeating feature of Wall Street investing.

In the video above, David Blitzer, managing director of the S&P 500 committee, thinks flash crashes can happen again when everyone decides that the world is over-valued and rushes for the exits simultaneously, selling off all their positions. Today, there are circuit breakers put in place as a result of the 1987 Flash Crash, but the driving bubble-panic dynamic is still part of stock market psychology.

These comments are of interest to the Random Stock Walker for a number of reasons. If the DJI is a random walk, then anything can happen at any time in response to some shock. If the DJI is, on the other hand, attractor driven (a random walk has no attractor) then was the flash crash the result of movement off the attractor, that is, a stock market bubble?

To test these ideas I ran four models through the Random Walk estimator (using the rw package, which I will describe in a future post). The four models estimated were a random walk (RW), a business-as-usual (BAU) model, a model where the DJI is driven by the US economy and a model where the DJI is driven by the World economy. The US economy model was identified as the best model (using the AIC criterion) and from the predicted vs. actual plot above, it did a good job of predicting the DJI over the late 20th century.
Using this model, I then ran an attractor simulation. An attractor simulation forecasts the model starting from the initial conditions in 1950 rather than the step-ahead predictions form last period's values displayed in the first graphic. The attractor simulation, displayed above, shows that the 1987 Flash Crash occurred after a multi-period movement away from the DJI attractor (dotted red line). What is unusual is not the movement away (the same occurred in 1983) but the sharp "crash" in October of 1987. What is also unusual was the more than two years necessary for the DJI to return to its attractor path after 1990.

The Random Walker models do not provide an answer to the last two questions, except to point out that movement away from the attractor path eventually results in a return to that path. The causes of the 1987 Flash Crash (here) include program trading, overvaluation, illiquidity and market psychology. Since the crash is thought to have started in Hong Kong, spread to Europe and finally hit the US, macroeconomic causes have also been investigated. 

We need to distinguish between the causes of the bubble and the causes of the collapse. Since the best model for the DJI is driven by the US economy, internal US market dynamics are the best explanation for the movement away from the attractor. The shock for the crash itself may well have been transmitted from the World economy. The rapid crash seems likely to have been caused by programmed trading (algorithms rushing for the exists), however, psychology must have also been hurt given the prolonged period after 1988 when the market could not get back to its attractor path.

From the perspective of the Random Walker, the best solution for flash crashes would be to limit movement away from the attractor path. Circuit breakers will not be enough unless they work more aggressively on the way up. The counterfactual question here is whether strong circuit breakers triggered by bubbles would ultimately have kept the DJI closer to its attractor path?

For the investor, selling as DJI stocks moved away from the attractor path is the right strategy. However, how much you suffered from the Flash Crash would depend on how much of your position you sold off before the crash hit. Since the timing of a crash based on exogenous shocks is impossible to predict, it is unlikely that the strategy would prevent you from taking losses.




Friday, April 13, 2012

What Really Does The Efficient Market Hypothesis Mean?



Today on CNBC, correspondent Steve Leisman interviewed Burton Malkiel, author of A Random Walk Down Wall Street, now in something like its 11th Edition! This interview was of interest to the Random Stock Walker for reasons that are hopefully evident to readers of this blog.

In another blog piece (here) I commented on an interview with Andrew W. Lo who also wrote A Non-Random Walk Down Wall Street which takes the other side of the argument, namely that financial markets are more predictable than the random-walk hypothesis would suggest. What's interesting about this academic debate is what it says about the Financial Crisis of 2007. If markets are a random walk, then financial crises are simply part of their underlying random dynamic. If financial markets are predictable, why wasn't Prof. Lo able to see the financial crisis coming?

In the interview above, Burton Malkiel takes on one myth about the financial crisis, namely that faith in the efficient markets hypothesis led investors to take too much risk during the bubble. The efficient market hypothesis only means that markets provide the best possible information about prices. One corollary is that you can't beat the market because you don't have better information. One qualification, however, is that "best possible information" does not mean that the prices are right. The market is just as efficient at communicating "bubble" prices as it is in communicating "rational" prices.

The analysis leaves open the question of how to compute rational prices if the market won't do it for you. In the long run, Prof. Malkiel would argue that the market will eventually get it right. Unfortunately, that point will be too late for you to make any money off it!

From the perspective of attractor theory, which is the subject of this blog, both Prof. Lo and Prof. Malkiel are right. The market attractor is, I would argue, predictable while the current market position is not. The burning question is whether you can invest using these ideas?

Thursday, February 16, 2012

AAPL Stock Price Almost Returns to Attractor Path

In a post last Friday (here), I argued that Apple stock (AAPL) was way overvalued. The opinion was based on the dynamic attractor plot (dashed red line in the graph below) for the stock. Early this morning, when AAPL was around 490 (after being above 520 yesterday), it seemed pretty clear that the stock was reverting to the attractor value, but then there was a little rally mid-day and it closed above 500 again.
The Random Stock Walker finds the current AAPL "bubble" very interesting for a number of reasons: (1) It should be a fairly clear test of dynamic attractor theory and (2) it might provide some information about why and how a stock runs up to improbable levels above its attractor value (an important unresolved issue from the late-2000s Financial Crisis).

Calculating a stock's attractor path is based on three steps: first, finding out what drives the stock, second, conducting a "free simulation" of the stock price over the entire sample period and, third, calculating the 98% bootstrap prediction intervals for the attractor. The resulting graph for AAPL is displayed above where the solid black line is the stock price, the dashed red line is the attractor value and the other dashed lines are the upper and lower 98% bootstrap prediction intervals. Such an analysis suggests that AAPL stock in the middle of February 2012 should be somewhere between 400 and 450, rather than improbably above 500.

To find out what drives the stock price, I test a number of models using the Reality Check Bootstrap (a procedure developed by Halbert White). The models I check are (1) a random walk, (2) a business-as-usual model predicting the stock price from its lagged values, (3) a model driven by the SP500, (4) a model driven by USL20 model of the US economy and (5) a model drive by the WL20 model of the world economy. In the case of AAPL, the best state-space model is the stock price driven by the world economy. How does this approach differ from conventional stock forecasting?

First, stock prices are typically forecast from last period's (or at most a 12 period lag) stock price. The Random Stock Walker models ignore last periods stock price but pay more attention to the prior period values of the driver variables. Second, academic theory looks almost exclusively at stock price as a function of earnings. These two decisions, focusing on last period's price and last periods earnings, insures that forecasting program cannot see stock market bubbles. Since there is no attractor value, at best the stock can revert to some moving average but the moving average is not really part of the model. And, since we are focused on earnings we miss the real drivers for stock price. In the case of AAPL and in the case of all strong global companies, the stock price has to be driven by the world economy. Earnings are far too narrow.

Obviously, in the case of AAPL, the attractor does not drive the stock price in the short run or AAPL wouldn't have had its recent run up. The Random Stock Walker models have no idea what drives today's stock price. In the case of AAPL, it's probably speculation. If I actually had the courage of my convictions in all this, I would have shorted AAPL last Wednesday. Another approach would have been to take some money off the table by selling AAPL on Wednesday. Option trading has advantage of not requiring initial buying and selling but it is more risky. Any of these approaches, to include stock investing, could be based on attractor theory. Evaluating attractor theory is the purpose of the Random Stock Walker blog.

Friday, February 10, 2012

AAPL above 500? Not Real Until Well Into 2013!

There has been a lot of speculation today on CNBC and in print (here) about the Apple (AAPL) stock price hitting 500 before the end of the week. On Thursday of this week, the stock had a ten point run up from 480 to 490 leading to speculation that another ten point run up might be about to happen. Since mid-day Thursday, however, the stock price has been flat at around 490.
The Random Stock Walker finds these valuations a little improbable for so early in 2012. My forecast above, created at the beginning of 2012, does not show AAPL reaching 500 with high probability (the green dashed line is the upper 98% bootstrap prediction interval and the dashed red line is the attractor forecast) until well into 2013.

These predictions do not mean that AAPL cannot skyrocket above 500 over the next few weeks. If an investor needs to take some money off the table, however, the models suggest paying attention to any negative turning points right now.


Thursday, January 19, 2012

EK: Kodak Moment

Today it was announced that Eastman Kodak (EK) had filed for bankruptcy. The company vowed to continue business as usual and plans to emerge from bankruptcy after "shrinking significantly". At the close of business today the stock was worth $0.360!

At the end of this post I have a CNBC Fast Money video of an interview conducted tonight with EK investor Greg Abella of the Investment Partners Group. Mr. Abella currently owns close to 200,000 EK shares and more the $1 million in Kodak bonds. He was asked in the interview "Why were you holding the stock until the bitter end?"

The question caught the attention of the Random Stock Walker. When might Mr. Abella have known Kodak was going to collapse and what are the chances he can hold his stocks and bonds until the company comes out of Chapter 11?
To answer these questions, I thought I would estimate an EK model ending in the year 2000 and then play the model forward from 2000, compare the predictions to current data and ask what Mr. Abella might have learned doing a similar exercise. The best EK2000 attractor model was being driven by the world economy which makes some sense since Kodak was a world company. Ending the attractor model in 2000 and then forecasting out of sample (see the graph above) didn't really say anything special except that the EK stock price was declining from the mid 1960's with a lot of chop along the way. In other words, the idea that Kodak missed the digital age is a little off the mark. Kodak missed the entire late 20th century.

For the future, the EK2000 attractor model predicts that there is a 50-50 chance that the EK stock price will begin climbing after 2040 and a 98% chance it will begin climbing before 2060. That will be really a long time for Mr. Abella to wait for his money. Now, if you're still interested, you can listen to his interview below.












Thursday, January 12, 2012

AAPL: When Will Apple Stock Hit $1000 per Share?


In May of 2011, James Altucher of Formula Capital forecast (here) that AAPL would be the first company to be worth more than $1 trillion which would be a price of about $1,000 per share. CNBC recently ran a twitter poll asking when viewers thought this might happen. I haven't seen the answer to this poll, but here are my answers based on the forecast graph above: There is a 1% chance that AAPL will hit $1000 per share by mid-2018, a 50% chance by the start of 2021 and a 99% chance by mid-2034. In other words, spreculation about the event would seem a little premature right now.


For the present, AAPL still seems to be undervalued (P/E > 15), continues to have a strong balance sheet and continues to have products in the pipeline (see more analysis here).
For the coming year, if AAPL has a few drops when the stock price gets close to the lower 98% bootstrap prediction interval (the dashed blue line above), it would seem to be a buy if one can afford a stock price approaching $500 per share. AAPL also had a few pops last year when the price reached the upper 98% bootstrap prediction interval (dashed green line). I need to take some profits so hopefully I'll be able to catch one of the peaks when I sell.