Sunday, February 24, 2008

Financial Price Change Distributions 2

One index I never trade in is probably the most widely known index, the Dow Jones Industrial Average (^DJI) AKA the Dow 30 or just 'Wall Street'.

The reason I avoid it is because it is an average over the share price of each composite company. Each company's share of the index is not weighted by market capitalisation as is the norm for most other indexes. This means that a relatively small company's price can go up say 10% but cause the index to go up by a disproportionate amount. E.g. say it causes the index to rise by 2% but that the company is miniscule compared to the other 29 in the index. The overall market cap of those 30 companies has not risen by anything like 2%.

This oddity has always led me to believe there will always be a greater degree of randomness in the Dow than most other indices, and possibly some weird dynamics unique to the Dow (hmm, maybe there could be something to profit from there?) and thus to just avoid it in favour of some other large cap index such as the S&P 500. If the PE is high in the S&P 500 I feel a lot safer shorting it than I would the Dow, which I feel is more likely to spring a surprise on me, e.g. a small company (with a larger share than it's market cap warrants) posting strong results.

Following on from yeserday's post then, I was wondering if this oddball index exhibits a distribution curve significantly different to market cap weighted indices. Here is a graph comparing the daily percentage price change distributions for the Russell 2000, The Dow and the S&P500. For comparison the frequencies for the Russell 2k and the S&P are scaled up to match the DOW at its peak.





And let's have a peek at one of the tails.




Note that the blip in the Dow at about -22% is from the crash of 1929.


I did wonder if the extra random element (the arbitrary weighting) in the Dow would make it's curve a bit more gaussian, apparently not. Of course there is potentially a significant effect from the buying and selling of the Dow directly, through various derivatives. If we were to take 30 random companies from the S&P 500 and construct our own unweighted index using historic data would that index still have a Levy Skew alpha-stable distribution?

Saturday, February 23, 2008

Financial Price Change Distributions

I thought I'd try my hand at generating data that has some of the properties of real world financial data. My main focus right now is the Russell 2000 index, and so to get the ball rolling I thought I'd take a look at the distribution of daily price changes for that index.




Having read The Black Swan I was expecting that the distribution wouldn't be normal (the red line, using sigma calculated from the data). A fat tailed distribution makes a better fit, here I used the Cauchy Distribution for which there exists an analytically expressible probability density function, although Benoit Mandelbrot identified that changes in cotton prices fit a Levy skew alpha-stable distribution (of which the Gaussian and Cauchy distributions are specialisations) with alpha=1.7.

The key area of the graph is out on the extreme ends of the tails, so lets zoom in on the left hand tail.



We can see Mandelbrot's main issue with the normal distribution. The bumps to the far left in the raw data (the black line) represent highly improbable events if we are taking the data to be gaussian. Although the Cauchy distribution shown here is not a perfect fit (it is too high), it is a far far better model for those rare and extreme price movements. The normal distribution basically leads us to believe they will never happen in the lifetime of the universe, the Cauchy tells us to expect them once every few years. If you're betting your life savings on those rare events not occuring that's one hell of a difference.

The Numberwang Code

Mainstream culture is such a load of crap sometimes it can be pretty depressing. As a solution to this problem I can fully recommend poking fun at it at every available opportunity (and there are many). Fortunately Mitchell & Webb's new series this week got off to a good start in this area...






And of course Charlie Brooker continues to pump out satire from his south London sofa seemingly without pause...

Saturday, February 16, 2008

Trading Options in the Russell 2000

I'd be interested to here from anyone in the UK that trades options in the Russell 2000(^RUT). Currently I trade using using IGIndex but their list of options is limited and doesn't include the ^RUT.

There are a couple of good reasons for buying put options on the ^RUT that I can see.

Firstly the ^RUTs P/E ratio is currently higher than most other indices. It's hard to find good quality figures for the PE but there are some (conflicting) figures out there...

The Wall Street Journal gives a figure of 40 based on trailing earnings.
http://online.wsj.com/mdc/public/page/2_3021-peyield.html

The home site of the Russell indices gives PE ratios ex-negative earnings. Which IMHO is a pretty meaningless figure, but at least we know the true PE is no lower than this figure, currently quoted at 17.59.
http://www.russell.com/Indexes/characteristics_fact_sheets/us/Russell_2000_Index.asp

The IWM is an ETF based on the ^RUT, and google finance gives us PE ratios for the ETF of 5.59
http://finance.google.com/finance?client=ob&q=IWM

Forbes though quote 86.3
http://finapps.forbes.com/finapps/jsp/finance/compinfo/CIAtAGlance.jsp?tkr=IWM

And here's yet another figure from July 2007 (40.82):
http://www.proshares.com/funds/rwm.html?Index



Quite a mess huh. Another handle on this is to look at the yield, since dividends are (mostly) paid out of earnings. Figures for the yield are a little more in agreement and I take the figure from russell.com to be about right, that being 1.35%. If all earnings were paid out as a dividend that would give a PE ratio of 74. Ok, so we can safely say that the true PE (based on trailing earnings) is between 17.59 and 74.

My own belief is that the true figure for trailing earnings is around 40. Jeremy Grantham at GMO has briefly mentioned shorting the Russell a couple of times in his quarterly "Letters to the Investment Comittee" that can be downloaded from www.gmo.com. His argument has been that the ^RUT is a good proxy for small to midcap stocks, which have outperformed large cap stocks since 2003. In times of falling profits it will probably be the blue chips that do well owing to their greater exposure to international trade and existing capital investment and infrastructure. A flight from riskier (lower or no profit) stocks to less risky stocks (good profit margins) would suggest a shift away from the Russell 200o to larger companies and thus indices such as the S&P500, Russell 1000 or the Dow. Indeed the recent falls have been more pronounced in the ^RUT than those other indices.

Essentially there is further down to fall for the ^RUT so we can expect more profts from buying puts or shorting as the PE reverts to mean. The next question then would be - What is the mean PE for the ^RUT?

Sunday, August 19, 2007

Netflix Prize: Feature Output Error Curve

I wanted to fill out some details surrounding what might be best referred to as the feature output error curve , mentioned in Brandyn Webb's (AKA Simon Funk) now well read blog post over at http://sifter.org/~simon/journal/20061211.html. He refers to this as the output-output curve or the output vs target output curve.

Having completed training on a feature we can simply apply this feature to the residuals matrix and start training the next feature. However, it turns out that a feature has a 'shape' and that shape can be found by plotting a graph with predicted rating along the X-axis and the mean error on the Y-axis. This is the mean error of all predictions of a given value. In reality of course we have to group predictions into small ranges on the X-axis in order to be able to calculate a mean for that group. By error here I am meaning the offset from the prediction and this includes both negative (prediction was too low) and positive (too high) numbers.

Here is such a graph from one of my own experiments for the first feature. The red line is the curve for probe ratings, the black line is the same plot for training data ratings. Oh and for reasons that even I myself am not sure of I rebased all of the ratings into the 0-4 range, instead of 1-5. Apologies for any resulting confusion!

As I said, Brandyn actually refers to a predicted vs target rating output curve, which is basically the same as the above plots but presented in a form that allows you to map directly from a predicted rating to an adjusted rating (more on that later), it is the above plots but with the offsets subtracted from x, (we subtract the offsets from the line y=x).


As you can see, this form shows the kinks at the ends of the plots that Brandyn mentions, but the overall shape/detail of the curves is less clear.

I should also point out at this stage that Brandyn was probably referring to the ouput of the feature vs it's target output (e.g. +1 will get us to the correct rating, but the feature generated +0.5), whereas I'm referring to the current best prediction (based on the current residuals plus the output of the current feature) vs the target prediction - so the residuals may contain a 3, the feature generates +0.5 and the target rating is 4. It all amounts to the same thing, viewed from slightly different perspectives, 'tis all.

Going back to the first graph then. It shows us that low predictions tend to be too low, and high predictions tend to be too high. So when we apply our feature to the residuals matrix we can pass our predictions through this graph, apply the appropriate offset and achieve a better RMSE on the residuals matrix (eliminate more error).

If you don't apply the offsets then the curve actually remains in the residuals matrix, quite possibly disrupting the discovery of features later on. You can however re-calculate the feature output error curve for a residuals matrix at any time and extract the corresponding amount of error.

One interesting observation is that if you apply such a curve after each feature, then the curve gets less and less prominent, eventually becoming more-or-less flat apart from a bit of noise. Brandyn therefore decided to not calculate this curve after 20 features or so. However, if you plot the curve after 20 features of not applying any offsets then you can see that a curve has re-emerged, and applying the offsets to the residuals matrix as before will reduce RMSE. This re-emergence is I assume the result of the accumulation of many faint curves, individually they are lost in the background noise, but together they become prominent again. On this basis I choose to apply the curve for the first 20 features (as Brandyn) and then again every 20. Perhaps I should just keep applying a curve at each feature?

But what of the two plots in each graph? One is plotted for the probe set predictions and one for the training set. In the above plots the train set plot (black) has a more prominent curvature than the probe. This means that if you remove the train set curve you are over-adjusting the probe predictions (residuals), or if you apply the probe curve you are under-adjusting the training residuals. I suppose you could apply the two curves to their respective residuals, but as a general rule I think that we should consistently apply functions to both sets of residuals to prevent them becoming separated in some way - maybe that instinct is wrong. Also, when training on the full set you do not have any set that is akin to the probe set, you have the qualifying set, sure, but you don't know the target ratings (that is the whole point of the contest!) which are required to calculate a feature output error curve.

Another option, and one I have used to generate a quiz submission, is to store the curves generated for each feature against the probe data, and to the then apply those same curves during SVD on the full data set. This on the basis that those saved curves will more closely represent the curve that would have been generated by the qualifying set if we had access to the ratings. Hmmm.


A loose end...

If like me your maths is a bit rusty [or in my case it was never that shiny in the first place ;) ] then you might be thinking - why did we take the mean error at each point on the x-axis? We are trying to reduce squared error (E^2) , not error (E) and thus applying an offset to the predicted ratings as described, although lowering E may in fact increase E^2. Hmm, well no. This is one of those things that some might find intuitively obvious, but I wasn't really sure until I worked through the maths. If you have a list of numbers and you can apply an offset to all of them and you want to get the lowest possible total sum(V), well then obviously you subtract the mean. And as it happens the same is true of sum(V^2), just subtract the mean. ------ no no no! see comment below!