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.
Showing posts with label AAPL. Show all posts
Showing posts with label AAPL. Show all posts

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.


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 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.

Sunday, September 25, 2011

When To Buy or Sell AAPL?

Apple Computer (AAPL) continues to do very well even after the departure of Steve Jobs. On the October 20th edition of Fast Money on CNBC, Carter Worth (chief market technician at Oppenheimer & Co) recommended doing what the hedge funds do: sell Apple when it breaks trend.
To determine trend, Worth suggested simply drawing a line along the low prices (see the solid red line above, the top graphic shows the moving average line in solid red) to establish trend. The graphic above compares the "trend selling" approach to the attractor bootstrap 98% prediction intervals for AAPL. The logic of attractor analysis would seem to be to take some money off the table anytime that a stock is above its attractor value and to definitely sell when the stock crosses the lower 98% prediction interval on the way down. You would buy in again either when the stock crossed the lower 98% prediction interval on the way up or when it bounced off the bottom (2009 for AAPL), if you can somehow tell where the bottom is.

In either approach, you would have been totally out of AAPL in late 2008 and buying back in (depending on the other uses of your money) until 2011 when you might have started taking some money off the table using attractor analysis. For the future, it's less clear that trend selling will work past the middle of 2012 when the trend line crosses the attractor.

It will be interesting to wait and see how each approach works about one year from now. It would also be interesting to compare how well these two approaches would have done in terms of a portfolio that invested $1000 at the bottom in 2009. The trick would be to decide what the portfolio's "other uses of money" might have been!

Thursday, February 17, 2011

Worry, Worry: Steve Jobs Six Weeks To Live?













The National Enquirer (that's right) is reporting that Steve Jobs has six weeks to live (here). Stock analysts are keeping a level head in the face of this "news" (video above). One analyst on Yahoo Finance (here) downgraded AAPL from "Strong Buy" to "Buy" and another analysts upgraded the stock from "Neutral" to "Buy".

The stock was up to 364.90 yesterday but dropped down to the 358 area for most of the day today. The Random Stock Walker models (here) suggest that a stock price between 300 and 350 will be very close to the dynamic attractor for the next few months.

Monday, February 14, 2011

What's Different About High-Growth, Momentum Stocks?














Tonight on Mad Money (video above), Jim Cramer argued that growth or momentum stocks are in a unique class and have to be judged differently from other stocks. For example, Apple (AAPL), Chipotle (CMG) and Netflix (NFLX) are typically downgraded by analysts because their P/E ratios are to high, that is, they are too expensive.

Cramer's argument is that for these momentum stocks, what really matters is that the smart money (hedge funds and mutual funds) want to hold growth stocks. Regardless of price, you can ride the momentum of these stocks as long as you are willing to take profits after a good run.

What interested me about momentum stocks is their properties when estimated with the Random Stock Walker models. What I have found is that these stocks all have significant unit roots (growth dynamics) and their attractors are also significantly related to (being driven by) growth in the U.S. economy.
The bootstrap forecast using the USL20 model shows strong growth potential but also shows a strong downside (the lower 98% prediction interval).
Chipotle also has strong growth potential but does not have the same downside risk. The same is true for Apple.
The Random Stock Walker models suggest that Netflix, at least, should be viewed cautiously. Too bad! Netflix is a product I like although many analysts think it has a difficult future ahead given potential competitors.

ARM Holdings (ARMH) is also mentioned in the Mad Money video (above). It is different from the other momentum stocks Cramer mentions (AAPL, CMG and NFLX). I'll talk about ARM Holdings in a future post.

THEORY and METHOD There are some interesting issues here. It is very difficult, because of the unit roots, to clearly determine whether these stocks are random walks (P[t] = 1 P[t-1] + V), business-as-usual (pure momentum, P[t] = a P[t-1] + V, a gt 1) or stocks that are linked to growth in the U.S. economy (P[t] = a P[t-1] + b S[t-1] + V, a lt 1). The models look very similar using the Akaike Information Criteria (AIC). It is necessary to look at the bootstrap confidence intervals for coefficients in the US index models. All the stocks are significantly related to growth in the U.S. economy and the unit roots are removed from the model when the state variables for the U.S. economy are included.

Notice also that Cramer talks about normal stocks being "driven by news." In terms of the Random Stock Walker models, news is the variability term, V, in P[t] = P[t-1] + V.

Tuesday, February 1, 2011

Quick Update: Apple Computer

At 345.03 today (not quite back to the month high) the AAPL stock price is still close to its dynamic attractor for early 2011.
The bootstrap forecast and 98% confidence intervals show that the stock price might be outperforming a little.
The dynamic attractor line also suggests that there could be a small downward correction, but 345 is still pretty close in probability. For me, it still remains a time to hold.

Thursday, January 20, 2011

Another Bad Day for Apple: Buy, Sell or Hold?

It was another bad day for AAPL with the stock closing down 6.16% from Tuesday when Steve job's medical leave was announced. What to do, if anything? Karen Finerman, president of Metropolitan Capital Advisors, thinks it's a buy (here). Jim Cramer, CNBC Mad Money, thinks that AAPL had just run up too much for a "blowout" quarter to propel the stock any higher (here).
The logic of my systems models suggests that if AAPL is below the dynamic attractor (displayed above) it's a buy opportunity since the stock price should eventually be drawn back to the attractor. Stock prices above the dynamic attractor present an opportunity to take excess profits.

For the month of January 2011 (the finest resolution for my models), an AAPL stock price of 332.68 is very close the attractor value of 331.01 (just a little over, actually). The models suggest that the stock could fall a little further before presenting a buy opportunity. In fact, Apple stock would have a long way to fall to reach improbable lows (290 brackets the lower 98% bootstrap prediction interval).

DISCLAIMER: I'm holding my Apple stock, but that has less to do with the models than with a wait-and-see attitude. Steve Job's medical leave cannot possibly have any effect on company fundamentals for many months into the future. It's a good time to watch what traders do to the stock and compare future time paths with model predictions.

Tuesday, January 18, 2011

A Rough Couple of Days for Apple Computer

On news that Steve Jobs, Apple CEO, is going on medical leave, Apple Computer has had a rough couple of days in the stock market and generated lots of speculation in the press (here and here). At the end of trading today (above), AAPL was trading down about 1/2 per cent at 338.84. Still, many analysts remained positive on Apple, especially as a result of a record earnings report (here). On CNBC, Jim Cramer increased his price target to $400 from $325 (here). How does this relate to my initially pessimistic forecast for Apple (here)?
First, in Burton Malkiel's terms (here), Steve Jobs medical leave is truly random, unpredictable news. The negative shock to Apple Stock, however, is predictable. In terms of my original pessimistic forecast (here), notice that the forecast is based on data ending in January 2010. Using all of 2010 (above) I get a much more optimistic forecast.
The new attractor plot (above) shows the stock peaks as the major attractor points.
Just projecting the attractor into the future (rather than using the actual stock data) shows strong growth for Apple through 2020. Just to be clear, the graphic above is the result of a free simulation starting in September 1984 and going forward to 2020. A forecast (second graphic above) uses step-ahead predictions from the actual data for each month starting in September 1984. Once the data runs out (January 2011), the forecast data is used for the prior month's stock value.
Returning to Jim Cramer's $400 price target, the attractor forecast suggests that $400 is somewhat unlikely until well into 2011.

DISCLAIMER: I have held Apple stock since 1988. None of the forecasts presented in this blog should be used to make buy or sell decisions. The usefulness of the models and the forecasts will have to be evaluated at some point in the future. My particular interest is to evaluate the models in terms of the random walk hypothesis and Burton Malkiel's persuasive view of the stock market (here). At this point, the models merely say that AAPL is not a random walk stock. What that results means for stock forecasting is unclear.

Saturday, January 1, 2011

Will the Apple "Run Up" Continue?

For the first post on this blog, I thought I'd analyze one of the current market darling stocks, Apple Computer (AAPL). The analysis in the "Random Stock Walker" will be based on a simple idea: as an investment, you probably want to stay away from stocks that are a random walk (you can read more about the well-known random walk hypothesis here and here). On the other hand, you probably would want to own a stock that was strongly linked to the secular and/or cyclical growth of the U.S. or world economy (if you follow Jim Cramer on CNBC, for example here, you've probably heard this pitch before).

I have a statistical technique that can be used to tell whether a stock is a random walk or whether the stock is being driven by secular and/or cyclical trends in the economy. I have used the approach to analyze stock market bubbles (here) and a few stocks (GM--here and here--and Cummins, here). Let's see how it applies to Apple Computer.

Apple's stock price history and the step-ahead predictions of the best model are displayed above. The AAPL stock price is not a random walk (GM is) and is well-predicted by secular and cyclical trends in the US economy.
The Apple stock price is also affected by random events. If we eliminate error variation from the model and simulate the model (solve the model over time) from 1985, we get the graph displayed above. There were times when AAPL was over-priced relative to its long-run growth path (e.g., around 2000) and times when it was under-valued (2001-2005). Right now, AAPL is slightly over-valued. Will the stock price continue rising in 2011?
We can't know the future but we can run the model forward in time and add 98% bootstrap prediction intervals to the forecast (above). The model suggests that AAPL will return to a lower equilibrium growth path and remain there for the next few years.

DISCLAIMERS: Whether a stock is or is not a random walk might prove to be a useful screening device for drawing your attention to investment grade stocks, but the analysis and the forecasts I will provide in this blog are not meant to be used for purchase or sell decisions. For that, you will have to do a lot more homework about the company and consult the many other sources that are available on the Internet (here, for example).

My main purpose for starting this blog is to see, over the next year, how happy I am with the forecasts and analysis generated by the models. Hopefully, we can look back in a year or two and learn something about how skillful the techniques are.