Learn R Programming

gravity (version 0.8.5)

fixed_effects: Fixed Effects

Description

fixed_effects estimates gravity models via OLS and fixed effects for the countries of origin and destination. These effects catch country specific effects.

Usage

fixed_effects(dependent_variable, regressors, codes = c("iso_o", "iso_d"),
  robust = TRUE, data, ...)

Arguments

dependent_variable

name (type: character) of the dependent variable in the dataset data (e.g. trade flows).

This variable is logged and then used as the dependent variable in the estimation.

regressors

name (type: character) of the regressors to include in the model.

Include the distance variable in the dataset data containing a measure of distance between all pairs of bilateral partners and bilateral variables that should be taken as the independent variables in the estimation.

The distance is logged automatically when the function is executed.

Fixed effects catch all unilateral effects. Therefore, no other unilateral variables such as GDP can be included as independent variables in the estimation.

Write this argument as c(distance, contiguity, common curreny, ...).

codes

variable name (type: character) of the code of the country of origin and destination (e.g. ISO-3 codes from the variables iso_o and iso_d) in the example datasets).

The variables are grouped by using iso_o and iso_d to obtain estimates.

Write this argument as c(code origin, code destination).

robust

robust (type: logical) determines whether a robust variance-covariance matrix should be used. By default is set to TRUE.

If robust = TRUE the estimation results are consistent with the Stata code provided at Gravity Equations: Workhorse, Toolkit, and Cookbook when choosing robust estimation.

data

name of the dataset to be used (type: character).

To estimate gravity equations you need a square dataset including bilateral flows defined by the argument dependent_variable, ISO codes or similar of type character (e.g. iso_o for the country of origin and iso_d for the destination country), a distance measure defined by the argument distance and other potential influences (e.g. contiguity and common currency) given as a vector in regressors are required.

All dummy variables should be of type numeric (0/1).

Make sure the ISO codes are of type "character".

If an independent variable is defined as a ratio, it should be logged.

The user should perform some data cleaning beforehand to remove observations that contain entries that can distort estimates.

When using panel data, a variable for the time may be included in the dataset. Note that the variable for the time dimension should be of type factor.

The time variable can be used as a single dependent variable or interaction term with other variables such as country identifiers by inserting it into regressors or as an optional parameter.

The function will remove zero flows and distances.

...

additional arguments to be passed to fixed_effects.

Value

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

Details

To account for MR terms, Feenstra (2002) and Feenstra (2004) propose to use importer and exporter fixed effects. Due to the use of these effects, all unilateral influences such as GDPs can no longer be estimated.

A disadvantage of the use of fixed_effects is that, when applied to panel data, the number of country-year or country-pair fixed effects can be too high for estimation. In addition, no comparative statistics are possible with fixed_effects as the Multilateral Resistance terms are not estimated explicitly. Nevertheless, Head2014;textualgravity highlight the importance of the use of fixed effects.

By including country specific fixed effects, all monadic effects are captured, including Multilateral Resistance terms. Therefore, no other unilateral variables such as GDP can be included as independent variables in the estimation.

fixed_effects 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 at the website Gravity Equations: Workhorse, Toolkit, and Cookbook when choosing robust estimation.

The function fixed_effects was therefore tested for cross-sectional data. Its up to the user to ensure that the functions can be applied to panel data.

Depending on the panel dataset and the variables - specifically the type of fixed effects - included in the model, it may easily occur that the model is not computable.

Also, note that by including bilateral fixed effects such as country-pair effects, the coefficients of time-invariant observables such as distance can no longer be estimated.

Depending on the specific model, the code of the respective function may has to be changed in order to exclude the distance variable from the estimation.

At the very least, the user should take special care with respect to the meaning of the estimated coefficients and variances as well as the decision about which effects to include in the estimation.

When using panel data, the parameter and variance estimation of the models may have to be changed accordingly.

For a comprehensive overview of gravity models for panel data see Egger2003;textualgravity, Gomez-Herrera2013;textualgravity and Head2010;textualgravity as well as the references therein.

References

For more information on fixed effects as well as informaton on gravity models, theoretical foundations and suitable estimation methods in general see

Anderson1979gravity

Anderson2001gravity

Anderson2010gravity

Baier2009gravity

Baier2010gravity

Head2010gravity

Head2014gravity

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

Egger2003gravity

Gomez-Herrera2013gravity

and the references therein.

See Also

lm, coeftest, vcovHC

Examples

Run this code
# NOT RUN {
data(gravity_no_zeros)

fixed_effects(dependent_variable = "flow",
regressors = c("distw", "rta"), codes = c("iso_o", "iso_d"),
robust = TRUE, data = gravity_no_zeros)

fixed_effects(dependent_variable = "flow",
regressors = c("distw", "rta", "comcur", "contig"),
codes = c("iso_o", "iso_d"), robust = TRUE, data = gravity_no_zeros)
# }
# NOT RUN {
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab