Skip to content

Commit

Permalink
January 2021 update
Browse files Browse the repository at this point in the history
  • Loading branch information
martgnz committed Jan 12, 2021
1 parent 3a740db commit 7a27779
Show file tree
Hide file tree
Showing 9 changed files with 1,954 additions and 1,758 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.ipynb_checkpoints
.DS_Store
642 changes: 296 additions & 346 deletions Big Mac data generator.ipynb

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions data-generator.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for(currency in base_currencies) {
by=date
]
}
big_mac_index[, (base_currencies) := lapply(.SD, round, 3L), .SDcols=base_currencies]
big_mac_index[, (base_currencies) := lapply(.SD, round, 5L), .SDcols=base_currencies]

fwrite(big_mac_index, './output-data/big-mac-raw-index.csv')

Expand All @@ -42,7 +42,13 @@ regression_countries = c('ARG', 'AUS', 'BRA', 'GBR', 'CAN', 'CHL', 'CHN', 'CZE',
'KOR', 'SWE', 'CHE', 'TWN', 'THA', 'TUR', 'USA', 'COL', 'PAK',
'IND', 'AUT', 'BEL', 'NLD', 'FIN', 'FRA', 'DEU', 'IRL', 'ITA',
'PRT', 'ESP', 'GRC', 'EST')
big_mac_gdp_data = big_mac_gdp_data[iso_a3 %in% regression_countries]
# in 2021, we added a number of additional countries to the adjusted index
regression_addons_2021 = c('ARE', 'CRI', 'LKA', 'UKR', 'URY', 'VNM', 'GTM', 'HND', 'NIC',
'AZE', 'BHR', 'HRV', 'JOR', 'KWT', 'MDA', 'OMN', 'QAT', 'ROU',
'SVK', 'SVN', 'LVA', 'LTU')
big_mac_gdp_data = big_mac_gdp_data[iso_a3 %in% regression_countries |
(iso_a3 %in% regression_addons_2021 & date >= as.Date('2021-01-01'))
]

big_mac_gdp_data[,adj_price := lm(dollar_price ~ GDP_dollar)$fitted.values, by=date]

Expand All @@ -58,7 +64,7 @@ for(currency in base_currencies) {
by=date
]
}
big_mac_adj_index[, (base_currencies) := lapply(.SD, round, 3L), .SDcols=base_currencies]
big_mac_adj_index[, (base_currencies) := lapply(.SD, round, 5L), .SDcols=base_currencies]

fwrite(big_mac_adj_index, './output-data/big-mac-adjusted-index.csv')

Expand Down
10 changes: 5 additions & 5 deletions generate-excel.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ data = fread('./output-data/big-mac-full-index.csv') %>%
yuan_adj_valuation = CNY_adjusted * 100
), by=date]

dates = data$date %>% unique
dates = data$date %>% unique %>% sort(., decreasing = T)

wb = createWorkbook(type='xls')

for(sheetDate in sort(dates, decreasing = T)) {
dateStr = sheetDate %>% strftime(format='%b%Y')
for(sheetDate in seq_along(dates)) {
dateStr = dates[sheetDate] %>% strftime(format='%b%Y')
sheet = createSheet(wb, sheetName = dateStr)
xlsx.addTable(wb, sheet, data[date == sheetDate, -1], row.names=FALSE, startCol=1)
xlsx.addTable(wb, sheet, data[date == dates[sheetDate], -1], row.names=FALSE, startCol=1)
}

saveWorkbook(wb, paste0('./output-data/big-mac-',max(dates),'.xls'))
saveWorkbook(wb, paste0('./output-data/big-mac-',max(dates),'.xls'))
Binary file added output-data/big-mac-2021-01-01.xls
Binary file not shown.
1,459 changes: 757 additions & 702 deletions output-data/big-mac-adjusted-index.csv

Large diffs are not rendered by default.

1,460 changes: 758 additions & 702 deletions output-data/big-mac-full-index.csv

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions output-data/big-mac-raw-index.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1385,3 +1385,59 @@ date,iso_a3,currency_code,name,local_price,dollar_ex,dollar_price,USD,EUR,GBP,JP
2020-07-01,USA,USD,United States,5.71,1,5.71,0,0.19303,0.33494,0.57062,0.84286
2020-07-01,URY,UYU,Uruguay,189,43.675,4.32741843159702,-0.24213,-0.09584,0.01171,0.19032,0.39664
2020-07-01,VNM,VND,Vietnam,66000,23180,2.84728213977567,-0.50135,-0.4051,-0.33433,-0.21681,-0.08106
2021-01-01,ARG,ARS,Argentina,320,85.3736,3.74823130335373,-0.33777,-0.27416,-0.15537,0.00236,0.08349
2021-01-01,AUS,AUD,Australia,6.48,1.29996750081248,4.98474,-0.1193,-0.03471,0.12327,0.33303,0.44092
2021-01-01,AZE,AZN,Azerbaijan,3.95,1.699,2.32489699823426,-0.58924,-0.54978,-0.47611,-0.37827,-0.32795
2021-01-01,BHR,BHD,Bahrain,1.5,0.377,3.97877984084881,-0.29704,-0.22951,-0.10342,0.06402,0.15013
2021-01-01,BRA,BRL,Brazil,21.9,5.5046,3.97849071685499,-0.29709,-0.22957,-0.10348,0.06394,0.15005
2021-01-01,GBR,GBP,Britain,3.29,0.741372280090447,4.4377165,-0.21595,-0.14064,0,0.18675,0.2828
2021-01-01,CAN,CAD,Canada,6.77,1.2803,5.28782316644536,-0.06576,0.02399,0.19156,0.41409,0.52853
2021-01-01,CHL,CLP,Chile,2940,719.425,4.0865969350523,-0.27799,-0.20863,-0.07912,0.09285,0.1813
2021-01-01,CHN,CNY,China,22.4,6.4751,3.45940603233927,-0.3888,-0.33009,-0.22045,-0.07487,0
2021-01-01,COL,COP,Colombia,12950,3460.5,3.74223378124549,-0.33883,-0.27532,-0.15672,0.00076,0.08176
2021-01-01,CRI,CRC,Costa Rica,2350,613.77,3.82879580298809,-0.32353,-0.25855,-0.13721,0.02391,0.10678
2021-01-01,HRV,HRK,Croatia,23,6.23875,3.68663594470046,-0.34865,-0.28608,-0.16925,-0.01411,0.06568
2021-01-01,CZE,CZK,Czech Republic,89,21.5909,4.12210699878189,-0.27171,-0.20176,-0.07112,0.10235,0.19156
2021-01-01,DNK,DKK,Denmark,30,6.12065,4.90144020651401,-0.13402,-0.05084,0.1045,0.31076,0.41684
2021-01-01,EGY,EGP,Egypt,42.5,15.64,2.71739130434783,-0.5199,-0.47378,-0.38766,-0.27331,-0.21449
2021-01-01,EUZ,EUR,Euro area,4.25,0.823011398707872,5.1639625,-0.08764,0,0.16365,0.38096,0.49273
2021-01-01,GTM,GTQ,Guatemala,25,7.8009,3.2047584253099,-0.43379,-0.3794,-0.27784,-0.14297,-0.07361
2021-01-01,HND,HNL,Honduras,87,24.103,3.60950918972742,-0.36228,-0.30102,-0.18663,-0.03473,0.04339
2021-01-01,HKG,HKD,Hong Kong,20.5,7.75535,2.64333653542393,-0.53298,-0.48812,-0.40435,-0.29311,-0.2359
2021-01-01,HUN,HUF,Hungary,900,297.42395,3.02598361698848,-0.46537,-0.41402,-0.31812,-0.19078,-0.12529
2021-01-01,IND,INR,India,190,73.39,2.58890857064995,-0.5426,-0.49866,-0.41661,-0.30767,-0.25163
2021-01-01,IDN,IDR,Indonesia,34000,14125,2.4070796460177,-0.57472,-0.53387,-0.45759,-0.35629,-0.30419
2021-01-01,ISR,ILS,Israel,17,3.179,5.3475935828877,-0.0552,0.03556,0.20503,0.43007,0.54581
2021-01-01,JPN,JPY,Japan,390,104.295,3.73939306774054,-0.33933,-0.27587,-0.15736,0,0.08094
2021-01-01,JOR,JOD,Jordan,2.3,0.709,3.24400564174894,-0.42685,-0.3718,-0.26899,-0.13248,-0.06227
2021-01-01,KWT,KWD,Kuwait,1.15,0.3037,3.78663154428713,-0.33098,-0.26672,-0.14672,0.01263,0.09459
2021-01-01,LBN,LBP,Lebanon,15500,8750,1.77142857142857,-0.68703,-0.65696,-0.60082,-0.52628,-0.48794
2021-01-01,MYS,MYR,Malaysia,9.99,4.052,2.46544916090819,-0.56441,-0.52257,-0.44443,-0.34068,-0.28732
2021-01-01,MEX,MXN,Mexico,54,20.11475,2.68459712400104,-0.52569,-0.48013,-0.39505,-0.28208,-0.22397
2021-01-01,MDA,MDL,Moldova,50,17.225,2.90275761973875,-0.48715,-0.43788,-0.34589,-0.22374,-0.16091
2021-01-01,NZL,NZD,New Zealand,6.8,1.39508928571429,4.87423999999998,-0.13883,-0.0561,0.09837,0.30348,0.40898
2021-01-01,NIC,NIO,Nicaragua,124,34.8453,3.55858609338993,-0.37127,-0.31088,-0.1981,-0.04835,0.02867
2021-01-01,NOR,NOK,Norway,52,8.5439,6.08621355587027,0.0753,0.17859,0.37147,0.62759,0.75932
2021-01-01,OMN,OMR,Oman,1.1,0.385,2.85714285714286,-0.4952,-0.44672,-0.35617,-0.23593,-0.17409
2021-01-01,PAK,PKR,Pakistan,550,160.35,3.42999688182102,-0.39399,-0.33578,-0.22708,-0.08274,-0.0085
2021-01-01,PER,PEN,Peru,11.9,3.6207,3.28665727621731,-0.41932,-0.36354,-0.25938,-0.12107,-0.04994
2021-01-01,PHL,PHP,Philippines,142,48.0925,2.95264334355669,-0.47833,-0.42822,-0.33465,-0.2104,-0.14649
2021-01-01,POL,PLN,Poland,13.08,3.7226,3.51367323913394,-0.37921,-0.31958,-0.20822,-0.06036,0.01569
2021-01-01,QAT,QAR,Qatar,13,3.641,3.57044767920901,-0.36918,-0.30858,-0.19543,-0.04518,0.0321
2021-01-01,ROU,RON,Romania,9.9,4.0089,2.46950535059493,-0.56369,-0.52178,-0.44352,-0.3396,-0.28615
2021-01-01,RUS,RUB,Russia,135,74.63,1.80892402519094,-0.6804,-0.6497,-0.59238,-0.51625,-0.4771
2021-01-01,SAU,SAR,Saudi Arabia,14,3.7518,3.73154219308065,-0.34072,-0.27739,-0.15913,-0.0021,0.07867
2021-01-01,SGP,SGD,Singapore,5.9,1.3308,4.43342350465885,-0.21671,-0.14147,-0.00097,0.1856,0.28156
2021-01-01,ZAF,ZAR,South Africa,33.5,15.5225,2.15815751328716,-0.6187,-0.58207,-0.51368,-0.42286,-0.37615
2021-01-01,KOR,KRW,South Korea,4500,1097.35,4.10078826263271,-0.27548,-0.20588,-0.07592,0.09665,0.1854
2021-01-01,LKA,LKR,Sri Lanka,700,189,3.7037037037037,-0.34564,-0.28278,-0.1654,-0.00954,0.07062
2021-01-01,SWE,SEK,Sweden,52.88,8.29525,6.37473252765137,0.12628,0.23447,0.43649,0.70475,0.84272
2021-01-01,CHE,CHF,Switzerland,6.5,0.89155,7.29067354607145,0.2881,0.41184,0.64289,0.94969,1.10749
2021-01-01,TWN,TWD,Taiwan,72,27.98,2.57326661901358,-0.54536,-0.50169,-0.42014,-0.31185,-0.25615
2021-01-01,THA,THB,Thailand,128,30.13,4.24825755061401,-0.24942,-0.17733,-0.04269,0.13608,0.22803
2021-01-01,TUR,TRY,Turkey,14.99,7.4705,2.00655913258818,-0.64548,-0.61143,-0.54784,-0.4634,-0.41997
2021-01-01,UKR,UAH,Ukraine,62,28.14,2.20326936744847,-0.61073,-0.57334,-0.50351,-0.41079,-0.36311
2021-01-01,ARE,AED,United Arab Emirates,14.75,3.67315,4.01562691422893,-0.29053,-0.22237,-0.09511,0.07387,0.16079
2021-01-01,USA,USD,United States,5.66,1,5.66,0,0.09606,0.27543,0.51361,0.63612
2021-01-01,URY,UYU,Uruguay,204,42.495,4.80056477232616,-0.15184,-0.07037,0.08176,0.28378,0.38768
2021-01-01,VNM,VND,Vietnam,66000,23064,2.86160249739854,-0.49442,-0.44585,-0.35516,-0.23474,-0.17281
72 changes: 72 additions & 0 deletions source-data/big-mac-source-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1657,3 +1657,75 @@ Uruguay,URY,UYU,189,43.675,17014.132,2020-07-01
United States,USA,USD,5.71,1,62868.917,2020-07-01
Vietnam,VNM,VND,66000,23180,2551.123,2020-07-01
South Africa,ZAF,ZAR,31,16.6725,6353.846,2020-07-01
United Arab Emirates,ARE,AED,14.75,3.67315,39179.883,2021-01-01
Argentina,ARG,ARS,320,85.3736,9890.314,2021-01-01
Australia,AUS,AUD,6.48,1.29996750081248,54348.227,2021-01-01
Austria,AUT,EUR,3.88,0.823011398707872,50380.282,2021-01-01
Azerbaijan,AZE,AZN,3.95,1.699,4813.67,2021-01-01
Belgium,BEL,EUR,4.35,0.823011398707872,46236.67,2021-01-01
Bahrain,BHR,BHD,1.5,0.377,25997.583,2021-01-01
Brazil,BRA,BRL,21.9,5.5046,8751.381,2021-01-01
Canada,CAN,CAD,6.77,1.2803,46271.717,2021-01-01
Switzerland,CHE,CHF,6.5,0.89155,82483.925,2021-01-01
Chile,CHL,CLP,2940,719.425,14772.111,2021-01-01
China,CHN,CNY,22.4,6.4751,10286.58,2021-01-01
Colombia,COL,COP,12950,3460.5,6423.179,2021-01-01
Costa Rica,CRI,CRC,2350,613.77,12243.842,2021-01-01
Czech Republic,CZE,CZK,89,21.5909,23538.518,2021-01-01
Germany,DEU,EUR,4.46,0.823011398707872,46472.623,2021-01-01
Denmark,DNK,DKK,30,6.12065,59770.324,2021-01-01
Egypt,EGY,EGP,42.5,15.64,3043.64,2021-01-01
Spain,ESP,EUR,4.33,0.823011398707872,29993.061,2021-01-01
Estonia,EST,EUR,3.2,0.823011398707872,23757.617,2021-01-01
Euro area,EUZ,EUR,4.25,0.823011398707872,39378.2868561122,2021-01-01
Finland,FIN,EUR,4.87,0.823011398707872,48809.551,2021-01-01
France,FRA,EUR,4.2,0.823011398707872,41896.577,2021-01-01
Britain,GBR,GBP,3.29,0.741372280090447,42378.606,2021-01-01
Greece,GRC,EUR,3.3,0.823011398707872,19569.531,2021-01-01
Guatemala,GTM,GTQ,25,7.8009,4354.336,2021-01-01
Hong Kong,HKG,HKD,20.5,7.75535,48626.576,2021-01-01
Honduras,HND,HNL,87,24.103,2550.666,2021-01-01
Croatia,HRV,HRK,23,6.23875,14853.016,2021-01-01
Hungary,HUN,HUF,900,297.42395,16469.607,2021-01-01
Indonesia,IDN,IDR,34000,14125,4196.67,2021-01-01
India,IND,INR,190,73.39,2097.782,2021-01-01
Ireland,IRL,EUR,4.4,0.823011398707872,80504.404,2021-01-01
Israel,ISR,ILS,17,3.179,43603.013,2021-01-01
Italy,ITA,EUR,4.3,0.823011398707872,33159.068,2021-01-01
Jordan,JOR,JOD,2.3,0.709,4425.687,2021-01-01
Japan,JPN,JPY,390,104.295,40255.936,2021-01-01
South Korea,KOR,KRW,4500,1097.35,31846.217,2021-01-01
Kuwait,KWT,KWD,1.15,0.3037,28499.788,2021-01-01
Lebanon,LBN,LBP,15500,8750,7661.073,2021-01-01
Sri Lanka,LKA,LKR,700,189,3852.484,2021-01-01
Lithuania,LTU,EUR,2.9,0.823011398707872,19482.142,2021-01-01
Latvia,LVA,EUR,2.85,0.823011398707872,17771.634,2021-01-01
Moldova,MDA,MDL,50,17.225,4458.192,2021-01-01
Mexico,MEX,MXN,54,20.11475,9862.44,2021-01-01
Malaysia,MYS,MYR,9.99,4.052,11193.016,2021-01-01
Nicaragua,NIC,NIO,124,34.8453,1920.291,2021-01-01
Netherlands,NLD,EUR,4.13,0.823011398707872,52646.193,2021-01-01
Norway,NOR,NOK,52,8.5439,75294.428,2021-01-01
New Zealand,NZL,NZD,6.8,1.39508928571429,41666.635,2021-01-01
Oman,OMN,OMR,1.1,0.385,18198.309,2021-01-01
Pakistan,PAK,PKR,550,160.35,1348.676,2021-01-01
Peru,PER,PEN,11.9,3.6207,6957.864,2021-01-01
Philippines,PHL,PHP,142,48.0925,3511.935,2021-01-01
Poland,POL,PLN,13.08,3.7226,15600.657,2021-01-01
Portugal,PRT,EUR,3.45,0.823011398707872,23132.455,2021-01-01
Qatar,QAT,QAR,13,3.641,62918.848,2021-01-01
Romania,ROU,RON,9.9,4.0089,12887.06,2021-01-01
Russia,RUS,RUB,135,74.63,11601.418,2021-01-01
Saudi Arabia,SAU,SAR,14,3.7518,23266.486,2021-01-01
Singapore,SGP,SGD,5.9,1.3308,65233.88,2021-01-01
Slovakia,SVK,EUR,3.7,0.823011398707872,19344.174,2021-01-01
Slovenia,SVN,EUR,2.5,0.823011398707872,25992.066,2021-01-01
Sweden,SWE,SEK,52.88,8.29525,51404.434,2021-01-01
Thailand,THA,THB,128,30.13,7806.961,2021-01-01
Turkey,TUR,TRY,14.99,7.4705,9150.862,2021-01-01
Taiwan,TWN,TWD,72,27.98,25873.367,2021-01-01
Ukraine,UKR,UAH,62,28.14,3706.765,2021-01-01
Uruguay,URY,UYU,204,42.495,16110.742,2021-01-01
United States,USA,USD,5.66,1,65253.518,2021-01-01
Vietnam,VNM,VND,66000,23064,3416.232,2021-01-01
South Africa,ZAF,ZAR,33.5,15.5225,5977.954,2021-01-01

0 comments on commit 7a27779

Please sign in to comment.