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.

Wednesday, January 16, 2013

Stock Market Recap for 2012

It's time to look back at last year's Stock Market and see what, if anything, the Random Stock Walker learned. This blog is largely based on ideas from Burton Malkiel's book A Random Walk Down Wall Street. I first read Malkiel's book in 1975 and it has always been a big influence on my views of the Stock Market and of investing. However, I have also been a little uncomfortable with the lessons I took from the book and last year I set out to give some of the ideas a test.

Malkiel's basic hypothesis is that the Stock Market is a random walk, that is, today's stock price is given by yesterday's stock price plus random error P(t) = P(t-1) + E. If this is true, the implications for investing are shocking. Since you cannot predict the movement of a random walk, investing is just gambling. Your financial analyst and commentators on CNBC are basically selling snake oil. The counter argument is that stocks do seem to have trends over time and minimally might perform like a random walk with drift, P(t) = a + P(t-1) +E, where a is the drift parameter. As long as a is positive, you can expect to make a little money over time as long as your profits aren't eaten up by taxes, trading fees and investment fees (this argument is made by Andrew Lo and Archie MacKinlay in their book A Nonrandom Walk Down Wall Street, follow the link to read the free on-line pdf file).

After reading these two books and living through a few financial crises (Savings and Loan CrisisDot-com bubble, Subprime Mortgage Crisis, etc.), I have to admit that Malkiel's book is more fun to read and very appealing. However, I have always had nagging doubts. Maybe some stocks aren't random walks. If you could identify them, maybe they would be good investments. Also, being a statistician, I knew I could write a program that could test to see whether or not a stock or some market index was a random walk. The strategy would be to do this for a few years and see how the models perform. I now have a few year's worth of data.


The most important stock I had to watch last year was Apple computer (AAPL) since I owned it from 1988 to September of 2012. I sold the stock just short of the peak in September of 2012. Why?


The basic answer is the graph above taken from a February 2012 post (here) when CNBC commentators were speculating that AAPL would hit 500 within the week. My models were showing two things: AAPL was not a random walk and 500 would not be reached until half way through 2013. We are two weeks into 2013, and AAPL is 509 today, still a little over-valued given my models.

The dotted red line in the graph above is the attractor path for AAPL while the dotted green and blue lines are the upper and lower 98% prediction intervals, respectively. Anytime AAPL gets out of the upper 98% prediction interval, my models start screaming SELL and when the stock price gets below the attractor value, the models say BUY. As for AAPL, I haven't bought back in and there wouldn't be much reason to until the stock starts trending over 500. Currently, some CNBC analysts are saying that AAPL has bottomed out (here) while others are saying that the company's problems that are not going away anytime soon (here). The next few years will tell.

Unlike individual stocks, Malkiel argues that index funds provide great investment opportunities because of low fees and consistent performance, that is, they are not random walks, supposedly because the index usually consist of the best stocks on a particular exchange. In October of 2012, I took a look at the Dow Jones Industrial Average (DJI) in terms of the 1987 Flash Crash (here). The DJI was of interest because flash crashes appear to be a new feature of investing driven by program trading. Can we be sure the DJI is not a random walk?

My models suggest that the DJI is not a random walk but rather that it's attractor path is being driven by the US economy. Unfortunately, for long periods during the late 1980's, the DJI was well below its attractor path. If you had your savings in a DJI index fund, had retired during this period and needed the money, you might be taking some losses. Investing in index funds are, evidently, no guarantee of good performance at any given point in time.

In summary, the Random Stock Walker investigations for 2012 are inconclusive. Some stocks are not random walks and some index funds are not random walks. This doesn't mean that you can simply identify a stock that is being driven by the world economy (as is AAPL) or an index who's attractor is being driven by the US economy (as is the DJI), and do some log-term buy-and-hold investing. If a stock gets too far above its attractor, it would be smarter to sell. The bubble may not last forever and who knows what might happen in the future. Index funds can also also be subject to bubbles (as was true of the DJI during 1987) and the return to the attractor (the bubble-popping "Flash Crash") can be rapid. What's worse, the index can under-perform for years afterward.

If I look back a littler further, into 2011, the are some other lessons about identifying stocks that I will cover in a future post.