Petrol prices adjusted for inflation

Petrol prices adjusted for inflation (Perth, Western Australia)

The thought for this sprung to mind when I saw petrol drop below $1.20 per litre the other day, and it made me think, I remember paying that when I got to Australia 4.5 years ago. Fuel prices are listed online here, so I went to the site for a nosey at their archiving and they have a reasonably comprehensive archive of data – WA historic fuel prices. All that was left to do was hunt out the inflation (CPI) data, which was also readily available – Australian inflation data.

The fuel price data was available as a monthly average [for the Perth Metro area]. The inflation data was available quaterly. Given the fuel data started in 2001, I thought it made sense to show things in 2001 dollars, so I divided the indices by the 2001 indices to make this the baseline. For manipulation purposes I converted the month data into date data, using the 1st of the month for the day in all cases. Then the ‘closest’ inflation index was merged onto the fuel price, which was then converted into 2001 dollars, and graphed.

I wrote this post in RStudio using the R Markdown language and then knitr to turn in into markdown (.md), and then pandoc to turn it into html. The original file is available here on github.

system(“pandoc -s -o petrol_prices.html”)

Credit also to this post from Jeromy as I used some of the finer points of his code as a guide to getting this up.

Prepare for analyses


# Pull data down from csv stored on github
fuel <- read.csv(textConnection(getURL("")))
inf <- read.csv(textConnection(getURL("")))

# examine the data

# format the dates
fuel$date <- as.Date(paste0("01-", fuel$month, "-", fuel$year), format = "%d-%b-%Y")
inf$date <- as.Date(paste0("01-", inf$month, "-", inf$year), format = "%d-%b-%Y")

# match the closest quarterly inflation figure to the fuel price date,
# just the position index
fuel$closest <- sapply(fuel$date, function(x) which(abs(as.numeric(inf$date) - 
    as.numeric(x)) == min(abs(as.numeric(inf$date) - as.numeric(x)))))
# convert the inflation indices to be relative to 2001 dollars
inf$cpi01 <- round(inf$cpi/inf$cpi[1] * 100, 2)
# pull the inflation figure into the fuel data frame
fuel$inf <- sapply(fuel$closest, function(x) inf$cpi01[x])
# calculate the 'real' price of the fuel
fuel$rprice <- fuel$price/fuel$inf * 100

# melt the data so it slides right into ggplot
mfuel <- melt(fuel, id = c("month", "year", "closest", "inf", "date"))
mfuel$variable <- factor(mfuel$variable, labels = c("Nominal (pump/actual) Price", 
    "Adjusted (to 2001 $) Price"))

And here’s the plot

ggplot(mfuel, aes(x = date, y = value, group = variable)) + geom_line(aes(colour = variable)) + 
    labs(x = "Date", y = "Price", colour = "") + opts(title = "Perth Metro petrol prices over time")

So you can see, today we’re actually paying relatively less for fuel than we did for through the middle of the 2000′s decade, but over the past few years it has been cheaper on average than it is now. Who knew.

This might have been done before but I couldn’t find a similar plot out there.

About these ads

8 thoughts on “Petrol prices adjusted for inflation

  1. hmmm… looks nice but it suprises me that australia publishes CPI in quarterly frequency… and probably just a thought: might it be helpful to deflate petrol prices by something like a core CPI (corrected for energy prices) since it seems odd to deflate prices with a time series that is strongly driven by the time series you are deflating …

    • They’ve published them quarterly for some time. Regarding petrols influence on CPI, that’s a really good point. The tables published by the RBA have a few different measures, some excluding things like petrol and ‘fruit and vegetables’. They seem quite closely correlated, so I wouldn’t go so far as to say petrol ‘strongly’ or even ‘moderately’ drives CPI, certainly not in Australia. That sad, economics is really not my area so this really is a crude cut to cull my own curiosity.

  2. In the U.S. a large part of the price is in various taxes. This of course distorts or at least strongly influences the interpretation of price across time. It would be interesting to see how oil as a commodity price varies in relation to retail sales price.

    • In Australia a portion is tax, but my understanding is that percentage hasn’t changed since 2000, so that shouldn’t affect this at all.(?) Ooo, that would be good, and possibly not that hard to do. Price of oil would be in US, then would have to retrospectively convert to AUD and then apply inflation adjustment. I guess you might need some knowledge of where we buy our oil (petrol) from if different manufacturers/countries have different prices etc. Hmmm.

      • nzoops, Tapis Crude Oil (and to a lesser extent Dated Brent Crude Oil) prices are generally considered the benchmark for Australia petrol prices.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s