Content uploaded by Alexandre Loures
Author content
All content in this area was uploaded by Alexandre Loures on Jul 18, 2022
Content may be subject to copyright.
Package ‘zerotradeflow’
July 18, 2022
Type Package
Title An Implementation for the Gravitational Models of Trade
Version 0.1.0
Maintainer Alexandre Loures <alexandre.loures@protonmail.com>
Description A system for creating the bilateral trade flow between a country
pair equal to zero. You provide the data, tell get_zerotradeflow() which
variables are of interest and it expands the base by creating the bilateral
zero trade flow. The bases on the flow of trade between countries only report
positive trade (greater than zero), however, for some analyzes of gravitacional
models, data on zero flow is also necessary. Some examples for Gravity Model:
Figueiredo and Loures (2016) <doi:10.5935/0034-7140.20160015> and
Yotov, Piermartini, Monteiro and Larch <https:
//vi.unctad.org/tpa/web/docs/vol2/book.pdf>.
License MIT + file LICENSE
Encoding UTF-8
Language English
LazyData true
LazyDataCompression xz
Depends R (>= 3.5.0)
Imports magrittr, tidyverse, rlang, dplyr, tidyr, purrr, cli
Suggests testthat (>= 2.1.0)
URL https://github.com/AlexandreLoures/zerotradeflow
BugReports https://github.com/AlexandreLoures/zerotradeflow/issues
RoxygenNote 7.1.2
Repository CRAN
NeedsCompilation no
Author Alexandre Loures [aut, cre] (<https://orcid.org/0000-0002-1288-0135>)
Date/Publication 2022-07-18 08:20:02 UTC
1
2comtrade
Rtopics documented:
comtrade .......................................... 2
distinct............................................ 3
get_zerotradeflow...................................... 4
same............................................. 5
Index 7
comtrade A sample of the UN Comtrade Database.
Description
A sample of the UN Comtrade Database prepared by the United Nations Department of Statistics
with official international trade information.
Usage
comtrade
Format
A dataframe object.
Details
In the following example the original base (comtrade.rda) has only 229,585 information on positive
bilateral trade flow (greater than zero). However, after expanding this base to also present the
bilateral trade flow equal to zero, the new base will have 1,255,892 observations (both positive and
zero flow). Note that the final size of the base will depend on the number of years, the number of
exporting and importing countries and the items present in the base. Since the distinct number of
exporting and importing countries has an important determining factor in the expansion of the base
(see the examples with the distinct.rda and same.rda bases).
A dataset consisting of two years, 24 exporting countries, 24 importing countries, 1,241 Harmo-
nized System codes and the value of exports in dollars. The data includes the following fields:
* ano - Numeric. Year in which exports were carried out. * ido - String. ISO code corresponding
to the exporting country. * idd - String. ISO code corresponding to the importing country. * HS4 -
Numeric. HS4 code corresponding to the merchandise sold. * comercio - Numeric. Dollar value of
exports.
Value
a dataframe object contains the five variables passed as parameters to the get_zerotradeflow() func-
tion (year, exporter, importer, item, trade) including the bilateral trade flow equal to zero.
Source
Repository UN Comtrade.
distinct 3
Examples
zeroflow <- get_zerotradeflow(comtrade, ano, ido, idd, HS4, comercio)
distinct Dataset composed of six different countries.
Description
A dummy dataset to illustrate the final size of the base after expansion.
Usage
distinct
Format
A dataframe object.
Details
A dataset consisting of three years, three exporting countries, three importing countries, three Har-
monized System code and value of exports (all data is fictitious). The data includes the following
fields:
* ano - Numeric. Year in which exports were carried out. * ido - String. ISO code corresponding
to the exporting country. * idd - String. ISO code corresponding to the importign country. * HS4 -
Numeric. HS4 code corresponding to the merchandise sold. * comercio - Numeric. Dollar value of
exports.
Value
a dataframe object contains the five variables passed as parameters to the get_zerotradeflow() func-
tion (year, exporter, importer, item, trade) including the bilateral trade flow equal to zero.
Examples
# Note that the distinct.rda base has six different countries (three
# exporters and three importers). Thus, when expanding this base, we have 81
# observations as a result.
4get_zerotradeflow
distinctflow <- get_zerotradeflow(distinct, ano, ido, idd, HS4, comercio)
get_zerotradeflow Expand the dataset from the passed database as parameters.
Description
Creates zero bilateral trade flow for a given pair of countries.
Usage
get_zerotradeflow(data, year, exporter, importer, item, trade)
Arguments
data a data set containing the variables that will be used to guide the expansion of the
base including all possible combinations of the reference variables.
year refers to the column in the database that contains information for the years under
review.
exporter refers to the column with the ISO codes (ISO 3166 standard - Codes for the
representation of names of countries and their subdivisions, created and main-
tains by International Organization for Standardization - ISO) of each exporter
country (Ex.: BRA, PRT, ITA, USA,...).
importer refers to the column with the ISO codes (ISO 3166 standard - Codes for the
representation of names of countries and their subdivisions, created and main-
tains by International Organization for Standardization - ISO) of each importer
country (Ex.: BRA, PRT, ITA, USA,...).
item refers to the column in the database that contains information about Harmonized
System (HS) codes, or other classification. Harmonized System is an acronym
for Harmonized Commodity Designation and Coding System, and it is a cus-
toms nomenclature, used internationally as a standardized system of coding and
classification of import and export products, developed and maintained by the
World Customs Organization (WCO).
trade refers to the column in the database that contains information about the value of
exports/imports
same 5
Details
The zerotradeflow package allows generating the bilateral trade flow equal to zero of each country
pair in each year present in the database passed in data parameter. Since, by default, data on bilateral
trade flows of countries only report positive trade flows (flows greater than zero).
Function to expand the database with the bilateral trade flow equal to zero, passing the following
parameters:
Value
a dataframe object contains the five variables passed as parameters to the get_zerotradeflow() func-
tion (year, exporter, importer, item, trade) including the bilateral trade flow equal to zero.
same Dataset composed of five different countries (BRA appears as both
exporter and importer).
Description
A dummy dataset to illustrate the final size of the base after expansion.
Usage
same
Format
A dataframe object.
Details
A dataset cosisting of three years, three exporting countries, three importing countries, three Har-
monized System code and value of exports (all data is fictitious). The data includes the following
fields:
* ano - Numeric. Year in which exports were carried out. * ido - String. ISO code corresponding
to the exporting country. * idd - String. ISO code corresponding to the importing country. * HS4 -
Numeric. HS4 code corresponding to the merchandise sold. * comercio - Numeric. Dollar value of
exports.
Value
a dataframe object contains the five variables passed as parameters to the get_zerotradeflow() func-
tion (year, exporter, importer, item, trade) including the bilateral trade flow equal to zero.
6same
Examples
# On the other hand, in the same.rda base, Brazil (BRA) appears as both an
# exporter and an importer and, in this case, when expanding the base, there
# are 72 observations as a result.
sameflow <- get_zerotradeflow(same, ano, ido, idd, HS4, comercio)