Last year's discussion about the differences between the retail price index (RPI) and consumer price index (CPI) in the UK only exemplified the challenge. The economist Tim Harford illustrated the differences between the RPI and CPI with a simple example of price changes for a shirt and blouse in his Radio 4 programme More or Less. The radio podcast is still available from the BBC. Start listening after about 18 minutes into the show.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inflation data example as presented by Tim Harford on 'More of Less' | |
# http://downloads.bbc.co.uk/podcasts/radio4/moreorless/moreorless_20120817-1630a.mp3 | |
dat <- data.frame(shirt =c(year_1 = 20, year_2 = 25, year_3 = 20), | |
blouse=c(year_1 = 25, year_2 = 20, year_3 = 25)) | |
dat | |
# shirt blouse | |
# year_1 20 25 | |
# year_2 25 20 | |
# year_3 20 25 | |
(yoyChange <- dat[-1,]/dat[-3,] - 1) | |
# shirt blouse | |
# year_2 0.25 -0.20 | |
# year_3 -0.20 0.25 | |
# Arithmetic average gives 2.5% inflation year on year | |
apply(yoyChange, 1, mean) | |
# year_2 year_3 | |
# 0.025 0.025 | |
geo_mean <- function(x) exp(mean(log(x))) | |
# No inflation with the geometric mean | |
apply(yoyChange + 1, 1, geo_mean) - 1 | |
# year_2 year_3 | |
# 0 0 |