tetrads: Tetrads

View source: R/tetrads.R

tetradsR Documentation

Tetrads

Description

tetrads estimates gravity models by taking the ratio of the ratio of flows.

Usage

tetrads(
  dependent_variable,
  distance,
  additional_regressors,
  code_origin,
  code_destination,
  filter_origin = NULL,
  filter_destination = NULL,
  multiway = FALSE,
  data,
  ...
)

Arguments

dependent_variable

(Type: character) name of the dependent variable. This variable is logged and then used as the dependent variable in the estimation.

distance

(Type: character) name of the distance variable that should be taken as the key independent variable in the estimation. The distance is logged automatically when the function is executed.

additional_regressors

(Type: character) names of the additional regressors to include in the model (e.g. a dummy variable to indicate contiguity). Unilateral metric variables such as GDP should be inserted via the arguments income_origin and income_destination.

Write this argument as c(contiguity, common currency, ...). By default this is set to NULL.

code_origin

(Type: character) country of origin variable (e.g. ISO-3 country codes). The variables are grouped using this parameter.

code_destination

(Type: character) country of destination variable (e.g. country ISO-3 codes). The variables are grouped using this parameter.

filter_origin

(Type: character) Reference exporting country.

filter_destination

(Type: character) Reference importing country.

multiway

(Type: logical) in case multiway = TRUE, the cluster.vcov function is used for estimation following \insertCiteCameron2011;textualgravity multi-way clustering of variance-covariance matrices. The default value is set to TRUE.

data

(Type: data.frame) the dataset to be used.

...

Additional arguments to be passed to the function.

Details

tetrads is an estimation method for gravity models developed by \insertCiteHead2010;textualgravity.

The function tetrads utilizes the multiplicative form of the gravity equation. After choosing a reference exporter A and importer B one can eliminate importer and exporter fixed effects by taking the ratio of ratios.

Only those exporters trading with the reference importer and importers trading with the reference exporter will remain for the estimation. Therefore, reference countries should preferably be countries which trade with every other country in the dataset.

After restricting the data in this way, tetrads estimates the gravity equation in its additive form by OLS.

By taking the ratio of ratios, all monadic effects diminish, hence no unilateral variables such as GDP can be included as independent variables.

tetrads estimation can be used for both, cross-sectional as well as panel data. Nonetheless, the function is designed to be consistent with the Stata code for cross-sectional data provided on the website Gravity Equations: Workhorse, Toolkit, and Cookbook when choosing robust estimation.

The function tetrads was therefore tested for cross-sectional data.

If tetrads is used for panel data, the user may have to drop distance as an independent variable as time-invariant effects drop.

For applying tetrads to panel data see \insertCiteHead2010;textualgravity.

Value

The function returns the summary of the estimated gravity model as an lm-object.

References

For more information on gravity models, theoretical foundations and estimation methods in general see

\insertRef

Anderson1979gravity

\insertRef

Anderson2001gravity

\insertRef

Anderson2010gravity

\insertRef

Baier2009gravity

\insertRef

Baier2010gravity

\insertRef

Feenstra2002gravity

\insertRef

Head2010gravity

\insertRef

Head2014gravity

\insertRef

Santos2006gravity

and the citations therein.

See Gravity Equations: Workhorse, Toolkit, and Cookbook for gravity datasets and Stata code for estimating gravity models.

For estimating gravity equations using panel data see

\insertRef

Egger2003gravity

\insertRef

Gomez-Herrera2013gravity

and the references therein.

See Also

lm, coeftest,

Examples

# Example for CRAN checks:
# Executable in < 5 sec
library(dplyr)
data("gravity_no_zeros")

# Choose 5 countries for testing
countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN")
grav_small <- filter(gravity_no_zeros, iso_o %in% countries_chosen)

fit <- tetrads(
  dependent_variable = "flow",
  distance = "distw",
  additional_regressors = "rta",
  code_origin = "iso_o",
  code_destination = "iso_d",
  filter_origin = countries_chosen[1],
  filter_destination = countries_chosen[2],
  data = grav_small
)

gravity documentation built on May 2, 2023, 9:13 a.m.