Gravity dataset with zero trade flows is an edited version of the full gravity dataset that is used in Head, Mayer, and Ries (2010).
Dataset gravity_no_zeros
corresponds to the dataset without zero trade flows, gravity_zeros
, on the other hand, includes zero trade flows.
In order to have a dataset suited for all functions, a cross-sectional dataset is chosen. All incomplete rows and observations with missing trade flows are therefore excluded from the dataset.
As some of the functions in the package are capable of handling zero values in trade flows and some are not, two datasets, gravity_zeros
and gravity_no_zeros
, are provided.
The original dataset downloaded from SciencesPo was edited in the following way:
# 1: Import and read the dataset
url <- "http://econ.sciences-po.fr/sites/default/files/file/tmayer/data/col_regfile09.zip"
zip <- "col_regfile09.zip"
if (!file.exists(zip)) { try(download.file(url, zip)) }
try(system("7z e -aos col_regfile09.zip"))
library(haven)
col_regfile09 <- read_dta("col_regfile09.dta")
# 2: Isolation of one year
library(dplyr)
data06 <- col_regfile09 %>%
filter(year == 2006)
# 3: Choosing variables
data06 <- data06 %>%
select(iso_o, iso_d, distw, gdp_o, gdp_d, rta, flow, contig, comlang_off, comcur)
# 4: Isolation of complete cases
library(tidyr)
gravity_zeros <- data06 %>%
drop_na()
# 5: Divide GDPs by 1,000,000 for scaling purposes
gravity_zeros <- gravity_zeros %>%
mutate(
gdp_o = gdp_o / 1000000,
gdp_d = gdp_d / 1000000
)
# 6: Exclusion of trade flows equal to 0
gravity_no_zeros <- gravity_zeros %>%
filter(flow > 0)
# 7: Export the data
save(gravity_zeros, file = "gravity_zeros.rdata", compress = "xz")
save(gravity_no_zeros, file = "gravity_no_zeros.rdata", compress = "xz")
Head, Keith, Thierry Mayer, and John Ries. 2010. “The Erosion of Colonial Trade Linkages After Independence.” Journal of International Economics 81 (1): 1–14. doi:10.1016/j.jinteco.2010.01.002.