big_mac <- read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-12-22/big-mac.csv')
The original source from The Economist https://www.economist.com/big-mac-index. It gives introduction of the idea of Big Mac Index and use it to compare currency valuation by the idea of purchasing power parity.
## pivot the price variables
big_mac_long <- big_mac %>%
pivot_longer(c(usd_raw:cny_raw, usd_adjusted:cny_adjusted),
names_to = c("Currency_type", "Price_type"),
names_sep = "_",
values_to = "Ratio") %>%
mutate(Currency_type = str_to_upper(as_factor(Currency_type)),
Price_type = str_to_upper(as_factor(Price_type)))
Some of the countries doesn’t have complete data set, we filter to the countries has data over the full date range.
## count the number
country_full_33 <- big_mac_long %>%
group_by(name) %>%
count(name) %>%
filter(n == 330)
## filter the country with full data
big_mac_long_33 <- big_mac_long %>%
inner_join(country_full_33, by = "name") %>%
select(-n)
We have a look at the local price behavior over time to see any time trend.
big_mac_long_33 %>%
mutate(name = fct_reorder(name, local_price, function (.) max(.)/min(.))) %>%
ggplot(aes(x = date, y = local_price, colour = name)) +
geom_line() +
expand_limits(y = 0) +
facet_wrap(~ name, scales = "free_y") +
theme(legend.position = "none") +
labs(x = "",
y = "Local Currency Price",
title = "Price change over time (Local rate)")
From the plot we can see Switzerland and Taiwan has hardly changed their price of Big Mac, Denmark has a small increase, while every other countries experienced stable linear growth in price due to inflation. The most notable country is Argentina, where there is hyperinflation showed exponential growth in price.
Let’s see how much each country has grown in price in a summarise plot.
big_mac_long_33 %>%
mutate(name = fct_reorder(name, local_price, function (.) last(.)/first(.))) %>%
group_by(name) %>%
summarise(inflation = last(local_price)/first(local_price)) %>%
ggplot(aes(inflation, name)) +
geom_col() +
geom_text(aes(label = paste0(round(inflation, 1), "X")), hjust = -0.5) +
scale_x_log10(breaks = c(1,3,10, 30, 100)) +
geom_vline(aes(xintercept = median(inflation), colour = "red")) +
theme(legend.position = "none") +
labs(x = "Inflation Rate over Time",
y = "Country",
title = "Inflation Growth on Price 2000-2020") +
expand_limits(x = 110)
We see majority of the country with price change to about 2x of the 2000 level. With the median at 2.2, (it’s about 8% inflation per year), Argentina has troubled economy, so is the high inflation in Brazil. South Africa and Russia is quite high as well. On the other end of the spectrum, Japan is famous for it’s low inflation rate, even lower than Japan, Taiwan, Switzerland and Denmark are worth look into, as their economies are general sound.
big_mac_long_33 %>%
mutate(name = fct_reorder(name, dollar_price, function (.) max(.)/min(.))) %>%
ggplot(aes(x = date, y = dollar_price, colour = name)) +
geom_line() +
expand_limits(y = 0) +
facet_wrap(~ name, scales = "free_y") +
theme(legend.position = "none") +
labs(x = "",
y = "Dollar Price",
title = "Price change over time (Dollar rate)")
Once we convert to dollar price, we see Taiwan is still the top country with it’s stable price, Denmark and Switzerland become more normal compare with other countries. Even Argentina’s hyperinflation is adjusted to regular price. This indicate market force is working here, currency exchange rate change in tandem with local inflation.
big_mac_long_33 %>%
mutate(name = fct_reorder(name, dollar_price, function (.) last(.)/first(.))) %>%
group_by(name) %>%
summarise(inflation = last(dollar_price)/first(dollar_price)) %>%
ggplot(aes(inflation, name)) +
geom_col() +
geom_text(aes(label = paste0(round(inflation, 1), "X")), hjust = -0.5) +
geom_vline(aes(xintercept = median(inflation), colour = "red")) +
theme(legend.position = "none") +
labs(x = "Inflation Rate over Time",
y = "Country",
title = "Inflation Growth on Price 2000-2020 (Dollar rate)") +
expand_limits(x = 3.5)
We now see the inflation rate become more normalised, notice Mexico is at the bottom with 1, so it’s exchange rate has changed a lot to compensate the inflation growth. (i.e. For Mexico the local currency inflation is 2.4x over the period, but the dollar rate inflation is 1x, so the exchange rate growth is 2.4x, which indicate Mexican currency is getting cheaper against dollar, more Mexican currency needed to exchange dollar.)
To visualise these idea better, we will plot the following.
big_mac_long_33 %>%
mutate(name = fct_reorder(name, dollar_ex, function (.) last(.)/first(.))) %>%
ggplot(aes(x = date, y = dollar_ex, colour = name)) +
geom_line() +
facet_wrap(~ name, scales = "free_y") +
scale_y_reverse() +
theme(legend.position = "none") +
labs(x = "",
y = "Dollar Exchange Rate",
title = "Dollar Exchange Rate Growth in 2000-2020",
subtitle = "Inverted Scale")
Dollar is the reference currency here, so we see the exchange rate for United State being constant (1), anything before is strengthening against dollar, while after is weakening against dollar. Switzerland currency gained most against dollar, hence its stable Big Mac price.
As seen from above, once the local price adjusted for exchange rate, we will have an exchanged dollar price (implied price). The discrepancy between the actual dollar price and the implied price, offer a sense about the valuation for the currency from market is overvalued or undervalued with respect to dollar. The raw price is calculated as such, and there are also similar calculation for other common currency such as Euro, British Pound, Chinese Yuan, Japanese Yen.
big_mac_long_33 %>%
filter(Price_type == "RAW") %>%
ggplot(aes(x = date, y = Ratio)) +
geom_point(alpha = 0.2, size = 1) +
geom_smooth(aes(colour = Currency_type)) +
geom_hline(yintercept = 0, colour = "red", size = 1.5) +
facet_wrap(~ Currency_type) +
theme(legend.position = "none") +
labs(x = "",
y = "Valuation Discrepancy Ratio",
title = "Over/Undervaluation wrt Reference Currency")
We see CNY is undervalued in early 2000 (or equivalently, other currency are over valued against it), as all other currency is greater than fair value (0). The trend indicate the valuation of CNY is start to converge towards fair value. EUR, GBP and USD are overvalued against other currency. In particular the dollar is widening the spread, indicate the strengthening of dollar against all other currency. JPY is fair valued against all other currency.
There are also information of the GDP per country, so we can see if the economic size of the economy affect the Big Mac index.
big_mac_long_33 %>%
filter(date == max(date)) %>%
select(name, dollar_price, gdp_dollar) %>% ## prevent overlap data points
distinct_all() %>%
ggplot(aes(gdp_dollar, dollar_price)) +
geom_point() +
geom_smooth(method = lm) +
geom_text_repel(aes(label = name)) +
labs(x = "Dollar GDP per capita",
y = "Dollar Price",
title = "GDP affects on Dollar Price of Big Mac Index")
The plot shows increase in GDP per capita will increase the exchanged dollar price of the Big Mac. Hong Kong is the most notable location where the Big Mac is cheap given their economical strength.
big_mac_long_33 %>%
filter(date == max(date)) %>% ## latest value
select(name, adj_price, gdp_dollar) %>%
distinct_all() %>%
ggplot(aes(gdp_dollar, adj_price)) +
geom_point() +
geom_smooth(method = lm) +
geom_text_repel(aes(label = name)) +
labs(x = "Dollar GDP per capita",
y = "GDP Adjusted Dollar Price",
title = "GDP Adjusted Dollar Price of Big Mac")
## Warning: ggrepel: 7 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
We see a perfect linear relationship, this indicates the Big Mac is priced in consideration of local economical size. The latest price is adjusted for the exchange rate and local GDP. Interestingly this implies the cost of producing Big Mac is not considered, either the cost is same (or very similar) in produce a Big Mac, or the difference in cost should be directly reflected in local franchise’s operating margin.
big_mac_long_33 %>%
filter(Price_type == "ADJUSTED", !is.na(Ratio)) %>%
ggplot(aes(x = date, y = Ratio)) +
geom_point(alpha = 0.2, size = 1) +
geom_smooth(aes(colour = Currency_type)) +
geom_hline(yintercept = 0, colour = "red", size = 1.5) +
facet_wrap(~ Currency_type) +
theme(legend.position = "none") +
labs(x = "",
y = "Valuation Discrepancy Ratio",
title = "GDP Adjusted Big Mac Index")
After adjusting for GDP per capita, we see all the currency are close to the fair value at 0. Therefore we can conclude the Big Mac Index is a very good value to inspect about the exchange rate of a particular currency. Deviation from the reference price in GDP adjusted index warrants check on the comparison currency and their exchange rate.