A Delicate Balance

3-way BalanceEver since Julia Gillard managed to wangle the support of two of the three country independents and scrape through to a second term in government, speculation has focused on how long the arrangement can last…and not only in the media but also on the Mule Stable.

Challenging though the road ahead may be for the new government, with so many different interests to juggle, I am of the view that Labor will do whatever they can to hold on to power. Even if they are unable to pass “crucial” legislation, they would be very unlikely to go to the polls early lest they lose the election. After all, if they did not have the courage to trigger a double dissolution when they failed to pass emissions trading legislation to combat the “greatest moral challenge of our time”, it is hard to see what issue could be important enough to them to jeopardise their power.

As for the independents, another election would risk their own new-found power. Furthermore, in siding with Labor they have not really promised very much. All they are committing to is to pass supply and to support the government in the event that no confidence motions are brought against it. On each and every particular piece of legislation they are free to horse-trade once more and potentially vote against the government. Also, as Bob Brown recently pointed out, there is nothing to stop the independents and the Greens backing legislation initiatives brought forward by the Liberals. So there really is no good reason for the independents to withdraw their support from Labor.

Without the numbers, the Liberals and Nationals are powerless to bring on an early election. So, this unlikely new coalition government is likely to be here to stay. The only scenario I can see that could undo Labor is a by-election. If one of the MPs supporting Labor were to fall under a bus, retire, disgrace themselves and resign or in some other way leave the Parliament, the Liberals would have the chance to win the by-election and chance the numbers on the floor. Failing that, I would expect to see Labor ruling for a full term.

What do you think? While it may take some time to see the result, this seems like a good opportunity for another poll on the Mule, so have your say!

(polls)

Protovis now working in Chrome and Safari

Thanks to everyone who responded to my experimental Protovis post*, whether in the survey, via twitter or in comments on the post. It quickly became clear that my trick for including the code to generate the chart completely failed to work in Chrome and Safari browsers. I still do not fully understand why that is, but I have now worked out a completely different approach to the problem which (fingers crossed) seems to work in more browsers, although I still cannot vouch for all versions of Internet Explorer.

So here is the chart one more time. I hope it now works for (almost) everyone!

[pvis src=”http://stubbornmule.net/scripts/pv/test.js” img=”/blog/wp-content/PV-CDO-circles.png” height=”125px”]CDO deals: total and recycled[/pvis]
I will also be updating the howto post very shortly to explain my new technique.

UPDATE: at the moment, this trick is not working on mobile devices. It should now be working on mobile devices except for Android. The only remaining problem is IE, but I think that will not be possible. I will instead try to make it fail more gracefully on IE.

* Protovis is a javascript data visualisation library being developed at Stanford, which allows the creation of interactive charts on web pages.

Getting Protovis working on WordPress

When I started experimenting with Protovis*, I quickly found that getting it to work in a WordPress blog was rather fiddly. With a lot of help from Google (and this page in particular), I managed to piece together what needed to be done, but since I did not find any explanations specifically focused on Protovis in WordPress, I thought it may be useful for others attempting the same thing if I summarised the steps involved. Most readers will not have the slightest interest in this, so I will not expect many of you to keep reading!

First of all, if you are hosting your blog on WordPress.com, give up now! These instructions will only work if you have a self-hosted installation of WordPress.

1. Download Protovis and unzip it on your server it a convenient location. I put it in a folder called “protovis”, accessible from the root of the webserver.

2. Ensure your headers include a pointer to the Protovis script. How exactly you do this, depends on your theme, but since I am using Thesis, it’s quite straightforward: under Site Options > Additional Scripts, I added the following code.

<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
 <script type="text/javascript" src="/protovis/protovis-r3.2.js"></script>

3. Wrap your Protovis code up in a function and save it in a .js file on the server. For example, here is the code I used to produce the chart in the last post. You will see that I wrapped everything up in a function called “cdodraw”. I saved the file in the folder /script/pv.

4. Edit your post in HTML mode and use the following code to load and call your function.

<script src="/scripts/pv/cdodraw.js" type="text/javascript"></script>
<script type="text/javascript+protovis"><!--
cdodraw();
--></script>

You should replace “/scripts/pv/cdodraw.js” with the location of your own Protovis chart code and replace “cdodraw()”. With the name of your own function. Note that the first script command has type “text/javascript” and the second “text/javascript+protovis”. This is important!

Part of the reason for the difficulty is that WordPress has a tendency to mash up the text you enter, which is fine most of the time, but not when you are trying to write Javascript. An alternative may be to try the Text Control plugin, which allows finer control over WordPress’s mashing of your text. I have not tried the plugin myself, so I cannot be sure how well it works.

Good luck, and let me know how you go! If you have any suggestions on how to do this a better way, please let me know. Better still, you could write a WordPress plugin to make it all much easier.

UPDATE: it appears that this function-wrapping trick does not work for Google Chrome or Safari. I’m looking into it!

FURTHER UPDATE: I could not work out why the approach described here does not work for Chrome or Safari, so instead I got it working by creating a custom shortcode that slurps in a javascript file and includes it in the post. I am in the process of wrapping this up in a plugin to save others the trouble of working out how to do it. For those who cannot wait, here is the code I used:

function sProtovis($atts, $content = null) {
 extract(shortcode_atts(array('src' => '#'), $atts));
 return '<script type="text/javascript+protovis">'."\n".file_get_contents($src).'</script><noscript>Scripts disabled -- cannot display chart!</noscript>'.'<p align="center"><strong>'.do_shortcode($content).'</strong></p>';
}
add_shortcode('protovis', 'sProtovis');

It still relies on the Protovis code already being added into the header (as described above). In the plugin, this will no longer be necessary.

PLUGIN: pv-loader is now available on github.

* Protovis is a javascript data visualisation library being developed at Stanford, which allows the creation of interactive charts on web pages.

Experimenting with Protovis

A couple of weeks ago I gave a talk on using graphics in R. During the question session, someone asked whether I had tried using Protovis, a javascript data visualisation library being developed at Stanford. It was an easy question to answer: no!

However, a bit of subsequent investigation revealed that Protovis has been developed very much in the spirit of Leland Wilkinson’s book The Grammar of Graphics, which I am currently reading, so I have decided to experiment with it here on the blog.

The charts I generate with R are all static images, while a tool like Protovis allows for user interaction which opens up some interesting possibilities. Compared to R, which I have been using for around 10 years, Protovis presents a double challenge: not only do I have to come to grips with Protovis itself, but I will also have to learn some basic Javascript programming. So, I expect it to be a slow journey.

As a tentative first step, I have reproduced the CDO chart from a recent post ranting about bubble charts. At first glance, it is essentially identical to the chart I produced using R. However, if you hover your mouse over the points on the chart, you should see the figures appear! It is by no means perfect (for example, it would probably look better if single points appeared, rather than every point on the chart and it could do with a legend), but it’s a start and I will persevere.

[pvis src=”http://stubbornmule.net/scripts/pv/test.js” img=”http://stubbornmule.net/blog/wp-content/CDO-circles.png” height=”125px”]CDO deals: total and recycled[/pvis]

Producing scripts using a Javascript library does have its drawbacks. For a start, it means the chart will only be visible when scripts can be run, so if you are reading this in an email or an RSS news reader, you will probably not see very much and will have to visit the page on the blog to see it. Even then, some of you may use script-blockers such as NoScript which will also break the chart (mind you, you can trust the Mule, so you could always whitelist this site!). Finally, I believe that some older browsers (such as IE6) will not support Protovis. It would be useful to see how many people can or cannot see the chart, so please let me know using this poll whether you can see the chart.


(polls)

Getting Protovis to work on the blog was a little fiddly, so for anyone interested, I have also written up a quick guide to using Protovis on a WordPress blog.

UPDATE: Reports in so far indicate that the chart is not working in Google Chrome or on mobile devices. More work to do it would seem!

Keynes on Economics

I have always enjoyed the way John Maynard Keynes had with words. He was responsible for many a bon mot, such as “in the long run we are dead” (skewering the idea of long-run equilibrium in economics), “It is better to be roughly right than precisely wrong”, “Capitalism is the astounding belief that the most wickedest of men will do the most wickedest of things for the greatest good of everyone” and (my favourite) “Markets can remain irrational a lot longer than you and I can remain solvent”.

Today I read a rather scathing piece on the performance of economists in the lead up to and throughout the financial crisis, which included this rather longer but nevertheless brilliant quotation from Keynes.

The completeness of the [orthodox] victory is something of a curiosity and a mystery. It must have been due to a complex of suitabilities in the doctrine to the environment into which it was projected. That it reached conclusions quite different from what the ordinary uninstructed person would expect, added, I suppose, to its intellectual prestige. That its teaching, translated into practice, was austere and often unpalatable, lent it virtue. That it was adapted to carry a vast and consistent logical superstructure, gave it beauty. That it could explain much social injustice and apparent cruelty as an inevitable incident in the scheme of progress, [with] the attempt to change such things as likely on the whole to do more harm than good, commended it to authority. That it afforded a measure of justification to the free activities of the individual capitalist, attracted to it the support of the dominant social force behind authority. But although the doctrine itself has remained unquestioned by orthodox economists up to a late date, its signal failure for purposes of scientific prediction has greatly impaired, in the course of time, the prestige of its practitioners. For professional economists…were apparently unmoved by the lack of correspondence between the results of their theory and the facts of observation—a discrepancy which the ordinary man has not failed to observe, with the result of his growing unwillingness to accord to economists that measure of respect which he gives to other groups of scientists…

John Maynard Keynes, The General Theory of Employment, Interest and Money (1936; London: Macmillan, 1964) 32–3

I have a copy of the General Theory, which I have only skimmed. One day I really should read the whole thing. In fact, there’s even a Kindle edition for $3, so maybe that day is not too far away…

Photo credit: Wikimedia Commons.

Junk Charts #4 – Puns are dangerous

Design guru Edward Tufte famously lambasted pie charts in The Visual Display of Quantitative Information and went on to say

the only worse design than a pie chart is several of them

While pie charts do have their defenders, the basis for the contempt in which pie charts are held by Tufte and others is that the human eye is far better at differentiating position and length than angle and area.

Circular CDOsSo, I was a little disappointed when a correspondent drew my attention to this rather bubbly chart which appeared on an article by the excellent team at Pro-Publica (click on the chart to see a larger version).

Pro-Publica is an independent, not-for-profit newsroom that specialises in investigative journalism. They have collaborated with the team at Planet Money (one of my favourite podcasts), and have perhaps delved deeper than any other journalists into the arcane world of CDOs, a topic I have touched on a few times here on the Stubborn Mule.

The chart, attributed to Thetica Systems, was used to accompany an article by Pro-Publica exposing the fact that, in their words,

Over the last two years of the housing bubble, Wall Street bankers perpetrated one of the greatest episodes of self-dealing in financial history.

It is a fascinating story, but it would seem that Thetica’s graphics department was carried away with a visual pun on the title of Pro-Publica’s post “Circular CDOs” when they chose to use circles to depict the growth in CDO recycling from 2005 to 2007. It might look pretty, but the circles make it much harder to discern the trend and to compare the four banks. Pro-Publica’s article deserves better.

In the tradition of my junk chart posts, I have produced an alternative visualization of the same data. I am sure that graphic designers could improve on the colour-scheme, but this simple lattice of line charts makes for a much clearer view of the data.

CDO Self-Dealing (2005-2007)CDO Self-Dealing by investment banks (2005-2007)

If this post has given you a taste for de-junking charts, you should also visit the Junk Charts blog for much, much more.

More Informality

Yesterday’s post on informal votes generated a lot of questions, both on and off the blog. One commenter was interested in understanding why there was so much variability in informal votes in New South Wales. It is a good question, and one I do not have an answer to. Presumably demographic differences across electorates (such as varying facility with reading English among non-native speakers) would come into play. But this still leaves open the question as to why the swing in informal votes varies so much across New South Wales. I will have to leave it to you to explore: the table below has the informal vote in all 48 New South Wales seats for your perusal. Let me know if you have any theories!

Division IDDivisionInformal (%)Informal Swing (%)
107Blaxland14.225.33
251Watson13.574.48
119Fowler13.24.72
111Chifley11.093.18
315McMahon11.013.41
153Werriwa10.594.01
104Barton10.283.71
122Greenway9.473.29
144Reid9.213.63
140Parramatta8.732.11
103Banks8.552.79
127Kingsford Smith8.232.92
128Lindsay82.48
131Macarthur7.932.36
121Grayndler7.131.15
110Charlton7.112.44
150Throsby7.012.14
118Farrer6.853.02
124Hughes6.782.34
148Shortland6.582.42
105Bennelong6.510.29
117Eden-Monaro6.442.71
126Hunter6.231.96
146Robertson6.22.76
250Riverina6.112.22
115Dobell6.071.75
136Newcastle5.821.39
112Cook5.731.92
114Cunningham5.731.82
134Mitchell5.621.55
133Macquarie5.41.75
249Paterson5.371.77
149Sydney5.351.17
132Mackellar5.270.6
139Parkes5.251.17
120Gilmore5.241
145Richmond5.150.87
125Hume5.141.57
109Calare4.691.07
151Warringah4.661.22
137North Sydney4.620.9
138Page4.480.18
106Berowra4.44-0.24
152Wentworth4.43-0.47
113Cowper4.310.34
108Bradfield4.230.26
130Lyne3.67-1.36
135New England3.60.63

An email correspondent asked whether it was in fact the 2007 election that was anomalous rather than the 2010 election, so I have also compared the 2010 informal vote to the 2004 election. Interestingly, the uptick in informal votes from 2004 to 2010 is indeed smaller. In fact, Western Australia had a lower rate of informal votes in this election than in 2004. New South Wales still shows significant increases in informal votes in a number of electorates, which helps drive a national trend. Overall, compared to 2004 there does still seem to be something going on with informal votes, but the effect is certainly less marked.

Informal Votes: 2010 vs 2004

I also received various questions about whether correlations could be seen between informal votes and Green votes, whether the increase in informal votes was greater in more marginal seats and so on. Unfortunately, as yet my data mining has not revealed anything of substance. Here, for example, is the increase in the rate of informal votes versus the absolute two-party preferred margin. The regression lines show no simple relationship.

Informal vs 2PP

Informal Vote versus Two-Party Preferred Margin

Comparing Green votes to informal votes is just as unenlightening. That, at least, seems to make sense. While it is reasonable to consider some of the Green vote as a protest vote and some of the informal votes likewise as a protest vote, it may be that in some electorates more voters were inclined to protest by voting Green than informal, or vice versa. This would mean that there would be negligible correlation between the Green and informal swings at the division level.

So, despite my efforts, I am yet to squeeze further insight from the data. Of course I remain open to further suggestions! If you would like to do your own analysis, the current 2010 data is available from the AEC as is past data.

UPDATE: If you sort the table at the top by informal vote, you’ll see that the two electorates with the lowest rates of informal voting were New England and Lyne, the seats of the independents Tony Windsor and Rob Oakeshott respectively!

Also, here is a national table of informal votes (just to avoid being to NSW-centric).

Dress: Informal

While Australia still waits to see which party will manage to scrape into power, the Australian Electoral Commission (AEC) has announced an investigation into the unusually high rate of informal votes. Veteran ABC analyst Antony Green observed that the rate of informal votes was the highest since 1984. Some are attributing the rise to the “Latham effect” following the exhortation by former Labor leader now professional provocateur, Mark Latham, that voters should spoil their ballots to thumb their noses at both major parties.

It will be interesting to see what conclusions the AEC draws, but there is no doubt that the informal votes in this election were significant.There are more votes to be counted and the trends in postal votes may differ somewhat from votes cast in person, but enough of the votes are in to get a reasonable picture of what has been going on. The figures here are based on the AEC data for the House of Representatives as at 23 August 2010. Informal votes rose in every state from the rate seen in the 2007 election, increasing by a margin of between 1.0% and 2.4%.

State 2007 2010 Change
NSW
4.95
6.87
1.91
NT
3.85
6.07
2.21
QLD
3.56
5.63
2.07
SA
3.78
5.54
1.76
WA
3.85
4.80
0.95
ACT
2.31
4.73
2.42
VIC
3.25
4.54
1.29
TAS
2.92
4.20
1.27

Informal Votes by State (%)

One way to visualize the changes is to plot the informal vote rate in 2010 against that of 2007. The chart below does this at a state level and also adds in a 45 degree line. Points falling above this line (as they all do) show an increase from 2007 to 2010, while points below the line would indicate a decrease.

Informal Votes by State

Aggregating to a state level hides a lot of the interesting detail and can be misleading. For example, the ACT shows the biggest increase in informal votes, but with only two electorates, these figures have less statistical value. A more interesting picture emerges when the changes are shown by division. The chart below groups the changes by state, but plots points for each division*. Once again, 45 degree lines provide a guide as to whether informal voting rates increased or decreased.

Informals by Division (State and National)

Leaping out from this picture is the extraordinarily high rate of informal votes in some divisions in New South Wales. It is also striking that the rate of informal votes has increased in almost every division. At this point, there are only 4 divisions in the whole country (one in Victoria and three in New South Wales) to see the rate of informal votes drop.

It is hard to escape the conclusion that the increase in informal votes reflects a protest vote arising from deep voter dissatisfaction with both major parties. The Greens are pleased with the “Greenslide” they have experienced, but some of their success is likely to amount to the same voter protest, only expressed another way, rather than a permanent shift in commitment to the Greens.

* For the purists, there were changes to electorates between elections, and the chart only shows divisions which existed in both 2007 and 2010. Given changes to boundaries, some of these electorates are, strictly speaking, no longer perfectly comparable, but they have been plotted regardless.

Recognise this?

Last night I was watching the Chaser’s Yes We Canberra (only a day late), and jumped out of my chair when I saw Craig Reucassel corner Tony Abbott to challenge him about his obsession with reducing Government debt. Have a look at this to see why!

Here is the post referred to in the video.

UPDATE: here’s a tweet from Craig on the topic of attribution (or lack thereof): http://twitter.com/craigreucassel/status/21647798173

Infrastructure Bonds

With Australia’s Federal election looming, the opposition has today proudly announced a new policy to fund infrastructure without actually increasing Government debt! What are we to make of this?

It’s hard to determine the details from a media announcement, but based on the text posted by Peter Martin on his blog, it would seem that the idea is to provide tax incentives for entities other than the Federal Government to borrow to fund infrastructure:

Private infrastructure operators and State and Local Governments will be eligible to apply for the concessional treatment.

The way the scheme would seem to work is that eligible projects could issue bonds and investors would receive a tax rebate amounting to 10% of the interest on the bond. So, if you received a $100 interest payment and your earning put you in the top marginal tax bracket, you would pay $45 in tax. Under this scheme, you would only pay $35 in tax.

So, the cost to the Federal Government would simply be forgone tax revenue (and this would be capped at $150 million per annum) and the Opposition believes that the program could support up to $20 billion in infrastructure financing. Presumably, investors currently buying plasma TVs would rush to buy these bonds instead.

Seems like a neat trick, but I have a number of reservations about the scheme.

First, I have argued in the past that the near-hysterical concern about Government debt is overdone. For a start, Government debt in Australia is far lower than in other developed countries around the world. More importantly, the facile analogy that compares Government finance to that of a household budget does not stand up for one very important reason: unlike you or me, the Government is the monopoly issuer of Australian dollars. This changes the game and breaks the analogy utterly.

Second, the opposition’s policy would still involve raising significant amounts of debt, just not issued by the Federal Government. If that debt is all incurred instead by State Governments, should that really be a cause for celebration? After all, unlike the Commonwealth, State Governments do not control issuance of currency, so they really could go bankrupt and indeed, recent history has shown that many of the State Governments are loath to increase their debt levels too significantly for fear of having their credit rating downgraded. What if the borrowers are in the private sector? Well, that would be worse still! Back in March I updated my chart showing private and government sector debt. The debt level we should all be worried about in Australia is private sector debt, which is far higher than government sector debt.

History of Government and Private Sector Debt levels

Third, infrastructure bonds have form. Back in the 90s, the then Labor government introduced an infrastructure bond scheme which also featured tax incentives. Of course, it did not take long for clever investment bankers to work out how to surgically isolate the tax benefit so that wealthy individuals could take advantage of the concession without actually taking on any investment risk. In the end, the whole scheme was shut down, although some of the transactions that were done still survive today. I would expect exactly the same thing to happen with this policy. Any special tax treatment is always a red rag to the tax expert bull.

So, it may sound clever, but to me it does not seem to be sound policy.