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.

Tuesday, July 8, 2014

Fiction or Forecast: Gold Will Hit $1,450 an Ounce This Year?


The Random Stock Walker just read a Tweet from The Street on How Gold Will Surge to $1450 an Ounce Before the End of the Year. This immediately caught my attention and the results of looking at this question are interesting. If you have been following this blog you know that our algorithm has not found many random walks among the stocks we've looked at (possibly contrary to Fama and Malkiel). Here, however, we have found a few random walks (someone tell the Chicago School).

In the video above, Scott Carter, CEO of Lear Capital, tells The Street that the US economy is not as strong as investors might think and that, as a result, equities and bonds will not perform very well leaving gold an attractive investment that will drive up the price. Mr. Carter is not advocating going out and buying gold bullion but rather, as the article notes (here), GLD (the SPDR Gold Trust ETF), IAU (the iShares Gold Trust ETF) and SGOL (the ETFS Gold Trust).

On the other hand, the Market News attached to the Gold ETFs doesn't sound great: Can Gold ETF's Continue to Shine?, Gold ETFs Gather Assets, But Market Remains Murky, Tarnished Gold ETFS Try to Glimmer, etc. In another article (here), analyst Chad Morganlander of Stifel's Washington Crossing Advisors says that "For the next six to 12 months, gold will be down roughly 5 to 7 percent." Not exactly a collection of rousing endorsements. Can the Random Stack Walker add anything to the confusion?



The two time plots above present forecasts for GLD and SGOL. The dashed red line is the forecasted path for the stock price and the blue and green dashed lines are the lower and upper 98% bootstrap confidence intervals for the forecast. The actual stock price is the sold black line. The forecasts for these two ETFs are resoundingly negative. What is perhaps more interesting is that the best step-ahead prediction model for SGOL and GLD is a random walk. The best attractor models (see the note below) for both GLD and SGOL are driven by the state of the World System (generated by the WL20 model). Unfortunately, both ETFs are negatively related to an important state variable for the World System which is dominated by Oil Prices. Since the WL20 model predicts oil prices to increase with Peak Oil, the increase is going to have a strong negative effect on GLD and SGOL.


IAU, on the other hand, is not a random walk. Both the step-ahead and attractor models for IAU are being driven by the World System (the WL20 model) but the price of IAU is strongly related to Oil Prices. From the time plot above, IAU went through a phenomenal crash towards the end of 2010. Investors would tend to be cautious of a stock with this level of volatility. However, the crash is well predicted by the WL20 model.


The time plot above shows the attractor path for IAU which begins decreasing in 2009 even though the stock price keeps climbing until 2011 when it crashes. For the future, IAU is predicted to take off around 2015 even though it is quite flat right now.

What does the Random Stock Walker analysis have to say for the investor? (1) Gold ETFs behave differently. (2) The best reason to invest in these ETFs is not as a hedge against US economy performance or government policy but rather as a hedge against oil prices. (3) You might have to either ride IAU through future world-system crashes or be prepared to sell the stock when the attractor path diverges from the stock price as it did in 2009 (this is a particularly great example of a sell-high and buy-low strategy based on an attractor path). (4) It's unlikely that Gold will reach $1,450 and, if it does, it's a bubble.

NOTE: A step-ahead prediction is basically the standard regression model you learned in Stat 101 applied to time series data. The next period's stock price is predicted from last period's stock price plus possibly some exogenous variables. The random walk model is P(t) = P(t-1) + E(t-1), that is, the current stock price is last period's stock price plus random error, E. The regression coefficients on the Random Walk model are a = 0 and b=1. The residuals (errors in E) are computed from P(t) - [a + B P(t-1)] = E(t-1). In the attractor model, the residuals are P(t) - P*(t) = E where P*(t) is the simulated time path of the model starting from time zero (around 2005 for the ETFs). This is called a free simulation since the P(t-1) values are not used as they are in the standard regression model. Not many models can meet this test, that is, generate a reasonable attractor path (the dashed red line in the last graphic above). Best models were chosen using the AIC criterion. The Random Stock Walker models for GLD, SGOL and IAU can all be downloaded here with instructions for their use available here.

Tuesday, April 8, 2014

The NASDAQ Bubble Pops!



CNBC commentator Jim Cramer finds the current NASDAQ "sell-off" dramatic and extraordinary. Cramer hasn't "...seen this sort of thing since the NASDAQ peaked in the year 2000." Since the NASDAQ index is primarily composed of tech stocks, Cramer thinks there are too many tech IPOs chasing too few dollars. What's going on?


If you're one of the investors that think the NASDAQ has been primed to take off since 2013, you probably thought the heavy red line in the graphic above would describe the growth path in 2014 and you would have been shocked by the sell-off. If you were a traditional chartist, plotting highs and lows, you might have thought the correction had to happen eventually, so you are not all that surprised. But would any of these investors have thought the NASDAQ was in a bubble as did economist Robert J. Shiller (here)? Many stock analysts were arguing that the NASDAQ was definitely not in a bubble.

The dotted green and blue lines above are the 98% bootstrap confidence intervals in the NASDAQ composite index (^IXIC) dynamic attractor path (the dashed red line). The dynamic attractor path is being driven but the US economy and the US economy has not been growing at a rate that would support NASDAQ 4000 until sometime well into 2015 (Cramer hints at this when he says that "...some actual growth in the economy...opens up the possibility of much higher earnings of traditional techs..." Of course, the opposite is also true with low growth!).


Taking a little longer perspective, as Jim Cramer tried to do when recalling the 1997-2000 dot-com bubble, it is easy to spot the stock bubbles from the NASDAQ dynamic attractor path (above). It is also easy to see how wrong analysts can be when drawing take-off lines on graphs. Also notice that the long-run forecast for the NASDAQ is not really great after 2020. Your intuition about attractor paths should tell you why: the forecast for the US economy is not that great!

Returning to Jim Cramer's observation that "too many IPOs are chasing to few dollars," IPO activity might be one signal at the beginning of a bubble and the shortage of investment funds might be another signal that the bubble is going to pop.

Monday, November 25, 2013

Eugene Fama and the Random Stock Walker



The video above was posted by Index Fund Advisors (IFA) congratulating Eugene Fama on winning the 2013 Nobel Price in Economics. IFA specializes in passive index fund investing, an investment strategy developed by Eugene Fama and Dimensional Fund Advisors (Fama sits on the board of Dimensional). The passive investing strategy is based on two simple, controversial hypotheses with many subtle implications: the Random Walk Hypothesis (RWH) and the Efficient Market Hypothesis (EMH). RWH and EMH are of great interest because they describe the null hypothesis in all Random Stock Walker models. Fama's Nobel prize provides an opportunity to develop the hypotheses.

A random walk in prices is described by the following equation:


where P is the price and E is an error term. A random walk model says the tomorrow's prices are a function of today's prices plus random error. Since the value for the error term cannot be predicted, the model also means that prices following a random walk cannot be forecast. 

Under what conditions might a price follow a random walk? Consider the basic market model:


where quantity demanded and quantity supplied depend on prices. If demand is higher than prices, supply increases to meet demand. The coefficients b and d determine how responsive quantities are to prices. The coefficients a and c are the level of demand and supply, respectively, when prices are zero. If a=c and b=d (they could all be zero, also) or are effectively very close (not statistically different), then the price in this market is a random walk.

The EMH argues that in an efficient market, where information is widely and rapidly available, supply and demand should adjust very quickly, that is, the response coefficients should be very similar. The market might drift predictably over time if a > c, and here is where passive investment comes in. If you invest in an index fund that drifts over time, you might expect to make some money--how much depends on how much drift and the direction of drift. If you try to actively trade stocks in this market, you are basically gambling (allowing the error term, E, to determine your earnings).

Fama also developed another important idea for the Random Stock Walker: the so-called joint-hypothesis problem. If your models are not working, you cannot tell whether it is an imperfection in the model or an imperfection in the market. You can only try to find a better model and even the best model you can find using brute force multi-model inference will be incomplete. 

The empirical evidence for the RWH and the EMH is extensive and contradictory. For the Random Stock Walker, most stocks either show growth, decline or stagnation. Using the AIC and multi-model inference, the RW null hypothesis can almost always be rejected. On the other hand, this doesn't mean you can uses models to make money in the stock market. There are periods when the markets are not predictable and, to paraphrase John Maynard Keynes, these periods can last longer than you can stay solvent.

One of the most unusual subtle implications of accepting the RWH and the EMH is that market bubbles cannot exist, a conclusion Eugene Fama has not been shy about publicizing. After the Dot-com Bubble, Subprime Mortgage Bubble, the Japanese Asset Price Bubble, etc. it's would seem hard to accept that markets always produce rational prices. But, that is a topic for another post when the work of another 2013 Nobel Prize winner, Robert J. Shiller, is discussed.

If awards are given to people we should emulate, then Eugene Fama certainly deserves a major award and the Noble Prize in Economics certainly is one. He has had the prototypical, successful academic career. He took a collection of ideas, the RWH and the EMH, and pushed them both theoretically and empirically as hard as they could be pushed. Whether he turns out to be right, wrong or somewhere in between, he did exactly what every academic is supposed to do. Science will have to sort out the rest.