ols
estimates gravity models in their traditional form
via Ordinary Least Squares (ols). It does not consider Multilateral
Resistance terms.
ols(dependent_variable, regressors, incomes, codes, uie = FALSE,
robust = TRUE, data, ...)
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.
If uie = TRUE
the dependent variable is divided by the product of
unilateral incomes (e.g. GDP variables inc_o
and inc_d
in the example datasets) of the
countries of interest and logged afterwards.
If uie=FALSE
the dependent variable is logged directly. The transformed variable is then used as
the dependent variable and the logged income variables are used as independent variables in the
estimation.
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.
Unilateral metric variables such as GDPs can be added but those variables have to be logged first.
Interaction terms can be added.
Write this argument as c(distance, contiguity, common curreny, ...)
.
variable name (type: character) of the income of the country of
origin (e.g. inc_o
) and destination (e.g. inc_d
) in the dataset data
.
The dependent variable dependent_variable
is divided by the product of the incomes.
Write this argument as c(income origin, income destination)
.
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)
.
Unitary Income Elasticities (type: logic) determines whether the
parameters are to be estimated assuming unitary income elasticities. The default value is set
to FALSE
.
If uie
is set TRUE
, the flows in the dependent variable y
are divided
by the product of the country pairs' incomes before the estimation.
If uie
is set to FALSE
, the income variables are logged and taken as independent
variables in the estimation. The variable names for the incomes should be included (e.g. inc_o
and inc_d
in the example datasets).
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.
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 function will remove zero flows and distances.
additional arguments to be passed to ols
.
The function returns the summary of the estimated gravity model as an
lm
-object.
ols
estimates gravity models in their traditional, additive,
form via Ordinary Least Squares using the lm
function.
Multilateral Resistance terms are not considered by this function.
As the coefficients for the country's incomes were often found to be close to unitary and unitary income elasticities are in line with some theoretical foundations on international trade, it is sometimes assumed that the income elasticities are equal to unity.
In order to allow for the estimation with
and without the assumption of unitary income elasticities, the option
uie
is built into ols
with the default set to FALSE
.
ols
estimation can be used for both, cross-sectional and
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 ols
was therefore tested for cross-sectional data. For the use with panel data
no tests were performed.
Therefore, it is 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.
For more information on gravity models, theoretical foundations and 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.
# NOT RUN {
data(gravity_no_zeros)
ols(dependent_variable = "flow", regressors = c("distw", "rta", "contig", "comcur"),
incomes = c("gdp_o", "gdp_d"), codes = c("iso_o", "iso_d"),
uie = TRUE, robust = TRUE, data = gravity_no_zeros)
# }
# NOT RUN {
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab