More colour wheels

In response to my post about colour wheels, I received a suggested enhancement from Drew. The idea is to first match colours based on the text provided and then add nearby colours. This can be done by ordering colours in terms of huesaturation, and value. The result is a significant improvement and it will capture all of those colours with more obscure names.

Here is my variant of Drew’s function:

col.wheel <- function(str, nearby=3, cex=0.75) {
	cols <- colors()
	hsvs <- rgb2hsv(col2rgb(cols))
	srt <- order(hsvs[1,], hsvs[2,], hsvs[3,])
	cols <- cols[srt]
	ind <- grep(str, cols)
	if (length(ind) <1) stop("no colour matches found",
		call.=FALSE)
	s.ind <- ind
	if (nearby>1) for (i in 1:nearby) {
		s.ind <- c(s.ind, ind+i, ind-i)
	}
	ind <- sort(unique(s.ind))
	ind <- ind[ind <= length(cols)]
	cols <- cols[ind]
	pie(rep(1, length(cols)), labels=cols, col=cols, cex=cex)
	cols
}

I have included an additional parameter, nearby, which specifies the range of additional colours to include. A setting of 1 will include colours matching the specified string and also one colour on either side of each of these. By default, nearby is set to 3.

The wheel below shows the results for col.wheel(“thistle”, nearby=5). As well as the various shades of “thistle”, this also uncovers “plum” and “orchid”.

"Thistle" wheel

This is far more powerful than the original function: thanks Drew.

Colour wheels in R

Regular readers will know I use the R package to produce most of the charts that appear here on the blog. Being more quantitative than artistic, I find choosing colours for the charts to be one of the trickiest tasks when designing a chart, particularly as R has so many colours to choose from.

In R, colours are specified by name, with names ranging from the obvious “red”, “green” and “blue” to the obscure “mintycream”, “moccasin” and “goldenrod”. The full list of 657 named colours can be found using the colors() function, but that is a long list to wade through if you just want to get exactly the right shade of green, so I have come up with a shortcut which I thought I would share here*.

Below is a simple function called col.wheel which will display a colour wheel of all the colours matching a specified keyword.

col.wheel <- function(str, cex=0.75) {
	cols <- colors()[grep(str, colors())]
	pie(rep(1, length(cols)), labels=cols, col=cols, cex=cex)
	cols
	}

To use the function, simply pass it a string:

col.wheel("rod")

As well as displaying the colour wheel below, this will return a list of all of the colour names which include the specified string.

 [1] "darkgoldenrod"        "darkgoldenrod1"       "darkgoldenrod2"
 [4] "darkgoldenrod3"       "darkgoldenrod4"       "goldenrod"
 [7] "goldenrod1"           "goldenrod2"           "goldenrod3"
[10] "goldenrod4"           "lightgoldenrod"       "lightgoldenrod1"
[13] "lightgoldenrod2"      "lightgoldenrod3"      "lightgoldenrod4"
[16] "lightgoldenrodyellow" "palegoldenrod"

"Rod" colour wheel
In fact, col.wheel will accept a regular expression, so you could get fancy and ask for colours matching “r.d” which will give you all the reds and the goldenrods.

This trick does have its limitations: you are not likely to find “thistle”, “orchid” or “cornsilk” this way, but I have found it quite handy and others may too.

*My tip was inspired by this page about R colours.

Melbourne Cup

I have been resting on my laurels for too long. Two years ago I had Shocking success tipping a winner for the Melbourne Cup. Needless to say the analysis was entirely bogus, but it was fun. Since then I have been reluctant to tarnish my spotless prediction record, but fortune favours the brave, so I really should try again.

Inspired by my last analysis, The Hoopla is tipping Lost in the Moment, which is a 5 year-old bay horse starting at barrier three and is carrying 53 kg. Unfortunately, my statistics tell me that over the last 150 races going back to 1861, there have been five Cups in which a horse with three words in its name has won, but never one with four words. That does not bode well for Lost in the Moment.

I will not give up entirely on a good formula, so based on the analysis from two years ago, I would still like to tip a bay horse with a handicap in the 50-55 kg range starting in the barrier range 1 to 5. This time, however, I will take into account the fact that over half of previous Cup winners only had a one-word name.

Three of the horses in barriers 1 through 5 have a one-word name, and they are all carrying around 53 kg:

  • Illo
  • Precedence
  • Modun

According to this form guide (which is the only one not blocked at my place of work, which limits access to “gambling sites” and yet is doubtless hosting many Melbourne Cup festivities), Precedence and Modun are geldings, which rules them out (they come second to horses in the chart below).

Horses

So: the Stubborn Mule tip for the 2011 Melbourne Cup is Illo.

For anyone foolish enough to take heed of this tip, I appreciate it, but you are foolish.

UPDATE: after a good run for much of the race (always a bad sign) Illo failed to win or even place. So it seems that the Mule has lost his crown.

The oldest bank in the world

Yes I am back. I know it has been a while. What can I say? I have been quite busy!

One of the things taking up my time during the week was preparing for and then giving a talk for the Q-Group on operational risk capital modelling. It sounds arcane, I know, but there was one exciting part: I had the opportunity to try out the simulated laser pointer that you can create by pressing your finger on the screen of the iPad during a Keynote presentation.

Since regulators expect banks to use their capital models to quantify 1 in 1,000 year losses, I slipped a reference in my presentation to the Italian bank Monte dei Paschi di Siena which, having been founded in 1472, is a mere 539 years old. The somewhat oblique point was that no-one should take these models too seriously.

Monte dei Paschi

Monte dei Paschi di Siena

It was an ironic twist that evening that this was headline on the front page of the Wall Street Journal website:

Siena Headline (II)

It seems that Monte dei Paschi di Siena was one of a number of banks suffering as a result of the European sovereign debt crisis and it makes an interesting case study of the challenges of the business of banking.

Back in the original days of the global financial crisis, the banks that got into the most trouble were the ones with significant exposure to “toxic assets” (US mortgages, mortgage-backed securities and their ilk). Once people started to worry about these toxic assets, the problem was that no-one really knew how much exposure any given bank had to these assets and so no-one wanted to lend to anyone else. Since many banks (including Australian banks) rely on wholesale debt markets (i.e. they borrow money from big institutional investors around the world like pension funds), this became a problem for everyone.

Back then you might have thought that a regional bank like Monte dei Paschi di Siena would be fairly immune to what was going on, but it got off to a bad start in the crisis by acquiring another bank, Banca Antonveneta in 2007. In retrospect (and even at the time in the eyes of some analysts), it paid too much and over-extended itself at the wrong time. Within a couple of years, its capital buffers had become so thin that it was forced to turn to the Italian government for a capital injection and also cut its dividend payments right back in an attempt to rebuild. This was painful for Siena because, in a peculiarity of Italian banking, the majority shareholder of Monte dei Paschi di Siena is a charitable foundation, originally established in the 1990s for the express purpose of acquiring the bank when banks across the country were being privatised. This foundation makes donations to all sorts of public groups across the city of Siena and, with the dividend cut, the donations stopped too.

To make matters worse, the bank is a large holder of Italian government bonds, which have not been performing particularly well of late. With a capital base of €7.1 billion (figure as at April 2011), it held €32.5 billion (figure as at December 2010) in Italian government bonds and so any decline in value of Italian government bonds put pressure on the bank’s capital. In mid-2011, in the face of the European debt crisis, the bank decided it needed to further bolster its capital position. But the foundation did not want to lose its majority share-holding, so the foundation turned to JPMorgan and Goldman Sachs (aka the vampire squid) to borrow money to buy new shares issued by the bank. Unfortunately the loans were secured by shares and as the share price continued to fall, the foundation had to hand over more shares to its lenders. If things do not improve, the foundation is likely to be forced to sell more shares, ultimately losing its majority stake in the bank. The foundation, which once made around €250 million a year in donations to the city, is not looking likely to be able to contribute nearly as much to the public good in the future.

Will this venerable bank be the first to survive for 1,000 years? It has not failed yet, but the immediate future still looks rather shaky.

What will the Reserve Bank do this week?

It has been a while since I have had a Reserve Bank poll here on the Mule. The Bank will be sitting down on Tuesday to decide whether or not they should adjust monetary policy. Westpac chief economist, Bill Evans, was the first of the bank economists to start predicting that the next move in the cash rate would be down back in July. Since then, some other economists have come around to Bill’s perspective, particularly given the global financial chaos as European banks face a slow-motion bank run. Others are still expecting that the Reserve Bank’s bug-bear, inflation, will remain sufficiently threatening to ensure that the next move in rates is up. But perhaps it is too soon for the Bank to do anything at all.

What do you think? Get your vote in before the announcement is out at 2.30pm on Tuesday (Sydney time).


UPDATE: the results are in and Mule readers got it right: 93% of respondents thought there would be no change in cash rates, which was indeed the case. No-one predicted a rate rise.

Ring-fencing rogue traders

Kweku Adoboli managed to cost UBS over $2 billion with his rogue trading, and has now cost chief executive Oswald Grübel his job. While this time the buck stopped at the top, it is more than can be said for many previous rogue trading cases. Grübel was called out of retirement to take the helm of UBS as it faced the global financial crisis, so perhaps a return to retirement was an easier choice than it would have been for the chief executives of Société Générale, NAB*, Allied Irish and other past victims of rogue traders.

But what has surprised me about this latest rogue trading incident is reactions like this one from the Economist:

For UBS and its shareholders, the immediate questions should be why it was still vulnerable to this sort of alleged manipulation more than three years after Mr Kerviel’s [the Société Générale rogue trader] loss.

Of course banks are aware of the risk of rogue trading, but it does not mean that protecting themselves against this risk is a simple matter. Trading businesses are complex, with many interconnected computer systems, some old, some new, most dealing with transactions in real time. It is a case of asymmetric warfare: the bank has to defend itself against every possible attack, but the rogue trader only has to find a single point of weakness. The UBS loss may be another reminder for banks of just how much an insider can cost them, but I am confident that there will be another spectacular rogue trading case within the next five years.

Little wonder then that Sir John Vickers, in his report on UK banking, has recommended that banks should “ring-fence” their investment banking operations (including financial markets trading businesses) from their retail and commercial banking arms. The idea is that, while governments will always want to protect the financial system that is so central to their economy, tax-payers should not end up on the hook for losses arising from risky investment banking activity.

Banking regulators around the world have been intently pursuing ideas like this over the last couple of years and the Adoboli case will only add to their determination to impose some form of “recovery and resolution” framework on banks. Before this work is complete, I would not be too surprised if UBS have spun off their investment banking arm. It is becoming all a bit much for Swiss shareholders to cope with.

* UPDATE: My memory served me poorly: the CEO of NAB, Frank Cicutto, did in fact resign after their FX trading fraud.

Unblock Us

A few months ago, I complained that more and more online music sites have blocked access from Australia. Of course, the arcane licensing of intellectual property has also led to many other sites being blocked for Australians. Anyone living down under trying to access BBC TV via their iPlayer, or trying to stream US TV on Hulu will find themselves out of luck. The list of sites offering movies, TV shows and music online is a long one. The list of these available in Australia is a very short one.

However, I have now discovered a Canadian company offering one way out of these geographic shackles. For US$5 per month, Unblock Us will allow you to configure your computer or router so that, when you try to access a selection of media sites, your connection will pop out from a server outside Australia so as to ensure you will not be blocked from accessing the site.

But is it legal? That’s an excellent question, and one I do not know the answer to. Not being a lawyer, I will not even speculate. Where I am happy to speculate is on the question of the ethics of the site.

On Friday, a colleague said he was planning to watch a downloaded movie over the weekend. I asked him where he had downloaded it from. While he said he had bought it from the iTunes store, he did indicate that was not the only place he had downloaded movies from over the years. His philosophy was always to try obtaining movies legally first but if—and only if—all legal means failed, he would resort to shadier sources. To me, this seems like a fair approach, legal or not.

As I would be more than happy to pay the copyright holders for access to e-books, online music or videos, I find it extremely frustrating when this is impossible, simply because I am in Australia. In the absence of such legal means, loopholes like Unblock Us start to look very appealing.

There are a couple of other considerations before leaping in to using the service:

  • Privacy: since your internet requests would be initiated through Unblock Us, you would have to be comfortable with them knowing about the pattern of your internet usage, although they do note on their site ” will not actively monitor user activity for inappropriate behavior, nor do we maintain direct logs of any customer’s Internet activities”.
  • Performance: having the extra check for each internet request to see whether it should be bounced through Unblock Us could make your internet performance a little slower than going directly through your ISP. I do not know whether this would be significant.

I am certainly tempted.

Dissonance and Debt

Ever since Standard & Poor’s downgraded the US government from AAA to AA+ I have been drawn into debates about the risks posed by growing US government debt. Ever since reading the book Mistakes Were Made by Carol Tavris and Elliot Aronson I have been fascinated by cognitive dissonance and as my debt debates kept following the same pattern I became convinced the explanation for this pattern lay in cognitive dissonance. Coincidentally, I then read a post by Bill Mitchell discussing a paper by Adam Kessler analysing the views of mainstream economists in terms of cognitive dissonance.

For those as yet unfamiliar with the concept of cognitive dissonance, it refers to the discomfort people feel when faced with conflicting information. The brain tends to react to cognitive dissonance by quickly eliminating the conflict and restoring consonance.

One of many examples of cognitive dissonance in Mistakes Were Made arises when people with prejudices are presented with evidence that contradicts their prejudices. Tavris and Aronson quote Gordon Allport, who wrote The Nature of Prejudice over fifty years ago. Allport illustrated a typical pattern of dissonance-blocking in the following dialogue:

Mr. X: The trouble with Jews is that they only take care of their own group.

Mr. Y: But the record of the Community Chest campaign shows that they give more generously, in proportion to their numbers, to the general charities of the community, than do non-Jews.

Mr X: That shows that they are always trying to buy favor and intrude into Christian affairs. They think of nothing but money; that is why there are so many Jewish bankers.

Mr Y: But a recent study shows that the percentage of Jews in the banking business is negligible, far smaller than the percentage of non-Jews.

Mr X: That’s just it: they don’t go in for respectable businesses; they are only in the movie business or run night clubs.

Time and time again Mr X. shakes off contradictions to his prejudice with a non-sequitur, responding with a completely unrelated argument in support of his prejudices. My conversations about US debt have been eerily similar:

Me: This Standard & Poor’s downgrade is a bit silly. The US has got past the farce of the debt-ceiling and, unless they choose to default next time they run up against that ceiling, their debt is much safer than euro sovereign debt from the likes of Greece and Ireland.

Mr. Z:  But they’ve just kicked the can down the road. Unless they do something about their deficits and cut all their entitlement spending, they are basically bankrupt.

Me: But the US government is effectively the monopoly issuer of US dollars and all their debt is denominated in US dollars: they cannot run out. So, they never have to default, unless their crazy politicians choose to.

Mr Z: Oh, sure, they can fire up the printing presses and simply print money, but that will always be inflationary.

Me: What about Japan? They ran deficits and their government debt has been growing for years and that hasn’t led to inflation. In fact, they could do with a bit of inflation, but have been unable to generate it. Government deficits will only be inflationary if the government is spending at the same time as the private sector and is overheating aggregate demand.

Mr Z: But Japan has been a basket-case for years, no-one would want the US to end up like Japan!

See the similarity? Almost every time I try to make the point that countries which control their own fiat free-floating currencies and only borrow in that currency (such as the US, UK, Australia, Canada and Japan) can never be forced to default on their debt, the conversation quickly veers away to inflation, Japan and anything but the central point. That’s cognitive dissonance for you.

 

Off the rails: mag-lev personal rapid transit

I have not been thinking about blog posts much over the last week and a half: on the 11 August my closest friend died and his memorial service was a week later. However, I have received a guest post from a new contributor to the Stubborn Mule: Norwegian academic Trond Andresen from the Norwegian University of Science and Technology. I met Trond last year at the CofFEE conference in Newcastle where he was spending time pursuing his research interests in macroeconomics. However, as will become evident in the post below, Trond also has other rather different academic interests and was inspired by the recent Train in Vain post, to write about a rather radical alternative to high-speed rail.

I am a Norwegian control systems lecturer recently back from a ten-month sabbatical in Newcastle. I have had one-year stays in Australia on two earlier occasions. My first stint was in Sydney 1997-98. I then experienced the city’s grave congestion and environmental problems due to car traffic. Thirteen years later it is even worse.

I have also tried the very slow railway service between Newcastle and Sydney. It hasn’t improved either. From 1997 I remember the debates about intercity high-speed rail and magnetic levitation trains. But this didn’t lead to anything.

Today however, there exists a new and proven – but largely unknown – technology that in one go can solve both the in-city and intercity transportation problems, and it is much cheaper than high-speed rail. That technology is maglev-based personal rapid transit (M-PRT). Computer-controlled small two-person streamlined pods run on a guideway six meters above gound. The guideway is carried by utility poles. The structure is very slender and much less intrusive than the Sydney monorail, because each pod weighs maximum 300 kg. It may be quickly erected along some main thoroughfares, and gradually extended to create a dense city network. One will not anymore depend on a few large stations, but can instead access the system at any of the many hundreds of network nodes (resembling elevated bus stops) you will have in a city like Sydney. A pod hangs under the guideway, and slides along it without wheels and no contact; an extension of the pod inside the guideway levitates it by magnetic repulsion. This is a new, simpler and cheaper type of maglev technology than that used in the very expensive German Transrapid, which was part of the Australian debate in 1997.

Maglev and the absence of wheels give two crucial advantages: very low maintenance requirements, and speeds up to 240 km/h (pods will of course cruise at a much slower speed in a dense city). This translates to impressive intercity timesL Newcastle-Sydney 0:45, Katoomba-Sydney 0:30. Canberra-Sydney 1:30. And between cities you don’t need to travel via central stations, you go directly and nonstop from suburb to suburb. Erecting lines between cities and towns is easy and fast because very little is needed in the way of earthworks: the guideway is on poles 6 meters above the ground. Nature is left largely undisturbed, and traffic and animals may cross freely under the track.

A bidirectional M-PRT line has the same capacity as a freeway with three lanes in each direction (like the new M2). Since there are no chauffeurs needed in the system, tickets may be quite cheap. And energy use per person even at top speed is low, on a par with high speed rail.

This technology should be included in the ongoing discussions. It is far superior to the alternatives.

I research and write about this in cooperation with the  American inventor, Doug Malewicki. But my engagement in this technology is purely academic: while I am the Norwegian contact for SkyTran, which currently has a research agreement with NASA to develop the concept, I have no commercial ties to the company.

Note that this is not Sci-Fi, or eccentric dreaming from some “futurist”. All parts of the system have proved to work, and you might check out the first “flight” of a full-size prototype at NASA’s Ames center, downloadable from here (my uni web site in Norway, guaranteed virus free!).

I gave a talk about the system at Sydney University’s Institute of Transport and Logistics Studies early this year, see presentation here (you find it as the second entry from the top). I was also interviewed about this on the ABC Science Show In spite of these openings, it is really an uphill battle to get radical new solutions out there in the public domain. I tried several times during my Australian stay to get something into the Sydney Morning Herald, but they didn’t even respond.

Train in vain

James Glover is a regular contributor to the Stubborn Mule who tries, whenever possible, to incorporate back of the beer coaster calculations in his posts. Here his beer coaster helps him skewer the prospects of high speed rail in Australia.

Don’t get me wrong–I love trains. I have caught trains around Europe and even the train from Sydney to Melbourne just for the pleasure of it. My favourite train journey, from London to Edinburgh up the east coast, was made particularly memorable one trip because I was (a) sitting in First Class (as usual), and (b) sharing a booth with two particularly rotund members of the House of Lords including Lord Lawrence “Mad-Eye” Mooney. So, whatever you do please don’t accuse me of trainist tendencies.

With that in mind, you would think I’d be excited by the release of a government report into building a high-speed train line from Melbourne to Sydney and from Sydney to Brisbane, via Newcastle and the Gold Coast. Sadly however the report recommending construction of this train line contains figures which crush any chance of this actually happening. The estimated cost of the build is $100 billion and there would be an estimated 54 million passengers per year. So how does that work out on a beer coaster? To convert $100 billion to an equivalent annual funding cost we just work out how much the government would pay, perpetually, to borrow this amount. At current government long-term yields of 6.00% this represents an annual interest cost of $6 billion. If the government wanted to pay back the capital in 25 years, a typical benchmark for infrastructure projects, the annual payments would increase to about $8 billion. So, calling it 50 million passengers a year, represents a cost per passenger of $160 per trip. That doesn’t seem so bad given that the cost of a one-way plane ticket between Sydney and Melbourne is about $200-400.

Is this just a coincidence? Sadly, no. It appears the planners have flipped the beer coaster over to its dark rum-soaked side to work out how many passengers they would require to make the project commercially feasible and competitive against air travel. It’s a time honoured trick but one that doesn’t stand up to closer scrutiny. In the interest of beercoasternomics and because a Google search failed to find the answer, I estimate the daily number of air passengers between Sydney and Melbourne. Turning to webjet.com, I counted 75 flights from Melbourne to Sydney on a Wednesday. From memory a typical plane on that route has about 40 rows and 6 passengers per row or about 250 passengers. That represents a total of fewer than 20,000 passengers per day. Double that for the return journey and add 25% for the numbers travelling to and from Brisbane. Let’s call it 50,000 passengers per day. Over a whole year our generous estimate of airline passenger numbers Sydney-Melbourne-Brisbane is 20 million. I’m guessing it is really no more than 5 million a year but lets call it 20 million anyway. Even at that figure it falls far short of the 50 million required to make the high-speed rail line economically viable. So why have the planners been so brazen in their estimate? That becomes clear if we used a still optimistic but realistic figure, in my opinion, of say 2 million potential rail passengers a year (which is still over 5000 per day), then the average cost of each passenger, one-way, would be $4,000! I rarely approve the use of “dead dog’s dicks” exclamation marks [strikethrough courtesy of a prudish editor], but really!!! Should this line ever get built I will be a frequent and enthusiastic user of it. $150 for $4,000 value is the sort of bargain that would make a late-night shopping channel host blush.

I suspect by including a few commuter stops at the beginning and end of their trips such as Brisbane to Gold Coast and Sydney to Newcastle and maybe even a new commuter line or two, e.g. Sydney to Epping, they have boosted the overall passenger numbers. But then those people are hardly going to pay over $150 for a short trip. The majority of the cost will still be borne by the (maximum) 2 million intercity travellers. Though even including short trip passengers 50 million seems excessively high until you realise it is really just the figure they need to make the numbers work.

So, sadly, the numbers don’t add up. I won’t comment on the politics except to say the feasibility study is one of promises the Labor Party made to get Greens’ support to form a government. Nor will I comment on the claims that there are hidden environmental and economic benefits. High speed rail in Australia is the classic white elephant which, according to Wikipedia, was a gift made by Thai Kings to obnoxious courtiers to bankrupt them due to the high cost of maintenance of these sacred pachyderms. Some will bring up the precedents of Europe or Asia, but there you have either cheap labour and government requisitioned land or a high density of large cities. Australia has none of these.

As The Clash so prophetically sang: it’s a train in vain.