Package 'zerotradeflow'

Title: An Implementation for the Gravitational Models of Trade
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>; Loures, Figueiredo and Mariano (2019) <doi:10.11606/1980-5330/ea150797> and Yotov, Piermartini, Monteiro and Larch <https://vi.unctad.org/tpa/web/docs/vol2/book.pdf>.
Authors: Alexandre Loures [aut, cre]
Maintainer: Alexandre Loures <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-11-01 03:38:17 UTC
Source: https://github.com/alexandreloures/zerotradeflow

Help Index


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 Harmonized 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() function (year, exporter, importer, item, trade) including the bilateral trade flow equal to zero.

Source

Repository UN Comtrade.

Examples

zeroflow <- get_zerotradeflow(comtrade, ano, ido, idd, HS4, comercio)

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 Harmonized 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() function (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.




distinctflow <- get_zerotradeflow(distinct, ano, ido, idd, HS4, comercio)

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 maintains 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 maintains 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 customs 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

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() function (year, exporter, importer, item, trade) including the bilateral trade flow equal to zero.


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 Harmonized 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() function (year, exporter, importer, item, trade) including the bilateral trade flow equal to zero.

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)