Monthly Archives: July 2010

The Mule goes SURFing

A month ago I posted about “SURF”, the newly-established Sydney R user forum (R being an excellent open-source statistics tool). Shortly after publishing that post, I attended the inaugural forum meeting.

While we waited for attendees to arrive, a few people introduced themselves, explaining why they were interested in R and how much experience they had with the system. I was surprised at the diversity of backgrounds represented: there was someone from the department of immigration, a few from various areas within the health-care industry, a group from the Australian Copyright Council (I think I’ve got that right—it was certainly something to do with copyright), a few from finance, some academics and even someone from the office of state revenue.

Of the 30 or so people who came to the meeting, many classed themselves as beginners when it came to R (although most had experience with other systems, such as SAS). So if there’s anyone out there who was toying with the idea of signing up but hesitated out of concern that they know nothing about R, do not fear. You will not be alone.

The forum organizer, Eugene Dubossarsky, proceeded to give an overview of the recent growth in R’s popularity and also gave a live demo of how quickly and easily you can get R installed and running. Since there were so many beginners, Eugene suggested that a few of the more experienced users could act as mentors to those interested in learning more about R. As someone who has used R for over 10 years, I volunteered my services. So feel free to ask me any and all of your R questions!

As well as being a volunteer mentor, I will have the pleasure of being the presenter at the next forum meeting on the 18th of August. Regular readers of the Stubborn Mule will not be surprised to learn that the topic I have chosen is The Power of Graphics in R. Here’s the overview of what I will be talking about:

In addition to its statistical computing prowess, R is one of the most sophisticated and flexible tools around for visualizing quantitative data. It can produce a wide variety of chart types, including scatter plots, box plots, dot plots, mosaic plots, 3D charts and more. Tweaking chart settings and adding customized annotations is a breeze and the charts can readily be output to a range of formats including images (jpeg or png), PDF and metafile formats.

Topics covered in this talk include:

  • Getting started with graphing in R
  • The basic charting types available
  • Customising charts (labels, axes, colour, annotations and more)
  • Managing different output formats
  • A look at the more advanced charting packages: lattice and ggplot2

Anyone who ever has a need to visualize their data, whether simply for exploration or for producing slick graphics for reports and presentations can benefit from learning to use R’s graphics features. The material presented here will get you well on your way. If you have ever been frustrated when trying to get charts in Excel to behave themselves, you will never look back once you switch to R.

For those of you in Sydney who are interested in a glimpse of how I use R to produce the charts you see here on the blog, feel free to come along. I hope to see you there!

The Art of Conversation

Have you ever heard the question “Would you like a tea or a coffee” answered with a simple “Yes”? If so, the respondent almost certainly considers their response to be extremely witty. The questioner is unlikely to agree. There is also a high probability that the joker is someone’s Dad…or perhaps a mathematician.

I have to admit to having indulged in this “joke” in my time (more than once), but until recently it had not occurred to me that it in fact reflects a violation of a general principle of conversation. Enlightenment came when I read the seminal 1975 paper “Logic and Conversation” [1] by the philosopher H.P.Grice.

The humour (or lack thereof) of the coffee/tea gag lies in the conflict between the logical truth of the statement and its inappropriateness in conversation. While the statement “A or B” is logically true as long as at least one of A and B is true , in the context of conversation, logical truth is not enough. If you knew A was true and B was false, you would not bother saying “A or B”, you would just say “A”. Moreover, that is what others would expect of you. If I ask you to pass me a hammer, I don’t expect you to pass me a hammer and a spanner. In the same way, if you know you are going to Spain for your holidays, I don’t expect you to say “I’m either going to Spain or Canada”, despite the fact that, strictly speaking, it is a true statement. It is this distinction between simple logical truth and appropriateness in conversation that is the subject of Grice’s paper.

Grice bases his ideas on the notion of the “Cooperative Principle”, which he summarises as the requirement to

Make your conversation such as is required, at the stage at which it occurs, by the accepted purpose or direction of the talk exchange in which you are engaged.

People have conversations of many types for many reasons: to do business, to gossip, to seduce, to educate, to inform or simply for the pleasure of conversation itself. In every case, conversation involves (at least) two participants and the conversations that work best are the ones that take the needs of all of the participants into account. So it makes sense that a bit of cooperation is the foundation of a good conversation.

Based on the cooperative principle, Grice goes on to postulate a number of “maxims of conversation”. Here are the maxims as he describes them:

Quantity

  1. Make your contribution as informative as is required (for the current purposes of the exchange).
  2. Do not make your contribution more informative than is required.

Quality

  1. Do not say what you believe to be false.
  2. Do not say that for which you lack adequate evidence.

Relation

  1. Be relevant.

Manner

  1. Avoid obscurity of expression.
  2. Avoid ambiguity.
  3. Be brief (avoid unnecessary prolixity).
  4. Be orderly.

The term “maxim” is carefully chosen as Grice notes that one need not follow all of the maxims at all times, while still being cooperative. The main reason that a maxim could be violated is if it is in conflict with another maxim. An example would be providing less information than required (violating Quantity 1) because you are not confident you have the facts right (and you don’t want to violate Quality 2).

Viewed in terms of Grice’s maxims, the coffee/tea joke is a clear violation of the first maxim of quantity.

As I have already admitted to this particular breach, the obvious question is: have I violated any other maxims? Some who know me well would take the view that, while I may take pains to avoid a violation of either of the maxims of quality, I regularly and flagrantly violate Quantity 2 and Manner 3 and probably Relation 1. I need to learn to stick to the point or risk being branded an uncooperative conversationalist! Or perhaps it’s too late.

[1] Available in the collection “Studies in the Way of Words” by H.P.Grice.

Emissions League Tables

Yesterday’s Sydney Morning Herald featured an opinion piece by Rodney Tiffen on Australia’s sluggish response to climate change. Deliberately provocative, the discussion was framed from the outset in the language of competition:

An international competition in self-righteousness would be closely fought. But Australia must be a strong contender.

Tiffen went on to draw on data from the International Energy Agency (IEA), but got his statistics slightly wrong in the process:

If we restrict the analysis to the most populous 130 countries, those with a population of 3.5 million or more, Australia is the world leader. Only a handful of small countries, especially oil producers such as Bahrain, Qatar and Kuwait, have higher per person emissions.

Australians may be disappointed to learn that we do not, in fact, take home the trophy in this competition. Both the United Arab Emirates and the United States have populations over 3.5 million and have higher per capita emissions than Australia at last count (2007). Nevertheless, coming in third place in this competition, Australia certainly punches above its weight, with per capita emissions running at 4.3 times the world average. Furthermore, as the chart below shows, we have been steadily catching up to the United States over the last 40 years. In fact, to give Tiffen the benefit of the doubt, the most recent IEA data is for 2007, so we may well be ahead of the USA by now.

CO2 emissions 1971-2007 (Source: IEA)

The reason Tiffen looks at per capita emissions is to ward off one common argument for inaction on climate change, namely that China and the United States are the only countries that can make a difference. There is no doubt that these two countries dominate the overall production of emissions. Throwing Canada and Mexico in with the United States brings North American emissions to almost one quarter of the world’s total. Add China and almost half the world’s emissions are accounted for.

Total CO2 emissions for 2007 (Source: IEA)

Nevertheless, if the aim is to attempt reductions in world emissions, Tiffen’s focus on per capita emissions is entirely appropriate. No-one would be convinced if the United States viewed its emissions along State lines, thereby arguing that their emissions were not so big by global standards after all (although, this defence would probably not be much use to California). While countries may be actors on the world stage through their political proxies at climate conferences, emissions are ultimately the product of people (both at home and at work) and not countries. Ranking countries by per capita emissions is thus useful as it gives some indication of where emission reductions may be more readily achieved. The chart below shows the top 25 (big and small) countries in terms of per capita emissions.

Top 25 per capita emitters for 2007 (Source: IEA)

Qatar ranks so high on this scale that it compresses the figures for all of the emitters below it, so here is the chart again with a somewhat truncated scale.

Top 25 per capita emitters for 2007 (Source: IEA)

There are certainly some small countries with high rates of carbon emissions per capita, but looking at a larger scale reveals that developed countries are the worst in per capita terms. It is worth noting, though, that Europe is doing better than the rest of the OECD and is also ahead of former members of the Soviet Union.

Per capita emissions by region for 2007 (Source: IEA)

Another useful approach is to consider emissions per dollar of economic output. This serves to highlight “inefficient” emitters, not to shame them but to identify where spending money on the problem is most likely to deliver significant results. It should come as no surprise that a league table of the highest emitters per dollar of gross domestic product (GDP) is a catalogue of troubled and/or small nations. Note that these figures are calculated based on conversion to US dollars using market exchange rates. Using purchasing power parity instead does reorder the list somewhat, but the names are largely the same.

Top 25 emitters by emissions/GDP for 2007 (Source: IEA)

This perspective suggests that when developed countries consider programs to assist developing countries to reduce their emissions, they could reasonably focus on significant but inefficient emitters. The chart below provides a possible target list, showing the 10 worst-performing countries in terms of emissions per dollar of economic output after restricting to countries with emissions of at least 150 million tons of C02 per annum.

Top 10 large emitters by emissions/GDP for 2007 (Source: IEA)

When will Julia go to the polls?

After taking Kevin Rudd’s scalp and now having done a deal with the miners, Australia’s new prime minister, Julia Gillard, is widely expected to call an early poll. The question is, when will the election be held?

As usual, my first inclination is to dig into the historical data. Looking at all of the Federal elections since Federation, December is far and away the most popular month for a poll. Although the election does not even have to be held this year, December is sufficiently far into the future that it fails to qualify as an early election. Unless the bounce Gillard has experienced in opinion polls proves to be extraordinarily short-lived, we should be looking at a somewhat earlier date. Interestingly, both July and August have only seen one election. On the admittedly spurious grounds of historical precedent, September would be a better bet.

Australian Federal Elections by month

But what of other sources of information? At the time of writing, the shortest odds from SportingBet were on August 7. In my own rather modest poll, August is also proving the most tipped month (it’s not too late to vote in the poll…just make your selection in the form below). No-one has voted for a date in July and I am inclined to agree that that is really a bit soon. Nevertheless SportingBet is still showing odds (admittedly long ones) for 31st July.

In a bid for contrarian status, I will diverge from both the bookies and voters in my poll and will tip a September election. But which date? History is not much help there. Of the four September elections in the past, there has been one on the 1st, 3rd, 4th and 5th Saturday of the month (1914, 1934, 1940 and 1946 respectively). So, I will veer as close as possible to the people’s choice of August, while still tipping September and predict that the election will be on Saturday 4th September. In choosing that date, I have not been swayed by the fact that the fourth Saturday of the month has been the most popular historically, other than to nominate 28th August as my fall-back selection.

Since I will most likely be wrong and you probably disagree with me, make sure to vote!

RSPT RIP – Long Live the MRRT

In the third in a series of guest posts on the subject of Australian mining tax, Zebra (James Glover) considers the changes to the proposed tax the new prime minister, Julia Gillard, has negotiated with miners.

The Govt has announced a replacement for the RSPT discussed in earlier posts to a Mineral Resources Rent Tax (MRRT). The principle differences are the tax rate – 30% and a change in the deduction. For established mines it is now based on market value depreciated over 25 years and the uplift rate is 12% not 5%. In addition there is a 25% deduction from earnings upfront which makes the base rate of tax 22.5% rather than 40%.

This post replaces an earlier one I put up about the MRRT in which I erroneously assumed that the opt-in about using the market value of assets applied in the way I proposed in my second post. The key statement here is:

“Miners may elect to use the book or market value as the starting base for project assets, with depreciation accelerated over 5 years when book value, excluding mining rights, is used; or effective life (up to 25 years) when market value at 1 May 2010, including mining rights, is used. All post 1 May 2010 capital expenditure will be added to the starting base.”

In the case where the mining company opts to use a market value approach I take it to mean the depreciation takes place before the MRRT is calculated. This means the formula is:

MRRT = 30% x (75% x Earnings – Price(2010)/25)

Currently the mining industry average for P/E (price to earnings ratio) is 14, though in the case of BHP-Billiton it is 19. For an average miner then Price(2010)/25 = Earnings x 14/25 = 56% Earnings so the actual MRRT is based on 19% of Earnings. However the Price is fixed at the May 1 2010 value so this will not increase over time even though earnings will. Should earnings continue to rise at the dramatic rate we have seen in the past decade then the MRRT will eventually look more like the 22.5% base rate.

It appears that the Govt and the mining industry’s compromise is to push the revenue from the tax windfall out from today to later years. In a sense the mining industry has also removed the contentious “retrospectivity” of the tax by using the current high price and choice of 25 years depreciation to ensure the current value of the MRRT is minimised but will rise at 22.5% of increased earnings going forward.

Thanks to an observant reader who pointed out my error. Mea culpa.