Skip to content

Commit

Permalink
July data update
Browse files Browse the repository at this point in the history
commit 342384952163c86255e5119dfb8322b2aca7b52b
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Wed Jul 11 17:55:13 2018 +0100

    Added Excel.

commit 31f992432e612a86585470b0d5c9e08167de0dc3
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Wed Jul 11 15:17:58 2018 +0000

    Minor fix.

commit 518550fee07d994dfad58774e8a27ead8a015e45
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Wed Jul 11 14:57:25 2018 +0000

    Correcting Euro-area figures.

commit 6363f73493b0304fa574ea473d16805c2a85f7bf
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Wed Jul 11 11:22:56 2018 +0000

    Update R script.

commit f1a468c35a4c2ee9cd2b55f32828c7859d34f656
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Wed Jul 11 11:21:41 2018 +0000

    Updated with final data.

commit 72d770a74f62a9a322fe903c6c5bc49153cf7407
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Tue Jul 10 18:52:19 2018 +0100

    New-ish data.

commit 9e0575601cdfc174bdce41b364a2bffef93455ef
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Tue Jul 10 12:24:47 2018 +0100

    Now with updated data and correct country names.

commit a7f70acb5f0d07d5519c34eb75760535c38d1d55
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Tue Jul 10 12:01:19 2018 +0100

    Update for regression.

commit 93201141016b31e8980a2ac8cc7baa0839d56fb6
Author: Evan Hensleigh <futuraprime@gmail.com>
Date:   Tue Jul 10 11:55:06 2018 +0100

    Adding July numbers.
  • Loading branch information
futuraprime committed Jul 11, 2018
1 parent 4858c7c commit 2add4db
Show file tree
Hide file tree
Showing 8 changed files with 791 additions and 382 deletions.
669 changes: 393 additions & 276 deletions Big Mac data generator.ipynb

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions data-generator.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
library('tidyverse')
library('data.table')

big_mac_countries = c('ARG', 'AUS', 'BRA', 'GBR', 'CAN', 'CHL', 'CHN', 'CZE', 'DNK',
'EGY', 'HKG', 'HUN', 'IDN', 'ISR', 'JPN', 'MYS', 'MEX', 'NZL',
'NOR', 'PER', 'PHL', 'POL', 'RUS', 'SAU', 'SGP', 'ZAF', 'KOR',
'SWE', 'CHE', 'TWN', 'THA', 'TUR', 'ARE', 'USA', 'COL', 'CRI',
'PAK', 'LKA', 'UKR', 'URY', 'IND', 'VNM', 'GTM', 'HND', # Venezuela removed
'NIC', 'AZE', 'BHR', 'HRV', 'JOR', 'KWT', 'LBN', 'MDA', 'OMN',
'QAT', 'ROU', 'EUZ')
base_currencies = c('USD', 'EUR', 'GBP', 'JPY', 'CNY')

big_mac_data = fread('./source-data/big-mac-source-data.csv', na.strings = '#N/A') %>%
.[!is.na(local_price)] %>% # remove lines where the local price is missing
.[,GDP_dollar := as.numeric(GDP_dollar)] %>% # convert GDP to a number
.[order(date, name)] # sort by date and then by country name, for easy reading

latest_date = big_mac_data$date %>% max

big_mac_data[, dollar_price := local_price / dollar_ex]

big_mac_index = big_mac_data[
!is.na(dollar_price) & iso_a3 %in% big_mac_countries
,.(date, iso_a3, currency_code, name, local_price, dollar_ex, dollar_price)]

for(currency in base_currencies) {
big_mac_index[
,
(currency) := dollar_price / .SD[currency_code == currency]$dollar_price - 1,
by=date
]
}
big_mac_index[, (base_currencies) := round(.SD, 3), .SDcols=base_currencies]

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

big_mac_gdp_data = big_mac_data[GDP_dollar > 0]

regression_countries = c('ARG', 'AUS', 'BRA', 'GBR', 'CAN', 'CHL', 'CHN', 'CZE', 'DNK',
'EGY', 'EUZ', 'HKG', 'HUN', 'IDN', 'ISR', 'JPN', 'MYS', 'MEX',
'NZL', 'NOR', 'PER', 'PHL', 'POL', 'RUS', 'SAU', 'SGP', 'ZAF',
'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]

big_mac_gdp_data[,adj_price := lm(dollar_price ~ GDP_dollar) %>% predict,by=date]

big_mac_adj_index = big_mac_gdp_data[
!is.na(dollar_price) & iso_a3 %in% regression_countries & iso_a3 %in% big_mac_countries
,.(date, iso_a3, currency_code, name, local_price, dollar_ex, dollar_price, GDP_dollar, adj_price)]

for(currency in base_currencies) {
big_mac_adj_index[
,
(currency) := (dollar_price / adj_price) /
(.SD[currency_code == currency]$dollar_price / .SD[currency_code == currency]$adj_price ) - 1,
by=date
]
}
big_mac_adj_index[, (base_currencies) := round(.SD, 3), .SDcols=base_currencies]

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

big_mac_full_index = merge(big_mac_index, big_mac_adj_index,
by=c('date', 'iso_a3', 'currency_code', 'name', 'local_price', 'dollar_ex', 'dollar_price'),
suffixes=c('_raw', '_adjusted'),
all.x=TRUE
)

fwrite(big_mac_full_index, './output-data/big-mac-full-index.csv')
Binary file removed output-data/big-mac-2018-01-01.xls
Binary file not shown.
Binary file added output-data/big-mac-2018-07-01.xls
Binary file not shown.
141 changes: 89 additions & 52 deletions output-data/big-mac-adjusted-index.csv

Large diffs are not rendered by default.

160 changes: 108 additions & 52 deletions output-data/big-mac-full-index.csv

Large diffs are not rendered by default.

58 changes: 57 additions & 1 deletion output-data/big-mac-raw-index.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ date,iso_a3,currency_code,name,local_price,dollar_ex,dollar_price,USD,EUR,GBP,JP
2018-01-01,HKG,HKD,Hong Kong,20.5,7.819,2.62181864688579,-0.503,-0.458,-0.406,-0.236,-0.173
2018-01-01,HUN,HUF,Hungary,864,252.14215,3.42663850530346,-0.351,-0.291,-0.224,-0.002,0.08
2018-01-01,IND,INR,India,180,63.86125,2.81861065982893,-0.466,-0.417,-0.361,-0.179,-0.111
2018-01-01,IDN,IDR,Indonesia,35750,13359,2.67609851036754,-0.493,-0.447,-0.394,-0.22,-0.156
2018-01-01,IDN,IDR,Indonesia,32500,13359,2.43281682760686,-0.539,-0.497,-0.449,-0.291,-0.233
2018-01-01,ISR,ILS,Israel,16.5,3.43635,4.80160635558078,-0.091,-0.007,0.088,0.399,0.514
2018-01-01,JPN,JPY,Japan,380,110.725,3.43192594265071,-0.35,-0.29,-0.222,0,0.082
2018-01-01,MYS,MYR,Malaysia,9,3.954,2.27617602427921,-0.569,-0.529,-0.484,-0.337,-0.282
Expand All @@ -1105,3 +1105,59 @@ date,iso_a3,currency_code,name,local_price,dollar_ex,dollar_price,USD,EUR,GBP,JP
2018-01-01,USA,USD,United States,5.28,1,5.28,0,0.092,0.196,0.538,0.665
2018-01-01,URY,UYU,Uruguay,140,28.58,4.89853044086774,-0.072,0.013,0.11,0.427,0.544
2018-01-01,VNM,VND,Vietnam,65000,22711.5,2.86198621843559,-0.458,-0.408,-0.351,-0.166,-0.098
2018-07-01,ARG,ARS,Argentina,75,27.725,2.70513976555455,-0.509,-0.429,-0.361,-0.228,-0.126
2018-07-01,AUS,AUD,Australia,6.05,1.33985395591881,4.51541749999998,-0.181,-0.046,0.067,0.288,0.459
2018-07-01,AZE,AZN,Azerbaijan,3.95,1.70175,2.32114000293815,-0.579,-0.51,-0.451,-0.338,-0.25
2018-07-01,BHR,BHD,Bahrain,1.2,0.37955,3.16163878276907,-0.426,-0.332,-0.253,-0.098,0.021
2018-07-01,BRA,BRL,Brazil,16.9,3.83835,4.40293355217737,-0.201,-0.07,0.041,0.256,0.422
2018-07-01,GBR,GBP,Britain,3.19,0.753863550697324,4.231535,-0.232,-0.106,0,0.207,0.367
2018-07-01,CAN,CAD,Canada,6.65,1.31235,5.06724578047015,-0.08,0.07,0.197,0.445,0.637
2018-07-01,CHL,CLP,Chile,2640,651.73,4.05075721541129,-0.265,-0.145,-0.043,0.156,0.308
2018-07-01,CHN,CNY,China,20.5,6.622,3.09574146783449,-0.438,-0.346,-0.268,-0.117,0
2018-07-01,COL,COP,Colombia,11900,2874.07,4.14046978674841,-0.249,-0.126,-0.022,0.181,0.337
2018-07-01,CRI,CRC,Costa Rica,2290,567.8,4.03311025008806,-0.268,-0.148,-0.047,0.15,0.303
2018-07-01,HRV,HRK,Croatia,21,6.31275,3.32660092669597,-0.396,-0.297,-0.214,-0.051,0.075
2018-07-01,CZE,CZK,Czech Republic,75,22.06475,3.39908677868546,-0.383,-0.282,-0.197,-0.03,0.098
2018-07-01,DNK,DKK,Denmark,30,6.3591,4.71764872387602,-0.144,-0.004,0.115,0.346,0.524
2018-07-01,EGY,EGP,Egypt,31.37,17.905,1.7520245741413,-0.682,-0.63,-0.586,-0.5,-0.434
2018-07-01,EUZ,EUR,Euro area,4.04,0.853205921249094,4.735082,-0.141,0,0.119,0.351,0.53
2018-07-01,GTM,GTQ,Guatemala,25,7.4871,3.33907654499072,-0.394,-0.295,-0.211,-0.048,0.079
2018-07-01,HND,HNL,Honduras,85,23.9926,3.54275901736369,-0.357,-0.252,-0.163,0.011,0.144
2018-07-01,HKG,HKD,Hong Kong,20,7.84825,2.54833880164368,-0.538,-0.462,-0.398,-0.273,-0.177
2018-07-01,HUN,HUF,Hungary,850,276.4302,3.07491728472504,-0.442,-0.351,-0.273,-0.123,-0.007
2018-07-01,IND,INR,India,173,68.825,2.51362150381402,-0.544,-0.469,-0.406,-0.283,-0.188
2018-07-01,IDN,IDR,Indonesia,31500,14360,2.19359331476323,-0.602,-0.537,-0.482,-0.374,-0.291
2018-07-01,ISR,ILS,Israel,17,3.6349,4.67688244518419,-0.151,-0.012,0.105,0.334,0.511
2018-07-01,JPN,JPY,Japan,390,111.25,3.50561797752809,-0.364,-0.26,-0.172,0,0.132
2018-07-01,JOR,JOD,Jordan,1.95,0.71005,2.74628547285402,-0.502,-0.42,-0.351,-0.217,-0.113
2018-07-01,KWT,KWD,Kuwait,1.05,0.3025,3.47107438016529,-0.37,-0.267,-0.18,-0.01,0.121
2018-07-01,LBN,LBP,Lebanon,6500,1511,4.3017868960953,-0.219,-0.092,0.017,0.227,0.39
2018-07-01,MYS,MYR,Malaysia,8.45,4.0225,2.10068365444375,-0.619,-0.556,-0.504,-0.401,-0.321
2018-07-01,MEX,MXN,Mexico,49,19.0515,2.57197595989817,-0.533,-0.457,-0.392,-0.266,-0.169
2018-07-01,MDA,MDL,Moldova,43,16.6526,2.58217935937932,-0.531,-0.455,-0.39,-0.263,-0.166
2018-07-01,NZL,NZD,New Zealand,6.2,1.46434324205594,4.23397999999999,-0.232,-0.106,0.001,0.208,0.368
2018-07-01,NIC,NIO,Nicaragua,103,31.5872,3.26081450714213,-0.408,-0.311,-0.229,-0.07,0.053
2018-07-01,NOR,NOK,Norway,42,8.0415,5.22290617422123,-0.052,0.103,0.234,0.49,0.687
2018-07-01,OMN,OMR,Oman,1.05,0.385,2.72727272727273,-0.505,-0.424,-0.355,-0.222,-0.119
2018-07-01,PAK,PKR,Pakistan,375,121.49,3.08667380031278,-0.44,-0.348,-0.271,-0.12,-0.003
2018-07-01,PER,PEN,Peru,10.5,3.2715,3.20953690967446,-0.418,-0.322,-0.242,-0.084,0.037
2018-07-01,PHL,PHP,Philippines,140,53.487,2.61745844784714,-0.525,-0.447,-0.381,-0.253,-0.154
2018-07-01,POL,PLN,Poland,10.1,3.68695,2.73939163807483,-0.503,-0.421,-0.353,-0.219,-0.115
2018-07-01,QAT,QAR,Qatar,12,3.641,3.29579785773139,-0.402,-0.304,-0.221,-0.06,0.065
2018-07-01,ROU,RON,Romania,9.2,3.97325,2.31548480463097,-0.58,-0.511,-0.453,-0.339,-0.252
2018-07-01,RUS,RUB,Russia,130,62.14065,2.09202832606353,-0.62,-0.558,-0.506,-0.403,-0.324
2018-07-01,SAU,SAR,Saudi Arabia,12,3.7504,3.19965870307167,-0.419,-0.324,-0.244,-0.087,0.034
2018-07-01,SGP,SGD,Singapore,5.8,1.35585,4.27775933915994,-0.224,-0.097,0.011,0.22,0.382
2018-07-01,ZAF,ZAR,South Africa,31,13.3619,2.32002933714517,-0.579,-0.51,-0.452,-0.338,-0.251
2018-07-01,KOR,KRW,South Korea,4500,1116,4.03225806451613,-0.268,-0.148,-0.047,0.15,0.303
2018-07-01,LKA,LKR,Sri Lanka,580,159.27,3.64161486783449,-0.339,-0.231,-0.139,0.039,0.176
2018-07-01,SWE,SEK,Sweden,51,8.7526,5.82684002467838,0.058,0.231,0.377,0.662,0.882
2018-07-01,CHE,CHF,Switzerland,6.5,0.99325,6.54417316889001,0.188,0.382,0.547,0.867,1.114
2018-07-01,TWN,TWD,Taiwan,69,30.3725,2.27179191703021,-0.588,-0.52,-0.463,-0.352,-0.266
2018-07-01,THA,THB,Thailand,119,33.17,3.5875791377751,-0.349,-0.242,-0.152,0.023,0.159
2018-07-01,TUR,TRY,Turkey,10.75,4.70625,2.28419654714475,-0.585,-0.518,-0.46,-0.348,-0.262
2018-07-01,UKR,UAH,Ukraine,50,26.199,1.90846978892324,-0.654,-0.597,-0.549,-0.456,-0.384
2018-07-01,ARE,AED,United Arab Emirates,14,3.67315,3.81144249486136,-0.308,-0.195,-0.099,0.087,0.231
2018-07-01,USA,USD,United States,5.51,1,5.51,0,0.164,0.302,0.572,0.78
2018-07-01,URY,UYU,Uruguay,140,31.31,4.47141488342383,-0.188,-0.056,0.057,0.275,0.444
2018-07-01,VNM,VND,Vietnam,65000,23039.5,2.82124178042058,-0.488,-0.404,-0.333,-0.195,-0.089
74 changes: 73 additions & 1 deletion source-data/big-mac-source-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ Greece,GRC,EUR,3.35,0.816826629,18049.302,2018-01-01
Hong Kong,HKG,HKD,20.5,7.819,43561.08,2018-01-01
Hungary,HUN,HUF,864,252.14215,12652.454,2018-01-01
India,IND,INR,180,63.86125,1741.652,2018-01-01
Indonesia,IDN,IDR,35750,13359,3604.291,2018-01-01
Indonesia,IDN,IDR,32500,13359,3604.291,2018-01-01
Ireland,IRL,EUR,4.07,0.816826629,64782.3,2018-01-01
Israel,ISR,ILS,16.5,3.43635,37192.14,2018-01-01
Italy,ITA,EUR,4.2,0.816826629,30507.181,2018-01-01
Expand Down Expand Up @@ -1297,3 +1297,75 @@ United States,USA,USD,5.28,1,57607.613,2018-01-01
Uruguay,URY,UYU,140,28.58,,2018-01-01
Venezuela,VEN,VEF,0,0,,2018-01-01
Vietnam,VNM,VND,65000,22711.5,,2018-01-01
United Arab Emirates,ARE,AED,14,3.67315,37225.745,2018-07-01
Argentina,ARG,ARS,75,27.725,14466.552,2018-07-01
Australia,AUS,AUD,6.05,1.33985395591881,55707.275,2018-07-01
Austria,AUT,EUR,3.4,0.853205921249094,47289.997,2018-07-01
Azerbaijan,AZE,AZN,3.95,1.70175,4140.65,2018-07-01
Belgium,BEL,EUR,4.1,0.853205921249094,43582.165,2018-07-01
Bahrain,BHR,BHD,1.2,0.37955,24028.728,2018-07-01
Brazil,BRA,BRL,16.9,3.83835,9894.929,2018-07-01
Canada,CAN,CAD,6.65,1.31235,45077.388,2018-07-01
Switzerland,CHE,CHF,6.5,0.99325,80590.91,2018-07-01
Chile,CHL,CLP,2640,651.73,15070.413,2018-07-01
China,CHN,CNY,20.5,6.622,8643.107,2018-07-01
Colombia,COL,COP,11900,2874.07,6272.818,2018-07-01
Costa Rica,CRI,CRC,2290,567.8,11685.161,2018-07-01
Czech Republic,CZE,CZK,75,22.06475,20152.408,2018-07-01
Germany,DEU,EUR,4.12,0.853205921249094,44549.688,2018-07-01
Denmark,DNK,DKK,30,6.3591,56444.103,2018-07-01
Egypt,EGY,EGP,31.37,17.905,2500.772,2018-07-01
Spain,ESP,EUR,4.1,0.853205921249094,28358.808,2018-07-01
Estonia,EST,EUR,3.15,0.853205921249094,19840.135,2018-07-01
Euro area,EUZ,EUR,4.04,0.853205921249094,37250.2902759764,2018-07-01
Finland,FIN,EUR,4.62,0.853205921249094,46016.744,2018-07-01
France,FRA,EUR,4.2,0.853205921249094,39869.075,2018-07-01
Britain,GBR,GBP,3.19,0.753863550697324,39734.592,2018-07-01
Greece,GRC,EUR,3.35,0.853205921249094,18637.27,2018-07-01
Guatemala,GTM,GTQ,25,7.4871,4471.873,2018-07-01
Hong Kong,HKG,HKD,20,7.84825,46109.124,2018-07-01
Honduras,HND,HNL,85,23.9926,2765.881,2018-07-01
Croatia,HRV,HRK,21,6.31275,13138.288,2018-07-01
Hungary,HUN,HUF,850,276.4302,15531.209,2018-07-01
Indonesia,IDN,IDR,31500,14360,3875.771,2018-07-01
India,IND,INR,173,68.825,1982.702,2018-07-01
Ireland,IRL,EUR,4.07,0.853205921249094,70638.259,2018-07-01
Israel,ISR,ILS,17,3.6349,40258.361,2018-07-01
Italy,ITA,EUR,4.2,0.853205921249094,31984.013,2018-07-01
Jordan,JOR,JOD,1.95,0.71005,5677.617,2018-07-01
Japan,JPN,JPY,390,111.25,38439.517,2018-07-01
South Korea,KOR,KRW,4500,1116,29891.255,2018-07-01
Kuwait,KWT,KWD,1.05,0.3025,27318.517,2018-07-01
Lebanon,LBN,LBP,6500,1511,11408.834,2018-07-01
Sri Lanka,LKA,LKR,580,159.27,4084.626,2018-07-01
Lithuania,LTU,EUR,2.8,0.853205921249094,16730.226,2018-07-01
Latvia,LVA,EUR,2.7,0.853205921249094,15547.236,2018-07-01
Moldova,MDA,MDL,43,16.6526,2279.645,2018-07-01
Mexico,MEX,MXN,49,19.0515,9304.174,2018-07-01
Malaysia,MYS,MYR,8.45,4.0225,9812.8,2018-07-01
Nicaragua,NIC,NIO,103,31.5872,2206.638,2018-07-01
Netherlands,NLD,EUR,3.79,0.853205921249094,48345.726,2018-07-01
Norway,NOR,NOK,42,8.0415,74940.62,2018-07-01
New Zealand,NZL,NZD,6.2,1.46434324205594,41593.062,2018-07-01
Oman,OMN,OMR,1.05,0.385,17972.922,2018-07-01
Pakistan,PAK,PKR,375,121.49,1541.08,2018-07-01
Peru,PER,PEN,10.5,3.2715,6762.192,2018-07-01
Philippines,PHL,PHP,140,53.487,2976.307,2018-07-01
Poland,POL,PLN,10.1,3.68695,13822.619,2018-07-01
Portugal,PRT,EUR,3.25,0.853205921249094,21161.286,2018-07-01
Qatar,QAT,QAR,12,3.641,60804.259,2018-07-01
Romania,ROU,RON,9.2,3.97325,10757.004,2018-07-01
Russia,RUS,RUB,130,62.14065,10608.159,2018-07-01
Saudi Arabia,SAU,SAR,12,3.7504,21120.481,2018-07-01
Singapore,SGP,SGD,5.8,1.35585,57713.335,2018-07-01
Slovakia,SVK,EUR,3,0.853205921249094,17664.299,2018-07-01
Slovenia,SVN,EUR,2.3,0.853205921249094,23654.409,2018-07-01
Sweden,SWE,SEK,51,8.7526,53217.627,2018-07-01
Thailand,THA,THB,119,33.17,6590.638,2018-07-01
Turkey,TUR,TRY,10.75,4.70625,10511.996,2018-07-01
Taiwan,TWN,TWD,69,30.3725,24576.665,2018-07-01
Ukraine,UKR,UAH,50,26.199,2582.838,2018-07-01
Uruguay,URY,UYU,140,31.31,16722.407,2018-07-01
United States,USA,USD,5.51,1,59501.114,2018-07-01
Vietnam,VNM,VND,65000,23039.5,2353.691,2018-07-01
South Africa,ZAF,ZAR,31,13.3619,6179.87,2018-07-01

0 comments on commit 2add4db

Please sign in to comment.