Sunday, May 11, 2008

Moving to LiveJournal

Going to trial LiveJournal. Admittedly the ads are a bit annoying if you're a non-paying user but not too bad. Also I like the way you can surf through people's friend lists in LJ, it seems to foster a bit more of a community spirit. Blogger in contrast seems to be a zillion unconnected blog islands.

Anyway you can catch me over at http://the-locster.livejournal.com/

Sunday, April 13, 2008

Food Crisis

It seems attention is shifting fairly rapidly from the financial crisis to the food crisis:

Grains Gone Wild
World Bank Leader Urges Action on Food


There are many factors in play here but, as in the financial crisis, complacency and poor judgment are major factors, specifically the allowing of stockpiles to dwindle on the basis that risk was/is spread (financial parallel: allowing of capital cushions to dwindle). This on the basis that if one country's harvests fail then they can simply import from another, or, if one mortgage fails then the impact is diluted by the remaining good mortgages. Umm yeh.

Both systems have exhibited the same flaw which is that risk estimation was based on uncorrelated entities/phenomenon/whatever cancelling each other out, whereas in times of crisis those correlations can break down, and break down in unpredictable ways - often the uncorrelated entities become strongly correlated, why? precisely because they were modelled as being uncorrelated. Such a model, when acted on by governments actually connects the uncorrelated entities - e.g. we need A or B, reduce stockpile of both because we know we will always have one or the other. Both fail, e.g. crops in Oz and continued cheap oil. Now no-one has adequate stockpiles so prices of A and B go up - they become correlated. And when supply is stretched to the limit for a must have resource, then prices can spike dramatically as the poorest people get priced out of the market (or starvation as it's otherwise known when dealing with food supply).

'Clever' mathematical modelling is not a substitute for reserves both in banking, food supply and any other system critical to our security and livelihood.


Ok so Mr. World Bank is calling for funding to lessen tensions in Haiti and elsewhere. Maybe I'm misunderstanding basic economics here but they don't need money, they need food. If we give them money they will buy food on the open market, the price will go up and the next poorest country/purchaser is priced out of the market. There either is enough food for everyone or there isn't, no amount of money is going to change that in the short term. Unlike the financial crisis we cannot just inject new fodo into the system like the Federeal Reserve 'injects' cash. Cash as abstract, food is real.

Monday, April 7, 2008

Shorting Opportunity?

IMHO the recent rise in the markets is just teetering on the edge of sanity right now. Let's take a look at a 2 year chart of my favourite index, the Russell 2000:




Out of context it might be reasonable to assume that a bounce back up to last summer's highs are a real possibility. OK but:

(A) The US economy is largely recognised to have been either in or very near recession in Q1.
(B) Q1 earnings reports are nigh.
(C) The Russell 2000 is currently sporting a dividend yield of 1.42%. (Umm, that's less than inflation folks)
(D) The credit markets are still in disarray and are shrinking.
(E) Property prices *are* falling. The credit crunch isn't just some ethereal event occuring in financial cyberspace, it's affecting 'Real People, Right Now'(TM).

The latest tick upwards in the markets is interesting but certainly not yet outside of 'control limits', for me alarm bells are not ringing. IMHO this is about as good as it gets as far as shorting or put option buying opportunities go, we're certainly not going to be seeing rising profits from ^RUT companies anytime soon + a continuing recession seems very likely indeed + stocks are still overpriced despite the fall from 2007 peaks. The recent move upwards has simply put some juice back into shorting opportunities.

Saturday, March 29, 2008

Good Practice in (Pseudo) Random Number Generation for Bioinformatics Applications

From http://www.cs.ucl.ac.uk/staff/D.Jones/GoodPracticeRNG.pdf

-----------------
Note that all of these standard generators have been shown to have serious defects:
Standard Perl rand
Java.util.Random
C-library rand()
Matlab’s rand
Mathematica’s SWB generator
-----------------

George Marsaglia's KISS algorithm is given the thumbs up, Microsoft dotNet's Random class isn't mentioned almost certainly because it isn't used much in academia - and as I've already discussed here, that algorithm cannot be re-initialised quickly and KISS is alomst certainly going to be faster anyway. Though not quite as fast as XOR-Shift.

Fractional Brownian Motion

Click on the images for larger versions.


Brownian Noise


Fractional Brownian Noise


Brownian Motion


Fractional Brownian Motion


Each plot shows 8000 samples. As the number of samples increases (as we zoom out) the brownian noise plot looks increasingly like a solid bar with straight edges, whereas the Fractional Brownian Motion(FBM) plot exhibits self-affinity, meaning it looks the same at any magnification (barring magnifications below a lower threshold).


FBM data was generated using the Hosking method with a Hurst parameter (H) of 0.7. For source code and an excellent thesis on FBM generation see:

http://www.proba.ucc.ie/~td3/mastersthesis/


The Hosking method is an exact method and as such has time complexity of O(N^2). The reason for this is that FBM exhibits long term dependence and therefore each new sample is dependent on all previous samples. Faster approximate methods exist, which is largely the subject of the linked thesis.

The hosking.c file was ported to C# and ranlib was substituted with this project which contains a NormalDistribution class:

http://www.codeproject.com/KB/recipes/Random.aspx

Thursday, March 27, 2008

World Community Grid Research + Climate Rant

Nice to see some research papers using data from WCG projects:

HPF2 Progress and News

I've always been a bit skeptical about the quality of the research behind some of these projects. E.g. a seemingly knowledgable poster on slashdot claimed the 'Help Conquer Cancer' project were using a grossly inefficient and sloppy technique. I was sufficiently convinced to switch off that particular project.

Despite my doubts I still feel overall that this sort of research (protein folding and interaction predictions) is a better use of CPU resources than the SETI or climate change modelling. Having said that I like the idea that SETI is running, but maybe the balance is wrong.

As for climate change, well I have many issues here. But ultimately I think we need to just look at the big picture (at the political level) and say, y'know we don't and can't know what is happening and to what degree CO2 and other emissions are responsible. We should (I would suggest) be attempting to minimize our modification of the atmosphere and thus minimize the probability that we invoke some change with detrimental consequences.

I seriously doubt that progress will be made on CO2 emmissions, and having spent the last few weeks reading about fractional brownian motion I'm also beginning to realise that the data we have is a very small set of samples from which very little can be derived mathematically. What we do know is that billions of tonnes of CO2 will have *an* effect and anything that rocks the boat is probably going to be bad for something or someone given that so much life on this planet, human or otherwise, teeters on a knife edge.

Sunday, March 23, 2008

UK House Prices as Multiple of Average Earnings

Ok I keep going on about this metric so I had a dig around the internet for the raw data and here then is the finished product.



Surprisingly then the multiple is currently aprox. 7.38, wow. Also I hand't realsied that the graph for the UK has yet to start falling. The data here goes up to the end of 2007 at which time the price was still rising. This graphs looks pretty 'toppy' though to my eyes.

A similar, but not directly comparable graph GMO drew for the US in Januray shows median home price over median family income. That multiple has a mean at 2.8, peaked at 3.9 in 2005 and had fallen to 3.7 by the end of 2007. So the fall has been going on sometime across the pond.

Note however that the national US picture doesn't do justice to the extent of the bubble in specific regions, or specifically what Paul Krugman refers to as zoned areas (where land isn't in inexaustible supply) in this video...



Along with the TED spread this is one of those graphs that will take pride of place as part of my 'economic radar'.


===========================================
Earnings data going back to 1952 was found here:
http://www.measuringworth.com/ukearncpi/

Unfortunately the numbers were rebased to 1913=100, so then I had to dig out some figures dealing in real unadjusted pounds from the ONS, e.g. from here.

http://www.statistics.gov.uk/cci/nugget.asp?id=285


And the house price data going back to 1952 came from this lovely resource at the Nationwide:

http://www.nationwide.co.uk/hpi/historical.htm

Idle Thoughts on Correlations With House Prices

I have a few ideas I want to write down with the intention of filling out details in later posts.

1) Residential Property Prices as a Multiple of Income.

Jeremy Grantham, Chairman at GMO (www.gmo.com) uses this metric often in his 'Letters to the Investment Committee'. In the UK the mean residential property price is currently about 6x mean salary. The long term multiple is around 3.5 and plotted on a graph this metric screams bubble and has been doing for the last few years.

The thinking behind this metric is simple - that the value of a house is strongly related to (and ultimately bound by) how much people can afford. That said, multiples greater than the number of years typically worked can't be completely ruled out if we allow mortgages to be handed down through generations. OK, but the only reason to do that is if the holder thinks that house prices are going to substantially increase in value over time, over and above inflation and personal earnings growth. Since we can always build new houses (where there is land available) that doesn't seem to hold - house prices will always be related to replacement cost.

A casual observation here is that the multiple of six is close to the reported multiple of 5x salary used by some mortgage lenders up to the sub-prime crisis kicking off. Typically a lender will calculate the maximum amount they are willing to lend using a multiple of 2.5 to 3. The gradual shift up to 5 was symptomatic of the disconnection going on in the debt markets between percieved or calculated risk and actual risk.

Now that salary multiple is a pretty crude calculation anyway. At the very least they could subtract tax and some basic cost of living from the gross salary and then assign a new multiple to what remains. In fact a glance over some mortgage web sites shows what they actually do is use different multiples depending on a small set of salary ranges. Better but still pretty crude considering this is a fudge to avoid doing some basic algebra here guys. No doubt more accurate calculations are performed in the 'back office'. Well maybe.



2) Employment Rates.

I need to check this out in more detail but I've read that another correlation exists between employment rate and property prices. Easy to see for sure, the economy slows, people lose jobs and ability to pay a mortgage. Or at least there are less new buyers around. Perhaps a stronger correlation would be found between total employment level rather than employment rate, since we are currently (in the UK) taking in many overseas workers, all of which add to demand for existing housing stock. You could argue that the construction industry expands along with the working population and demand, sure, but there is some lag there I would say. It also raises the possibility of recent immigrants swiftly departing the UK on an economic downturn, reducing demand for accomodation fairly sharply.


3) GDP per head.

This is related to the above comments about employment rate versus employment level. Last week The Economist discussed how GDP per head is often a very different number from overall GDP. E.g. Japan's GDP per head is actually very strong due to a shrinking population, The US on the other is already in a recession on the per head scale because of a rising population through immigration.

Tuesday, March 18, 2008

Debt Not Correlated With Economic Growth: News at 11

More wisdom from one of my favourite economic commentators...

Interview with Jeremy Grantham, Chief Investment Strategist, GMO


So if debt doesn't create growth then why the heck have we been allowing debt to grow so substantially? Where is the intellectual rigour in these decisions? either to actively engage in the issuing of more debt (banks) or to sit by and allow it to happen (governments)?

The UK government is one of the most indebted as measured in % of GDP despite record economic activity, bumper tax income and super low unemployment rates. They have inflated the public sector's slice of GDP and (assuming a recession is nigh) will have to either (A) take on much more debt to pay all of those public workers in the next few years or (B) make massive public sector cuts. They have absolutely no cushion for this potential recession, as far as I'm concerned they have been grossly irresponsible. No doubt they will say that no-one could have predicted the coming recession, well, umm actually, dunno if you'd noticed chaps but they kinda happen every few years.

3684 Days to The Robot Uprising

From the 'very cool but ever-so-slightly unnerving' deptartment...





Something about the leg shape and the buzzing noise from the (I assume) petrol engine just made me think - giant mutant wingless fly . Probability that this will feature in a nightmare tonight, ummm about 95%.

Sunday, March 2, 2008

Selective Acquisition of Knowledge

Experiment. Take a 'basic' piece of knowledge, oh I don't know, let's say the fact that the Moon revolves around the Earth. Where did this knowledge come from? And how widely dispersed/propagated is it through, umm let's say the population of France?

Who wants to be a millionaire clip

To summarise, the guy is asked "Qu'est-ce qui gravite autour de la Terre?" (What revolves around the Earth?), The Moon, The Sun, Mars or Venus. He answers The Sun after an audience poll yielding 56% for the Sun, 42% Moon and 2% for Mars.

Those numbers need qualifying and cleaning up a little. First up, we have to consider that more than 58% didn't actually know the correct answer, there may have been some who did not know and just picked an answer at random, some right, some wrong. Note however that the quizmaster says not to feel obliged to answer. On the other hand there is pressure in situations like this to not look stupid - so you just press a button anyway (potentially).

I also just want to address the more pedantic readers out there in internetland - it is of course more correct say that the Moon and Earth rotate around their common center of gravity(barycenter), but that center is within the body of the Earth and so it's not an unreasonable question to ask in a general purpose quiz. OK? Certainly this guy wasn't struggling trying to work out what is meant by 'revolve' - does that word have a different meaning in real space-time than in Euclidean space? hmmm.


So anyway, at least 58% of that audience were not in possesion of this particular piece of knowledge. It doesn't appear to be a core, commonly known fact in French society (and mostly likely others), like say 1+1=2 (this is an assumption). And yet there is this large shimmering, fairly prominent silk cresent in the sky. It wouldn't be unreasonable to have assumed that most people would have looked at it at some time and wondered what it was and made enqiries. Consider this versus some obscure fact deep in some specialist research paper, why would most people know about that? What would the hook or lead be that led them on an a path of enquiry to it? The path to the fact is more tenuous and arduous and therefore we could expect most people to be oblivious to it.

So what is it that determines which pieces of knowledge become widely known, given that the moon is misunderstood despite being so prominent? Most probably it comes down to the fact that a given human's primary purpose in life, whether they know this or not, is to propagate his/her genetic makeup into the future. Learning all of this pesky knoweldge stuff is just a necessary cost of achieving that goal, and the knowledge that assists most on that quest is that related to society - it's structure, who has what power and skills(rather than aquiring all of the skills yourself), who to trust, and of course evaluating potential mates - in the traditional sense of the word :)

We are bombarded with senory input conveying vast quantities of information from which we could infer and deduce vast quantities of knowledge if we had the time and perseverance, but doing so would be sub-optimal with regard to the task of propagating our genetic sequences into the future. We are programmed to notice some features and to think about some aspects of the physical world moreso than others.

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?