“The big mac index was invented by The Economist in 1986 as a lighthearted guide to whether currencies are at their “correct” level. It is based on the theory of purchasing-power parity (PPP), the notion that in the long run exchange rates should move towards the rate that would equalise the prices of an identical basket of goods and services (in this case, a burger) in any two countries.” (Source: https://www.economist.com/news/2020/07/15/the-big-mac-index)
Run the following code chunk first to load and clean the data
library(data.table)
library(ggplot2)
library(curl)
## Using libcurl 7.84.0 with Schannel
bigmac <- fread("https://raw.githubusercontent.com/dratnadiwakara/fin4820/master/bigmac.csv")
bigmac_USA <- bigmac[iso_a3=="USA", c("year","local_price")]
setnames(bigmac_USA,"local_price","US_price")
bigmac <- merge(bigmac,bigmac_USA,by="year")
bigmac[,bigmac_ex:= local_price/US_price]
bigmac[,diff:= (bigmac_ex-dollar_ex)/dollar_ex]
bigmac[,undervalued := ifelse(diff<0,1,0)]
head(bigmac)
## year iso_a3 currency_code name local_price dollar_ex dollar_price
## 1: 2000 ARG ARS Argentina 2.50 1.00 2.500000
## 2: 2000 AUS AUD Australia 2.59 1.68 1.541667
## 3: 2000 BRA BRL Brazil 2.95 1.79 1.648045
## 4: 2000 CAN CAD Canada 2.85 1.47 1.938776
## 5: 2000 CHE CHF Switzerland 5.90 1.70 3.470588
## 6: 2000 CHL CLP Chile 1260.00 514.00 2.451362
## gdp_dollar US_price bigmac_ex diff undervalued
## 1: NA 2.51 0.9960159 -0.003984064 1
## 2: NA 2.51 1.0318725 -0.385790173 1
## 3: NA 2.51 1.1752988 -0.343408489 1
## 4: NA 2.51 1.1354582 -0.227579478 1
## 5: NA 2.51 2.3505976 0.382704476 0
## 6: NA 2.51 501.9920319 -0.023361806 1
Data Dictionary: year: Year of observation iso_a3: Three-character ISO 3166-1 country code name: County name local_price: Price of a Big Mac in the local currency dollar_ex: Local currency units per dollar (Exchange rate) dollar_price: Price of a Big Mac in dollars gdp_dollar: GDP per person, in dollars
library(rgdal)
library(rgeos)
worldmap <- readOGR("https://raw.githubusercontent.com/dratnadiwakara/fin4820/master/countries/countries.geojson")
## OGR data source with driver: GeoJSON
## Source: "https://raw.githubusercontent.com/dratnadiwakara/fin4820/master/countries/countries.geojson", layer: "countries"
## with 255 features
## It has 2 fields
worldmap <- data.table(fortify(worldmap,region="ISO_A3"))
worldmap <- merge(worldmap,bigmac[year==2020],by.x="id",by.y="iso_a3",all.x=T)
ggplot(data=worldmap,aes(x=long,y=lat,group=group,fill=dollar_price))+geom_polygon()+
theme_minimal()+
theme(legend.position = "bottom",legend.title =element_blank())+
scale_fill_gradient(low = "yellow", high = "darkred")+
labs(x="",y="",title="Big Mac Prices in 2020 ($)")