Title: | Estimation Methods for Gravity Models |
---|---|
Description: | A wrapper of different standard estimation methods for gravity models. This package provides estimation methods for log-log models and multiplicative models. |
Authors: | Anna-Lena Woelwer [aut, cph], Jan Pablo Burgard [aut, cph], Joshua Kunst [aut, cph], Mauricio Vargas [aut, cre, cph] , Romain Francois [ctb] (adapted parts of the code to use dplyr 0.8.0), Lionel Henry [ctb] (simplified parts of the code), Sarah Johnson [ctb] (improved the double demeaning function), Hrisyana Doytchinova [rev] (sent us different suggestions and bug reports) |
Maintainer: | Mauricio Vargas <[email protected]> |
License: | Apache License (>= 2) |
Version: | 1.2 |
Built: | 2024-11-21 19:20:35 UTC |
Source: | https://github.com/pachadotdev/gravity |
bvu
estimates gravity models via Bonus vetus OLS with simple averages.
bvu( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, robust = FALSE, data, ... )
bvu( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, robust = FALSE, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. This dependent variable is
divided by the product of unilateral incomes such (i.e. |
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
Write this argument as |
income_origin |
(Type: character) origin income variable (e.g. GDP) in the dataset. |
income_destination |
(Type: character) destination income variable (e.g. GDP) in the dataset. |
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. |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
Bonus vetus OLS is an estimation method for gravity models developed by Baier and Bergstrand (2009); Baier and Bergstrand (2010) using simple averages to center a Taylor-series.
The bvu
function considers Multilateral Resistance terms and allows to
conduct comparative statics. Country specific effects are subdued due
to demeaning. Hence, unilateral variables apart from incomes cannot be included
in the estimation.
bvu
is designed to be consistent with the Stata code provided at
Gravity Equations: Workhorse, Toolkit, and Cookbook
when choosing robust estimation.
As, to our knowledge at the moment, there is no explicit literature covering
the estimation of a gravity equation by bvu
using panel data,
we do not recommend to apply this method in this case.
The function returns the summary of the estimated gravity model as an
lm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- bvu( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "contig", "comcur"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- bvu( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "contig", "comcur"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
bvw
estimates gravity models via Bonus
vetus OLS with income-weights.
bvw( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, robust = FALSE, data, ... )
bvw( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, robust = FALSE, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. This dependent variable is
divided by the product of unilateral incomes such (i.e. |
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
Write this argument as |
income_origin |
(Type: character) origin income variable (e.g. GDP) in the dataset. |
income_destination |
(Type: character) destination income variable (e.g. GDP) in the dataset. |
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. |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
Bonus vetus OLS is an estimation method for gravity models developed by Baier and Bergstrand (2009); Baier and Bergstrand (2010) using income-weights to center a Taylor series.
The bvw
function considers Multilateral Resistance terms and allows to
conduct comparative statics. Country specific effects are subdued due
to demeaning. Hence, unilateral variables apart from inc_o
and inc_d
cannot be included in the estimation.
bvw
is designed to be consistent with the Stata code provided at
Gravity Equations: Workhorse, Toolkit, and Cookbook
when choosing robust estimation.
As, to our knowledge at the moment, there is no explicit literature covering
the estimation of a gravity equation by bvw
using panel data,
we do not recommend to apply this method in this case.
The function returns the summary of the estimated gravity model as an
lm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- bvw( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "comcur", "contig"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- bvw( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "comcur", "contig"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
ddm
estimates gravity models via double demeaning the
left hand side and right hand side of the gravity equation.
ddm( dependent_variable, distance, additional_regressors = NULL, code_origin, code_destination, robust = FALSE, data, ... )
ddm( dependent_variable, distance, additional_regressors = NULL, code_origin, code_destination, robust = FALSE, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. This dependent variable is
divided by the product of unilateral incomes such (i.e. |
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
Write this argument as |
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. |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
ddm
is an estimation method for gravity models presented
in Head and Mayer (2014).
Country specific effects are subdued due double demeaning. Hence, unilateral income proxies such as GDP cannot be considered as exogenous variables.
Unilateral effect drop out due to double demeaning and therefore cannot be estimated.
ddm
is designed to be consistent with the Stata code provided at
Gravity Equations: Workhorse, Toolkit, and Cookbook
when choosing robust estimation.
As, to our knowledge at the moment, there is no explicit literature covering
the estimation of a gravity equation by ddm
using panel data,
we do not recommend to apply this method in this case.
The function returns the summary of the estimated gravity model as an
lm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- ddm( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "comcur", "contig"), code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- ddm( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "comcur", "contig"), code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
discard_unusable
drops observations that cannot be used
with models that convert columns to log scale, and therefore requiere non-negative
and finite observations.
Consider that some of the functions within this package will drop observations when required and it is not requiered to be run before fitting a model.
discard_unusable(data, columns)
discard_unusable(data, columns)
data |
(Type: data.frame) the dataset to be used. |
columns |
The columns to be cleaned (e.g. |
The function returns the summary of the estimated gravity model as an
lm
-object.
discard_unusable(gravity_zeros, "flow") discard_unusable(gravity_zeros, c("flow", "distw"))
discard_unusable(gravity_zeros, "flow") discard_unusable(gravity_zeros, c("flow", "distw"))
ek_tobit
estimates gravity models in their additive form
by conducting a censored regression.
ek_tobit( dependent_variable, distance, additional_regressors = NULL, code_destination, robust = FALSE, data, ... )
ek_tobit( dependent_variable, distance, additional_regressors = NULL, code_destination, robust = FALSE, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. This variable is logged and then used as the dependent variable in the estimation. As the log of zero is not defined, all flows equal to zero are replaced by a left open interval with the logged minimum trade flow of the respective importing country as right border. |
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
Write this argument as |
code_destination |
(Type: character) country of destination variable (e.g. country ISO-3 codes). The variables are grouped using this parameter. |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
ek_tobit
represents the Eaton and Kortum (2001) Tobit model where each country
is assigned specific censoring bounds.
When taking the log of the gravity equation flows equal to zero
constitute a problem as their log is not defined. Therefore, in ek_tobit
all values of
the dependent variable are redefined as intervals.
The positive observations have both interval bounds equal to their original value.
For zero flows the interval is left open. The right border of the interval is set to the log of the minimum positive trade flow of the respective importing country.
The defined data object of class Surv
is then inserted
in survreg
for the parameter estimation.
ek_tobit
is designed to be consistent with the Stata code provided at
Gravity Equations: Workhorse, Toolkit, and Cookbook
when choosing robust estimation.
For other Tobit functions, see tobit
for a simple Tobit model where number 1
is added to all observations
and et_tobit
for the Eaton and Tamura (1995)
threshold Tobit model where instead of simply adding number 1
to the data the threshold is estimated.
The function is designed for cross-sectional data, but can be extended to panel data using the
survreg
function.
The function returns the summary of the estimated gravity model as a
survreg
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$flow <- ifelse(grav_small$flow < 5, 0, grav_small$flow) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- ek_tobit( dependent_variable = "flow", distance = "distw", additional_regressors = c("distw", "rta", "lgdp_o", "lgdp_d"), code_destination = "iso_d", robust = FALSE, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$flow <- ifelse(grav_small$flow < 5, 0, grav_small$flow) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- ek_tobit( dependent_variable = "flow", distance = "distw", additional_regressors = c("distw", "rta", "lgdp_o", "lgdp_d"), code_destination = "iso_d", robust = FALSE, data = grav_small )
et_tobit
estimates gravity models in their additive form
by conducting a left-censored regression.
et_tobit(dependent_variable, distance, additional_regressors = NULL, data, ...)
et_tobit(dependent_variable, distance, additional_regressors = NULL, data, ...)
dependent_variable |
(Type: character) name of the dependent variable. Following
Carson and Sun (2007), the smallest positive flow value is used as an estimate of the threshold, this value is is added to the |
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
Write this argument as |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
et_tobit
represents the Eaton and Tamura (1995) Tobit model
which is often used when several gravity models are compared, instead of adding number 1
to the dependent
variable as done in tobit
, the constant added to the data is estimated and interpreted as a
threshold.
When taking the log of the gravity equation flows equal to zero constitute a problem as their log is not defined. Therefore, a constant is added to the flows.
Compared to the usual ET-Tobit approaches, in this package, the estimation of the threshold is done before the other parameters are estimated.
We follow Carson and Sun (2007), who show that taking the minimum positive flow value as an estimate of the threshold is super-consistent and that using this threshold estimate ensures that the parameter MLE are asymptotically normal with the asymptotic variance identical to the variance achieved when the threshold is known. Hence, first the threshold is estimated as the minimum positive flow. This threshold is added to the flow variable, it is logged afterwards and taken as the dependent variable.
The Tobit estimation is then conducted using the
censReg
function and setting the lower bound
equal to the log of the minimum positive flow value which was added to all
observations.
A Tobit regression represents a combination of a binary and a linear regression. This procedure has to be taken into consideration when interpreting the estimated coefficients.
The marginal effects of an explanatory variable on the expected value of the dependent variable equals the product of both the probability of the latent variable exceeding the threshold and the marginal effect of the explanatory variable of the expected value of the latent variable.
For a more elaborate Tobit function, see ek_tobit
for the Eaton and Kortum (2001) Tobit model where each zero trade volume
is assigned a country specific interval with the upper
bound equal to the minimum positive trade level of the respective
importing country.
The function is designed for cross-sectional data, but can be extended to panel data using the
censReg
function.
A robust estimations is not implemented to the present
as the censReg
function is not
compatible with the vcovHC
function.
The function returns the summary of the estimated gravity model as a
censReg
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$flow <- ifelse(grav_small$flow < 5, 0, grav_small$flow) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- et_tobit( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "lgdp_o", "lgdp_d"), data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$flow <- ifelse(grav_small$flow < 5, 0, grav_small$flow) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- et_tobit( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "lgdp_o", "lgdp_d"), data = grav_small )
fixed_effects
estimates gravity models via
OLS and fixed effects for the countries of origin and destination.
fixed_effects( dependent_variable, distance, additional_regressors = NULL, code_origin, code_destination, robust = FALSE, data, ... )
fixed_effects( dependent_variable, distance, additional_regressors = NULL, code_origin, code_destination, robust = FALSE, data, ... )
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 GDPs can be added but those variables have to be logged first. Write this argument as |
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. |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
To account for MR terms, Feenstra (2002) and Feenstra (2015) 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, Head and Mayer (2014) 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.
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 might have 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 Egger and Pfaffermayr (2003), Gómez-Herrera (2013) and Head et al. (2010) as well as the references therein.
The function returns the summary of the estimated gravity model as an
lm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- fixed_effects( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "comcur", "contig"), code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- fixed_effects( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "comcur", "contig"), code_origin = "iso_o", code_destination = "iso_d", robust = FALSE, data = grav_small )
gpml
estimates gravity models in their
multiplicative form via Gamma Pseudo Maximum Likelihood.
gpml( dependent_variable, distance, additional_regressors = NULL, robust = FALSE, data, ... )
gpml( dependent_variable, distance, additional_regressors = NULL, robust = FALSE, data, ... )
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 GDPs can be added but those variables have to be logged first. Interaction terms can be added. Write this argument as |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
gpml
is an estimation method for gravity models
belonging to generalized linear models. It is described in Silva and Tenreyro (2006) and the model
is estimated via glm2
using the gamma distribution and a log-link.
For similar functions, utilizing the multiplicative form via the log-link,
but different distributions, see ppml
, nls
, and nbpml
.
gpml
estimation can be used for both, cross-sectional as well as
panel data, but 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 might have 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 Egger and Pfaffermayr (2003), Gómez-Herrera (2013) and Head et al. (2010).
The function returns the summary of the estimated gravity model similar to a
glm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- gpml( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "iso_o", "iso_d"), data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- gpml( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "iso_o", "iso_d"), data = grav_small )
An edited version of the full gravity dataset: The "square" gravity dataset for all possible pairs of Countries worldwide, 1948-2006, which is used in the article: Head, K., T. Mayer and J. Ries, 2010, "The erosion of colonial linkages after independence". Journal of International Economics, 81(1):1-14 (lead article).
Dataset gravity_no_zeros
corresponds to the dataset without zero trade flows, gravity_zeros
, on the other hand, includes zero trade flows.
data("gravity_no_zeros")
data("gravity_no_zeros")
A data frame with 17088 observations on the following 10 variables.
iso_o
ISO-Code of country of origin
iso_d
ISO-Code of country of destination
distw
weighted distance
gdp_o
GDP of country of origin in million dollars
gdp_d
GDP of country of destination in million dollars
rta
regional trade agreement dummy
flow
trade flow in million dollars
contig
contiguity dummy
comlang_off
common official language dummy
comcur
common currency dummy
https://sites.google.com/site/hiegravity/data-sources
Head, K. and Mayer, T. (2014). Chapter 3 - gravity equations: Workhorse,toolkit, and cookbook. In Gita Gopinath, E. H. and Rogoff, K., editors, Handbook of International Economics, volume 4 of Handbook of International Economics, pages 131-195. Elsevier. (Gravity Equations: Workhorse, Toolkit, and Cookbook)
Head, K., T. Mayer and J. Ries, 2010, "The erosion od colonial linkages after independence". Journal of International Economics, 81(1):1-14 (lead article).
data(gravity_no_zeros) str(gravity_no_zeros)
data(gravity_no_zeros) str(gravity_no_zeros)
An edited version of the full gravity dataset: The "square" gravity dataset for all possible pairs of Countries worldwide, 1948-2006, which is used in the article: Head, K., T. Mayer and J. Ries, 2010, "The erosion of colonial linkages after independence". Journal of International Economics, 81(1):1-14 (lead article).
Dataset gravity_no_zeros
corresponds to the dataset without zero trade flows, gravity_zeros
, on the other hand, includes zero trade flows.
data("gravity_zeros")
data("gravity_zeros")
A data frame with 22588 observations on the following 10 variables.
iso_o
ISO-Code of country of origin
iso_d
ISO-Code of country of destination
distw
weighted distance
gdp_o
GDP of country of origin in million dollars
gdp_d
GDP of country of destination in million dollars
rta
regional trade agreement dummy
flow
trade flow in million dollars
contig
contiguity dummy
comlang_off
common official language dummy
comcur
common currency dummy
https://sites.google.com/site/hiegravity/data-sources
Head, K. and Mayer, T. (2014). Chapter 3 - gravity equations: Workhorse,toolkit, and cookbook. In Gita Gopinath, E. H. and Rogoff, K., editors, Handbook of International Economics, volume 4 of Handbook of International Economics, pages 131-195. Elsevier. (Gravity Equations: Workhorse, Toolkit, and Cookbook)
Head, K., T. Mayer and J. Ries, 2010, "The erosion od colonial linkages after independence". Journal of International Economics, 81(1):1-14 (lead article).
data(gravity_zeros) str(gravity_zeros)
data(gravity_zeros) str(gravity_zeros)
Summary of estimates function that, if is used with default options, provides estimation results are consistent with the Stata methods used in Head and Mayer (2014). This function is adapted from the work of Isidore Beautrelet.
hm_summary(model, robust = FALSE, ...)
hm_summary(model, robust = FALSE, ...)
model |
(Type: lm) Regression object obtained by using the estimation methods from this package
or a generic method such as |
robust |
(Type: logical) Determines whether a robust
variance-covariance matrix should be used. By default is set to If set |
... |
additional arguments to be passed to |
Summary lm
object.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) # Using OLS for testing fit <- ols( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "contig", "comcur"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", uie = FALSE, robust = FALSE, data = grav_small ) fit2 <- hm_summary(fit, robust = FALSE)
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) # Using OLS for testing fit <- ols( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "contig", "comcur"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", uie = FALSE, robust = FALSE, data = grav_small ) fit2 <- hm_summary(fit, robust = FALSE)
log_distance
creates a new dist_log
column in log scale by taking the original distance column in the data
log_distance(data, distance)
log_distance(data, distance)
data |
(Type: data.frame) the dataset to be used. |
distance |
The distance column |
The function returns the summary of the estimated gravity model as an
lm
-object.
log_distance(gravity_zeros, "distw")
log_distance(gravity_zeros, "distw")
nbpml
estimates gravity models in their
multiplicative form via Negative Binomial Pseudo Maximum Likelihood.
nbpml( dependent_variable, distance, additional_regressors = NULL, robust = FALSE, data, ... )
nbpml( dependent_variable, distance, additional_regressors = NULL, robust = FALSE, data, ... )
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 GDPs can be added but those variables have to be logged first. Interaction terms can be added. Write this argument as |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
nbpml
is an estimation method for gravity models
belonging to generalized linear models. It is estimated via glm.nb
using the negative binomial distribution and a log-link.
For similar functions, utilizing the multiplicative form via the log-link,
but different distributions, see nbpml
, gpml
,
and nls
.
gpml
estimation can be used for both, cross-sectional as well as
panel data, but 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 Egger and Pfaffermayr (2003), Gómez-Herrera (2013) and Head et al. (2010).
The function returns the summary of the estimated gravity model similar to a
glm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 3 countries for testing countries_chosen <- c("AUS", "GBR", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- nbpml( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "iso_o", "iso_d"), data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 3 countries for testing countries_chosen <- c("AUS", "GBR", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- nbpml( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "iso_o", "iso_d"), data = grav_small )
nls
estimates gravity models in their
multiplicative form via Nonlinear Least Squares.
nls(dependent_variable, distance, additional_regressors = NULL, data, ...)
nls(dependent_variable, distance, additional_regressors = NULL, data, ...)
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 GDPs can be added but those variables have to be logged first. Interaction terms can be added. Write this argument as |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
nls
is an estimation method for gravity models
belonging to generalized linear models. It is estimated via glm
using the gaussian
distribution and a log-link.
As the method may not lead to convergence when poor
starting values are used, the linear predictions, fitted values,
and estimated coefficients resulting from a
ppml
estimation are used for the arguments
etastart
, mustart
, and start
.
For similar functions, utilizing the multiplicative form via the log-link,
but different distributions, see ppml
, gpml
,
and nbpml
.
nls
estimation can be used for both, cross-sectional as well as
panel data, but 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 Egger and Pfaffermayr (2003), Gómez-Herrera (2013) and Head et al. (2010) as well as the references therein.
The function returns the summary of the estimated gravity model similar to a
glm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- nls( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "lgdp_o", "lgdp_d"), data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- nls( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "lgdp_o", "lgdp_d"), data = grav_small )
ols
estimates gravity models in their traditional form
via Ordinary Least Squares (ols). It does not consider Multilateral
Resistance terms.
ols( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, uie = FALSE, robust = FALSE, data, ... )
ols( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, uie = FALSE, robust = FALSE, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. If If |
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 GDPs can be added but those variables have to be logged first. Interaction terms can be added. Write this argument as |
income_origin |
(Type: character) origin income variable (e.g. GDP) in the dataset. |
income_destination |
(Type: character) destination income variable (e.g. GDP) in the dataset. |
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. |
uie |
(Type: logical) Dtermines whether the
parameters are to be estimated assuming unitary income elasticities. The default value is set
to |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
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 Egger and Pfaffermayr (2003), Gómez-Herrera (2013) and Head et al. (2010) as well as the references therein.
The function returns the summary of the estimated gravity model as an
lm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- ols( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "contig", "comcur"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", uie = FALSE, robust = FALSE, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- ols( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "contig", "comcur"), income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", uie = FALSE, robust = FALSE, data = grav_small )
ppml
estimates gravity models in their
multiplicative form via Poisson Pseudo Maximum Likelihood.
ppml( dependent_variable, distance, additional_regressors = NULL, robust = FALSE, data, ... )
ppml( dependent_variable, distance, additional_regressors = NULL, robust = FALSE, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. This variable is 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 GDPs can be added but those variables have to be logged first. Interaction terms can be added. Write this argument as |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
ppml
is an estimation method for gravity models
belonging to generalized linear models. It is estimated via glm
using the quasipoisson
distribution and a log-link. ppml
is presented in Silva and Tenreyro (2006).
For similar functions, utilizing the multiplicative form via the log-link,
but different distributions, see gpml
, nls
,
and nbpml
.
ppml
estimation can be used for both, cross-sectional as well as
panel data. The function is designed to be consistent with the
results from the Stata function ppml
written by Silva and Tenreyro (2006).
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 Egger and Pfaffermayr (2003), Gómez-Herrera (2013) and Head et al. (2010) as well as the references therein.
The function returns the summary of the estimated gravity model as an
glm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- ppml( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "iso_o", "iso_d"), data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- ppml( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "iso_o", "iso_d"), data = grav_small )
sils
estimates gravity models via
Structural Iterated Least Squares and an explicit inclusion
of the Multilateral Resistance terms.
sils( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, maxloop = 100, decimal_places = 4, robust = FALSE, verbose = FALSE, data, ... )
sils( dependent_variable, distance, additional_regressors = NULL, income_origin, income_destination, code_origin, code_destination, maxloop = 100, decimal_places = 4, robust = FALSE, verbose = FALSE, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. This dependent variable is
divided by the product of unilateral incomes such (i.e. |
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
Write this argument as |
income_origin |
(Type: character) origin income variable (e.g. GDP) in the dataset. |
income_destination |
(Type: character) destination income variable (e.g. GDP) in the dataset. |
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. |
maxloop |
(Type: numeric) maximum number of outer loop iterations. The default is set to 100. There will be a warning if the iterations did not converge. |
decimal_places |
(Type: numeric) number of decimal places that should not change after a new iteration for the estimation to stop. The default is set to 4. |
robust |
(Type: logical) whether robust fitting should be used. By default this is set to |
verbose |
(Type: logical) determines whether the estimated coefficients
of each iteration should be printed in the console. The default is set
to |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
sils
is an estimation method for gravity models
developed by Head and Mayer (2014).
The function sils
utilizes the relationship between the Multilateral
Resistance terms and the transaction costs. The parameters are estimated by
an iterative procedure. The function executes loops until the parameters
stop changing significantly.
sils
is designed to be consistent with the Stata code provided at
Gravity Equations: Workhorse, Toolkit, and Cookbook
when choosing robust estimation.
As, to our knowledge at the moment, there is no explicit literature covering
the estimation of a gravity equation by sils
using panel data,
and we do not recommend to apply this method in this case.
The function returns the summary of the estimated gravity model as an
lm
-object. It furthermore returns the resulting coefficients for each
iteration.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- sils( dependent_variable = "flow", distance = "distw", additional_regressors = "rta", income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", maxloop = 50, dec_places = 3, robust = FALSE, verbose = FALSE, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) fit <- sils( dependent_variable = "flow", distance = "distw", additional_regressors = "rta", income_origin = "gdp_o", income_destination = "gdp_d", code_origin = "iso_o", code_destination = "iso_d", maxloop = 50, dec_places = 3, robust = FALSE, verbose = FALSE, data = grav_small )
tetrads
estimates gravity models
by taking the ratio of the ratio of flows.
tetrads( dependent_variable, distance, additional_regressors = NULL, code_origin, code_destination, filter_origin = NULL, filter_destination = NULL, multiway = FALSE, data, ... )
tetrads( dependent_variable, distance, additional_regressors = NULL, code_origin, code_destination, filter_origin = NULL, filter_destination = NULL, multiway = FALSE, data, ... )
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
Write this argument as |
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 |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
tetrads
is an estimation method for gravity models
developed by Head et al. (2010).
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 Head et al. (2010).
The function returns the summary of the estimated gravity model as an
lm
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(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 )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(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 )
tobit
estimates gravity models in their additive form
by conducting a left-censored regression, which, after adding the
constant 1
to the dependent variable, utilizes log(1) = 0
as the censoring value.
tobit( dependent_variable, distance, additional_regressors = NULL, added_constant = 1, data, ... )
tobit( dependent_variable, distance, additional_regressors = NULL, added_constant = 1, data, ... )
dependent_variable |
(Type: character) name of the dependent variable. The number |
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
Write this argument as |
added_constant |
(Type: numeric) the constant to be added to the dependent variable. The default value
is In the often used case of |
data |
(Type: data.frame) the dataset to be used. |
... |
Additional arguments to be passed to the function. |
tobit
represents the left-censored tobit Tobin (1958)
approach utilizing a known censoring threshold
which is often used when several gravity models are compared.
When taking the log of the gravity equation flows equal to zero constitute a problem as their log is not defined.
Therefore, in the execution of the function the number 1
is added to all flows and the log(flows+1)
is
taken as the dependent variable.
The tobit estimation is conducted using the censReg
function and setting the lower bound equal to 0
as
log(1)=0
represents the smallest flows in the transformed
variable.
A tobit regression represents a combination of a binary and a linear regression.
This procedure has to be taken into consideration when interpreting the estimated coefficients.
The marginal effects of an explanatory variable on the expected value of the dependent variable equals the product of both the probability of the latent variable exceeding the threshold and the marginal effect of the explanatory variable of the expected value of the latent variable.
The function is designed for cross-sectional data,
but can be easily extended to panel data using the
censReg
function.
A robust estimations is not implemented to the present
as the censReg
function is not
compatible with the vcovHC
function.
For a more elaborate Tobit function, see ek_tobit
for the Eaton and Kortum (2001) Tobit model where each zero trade volume
is assigned a country specific interval with the upper
bound equal to the minimum positive trade level of the respective
importing country.
The function returns the summary of the estimated gravity model as a
censReg
-object.
For more information on gravity models, theoretical foundations and estimation methods in general see
Anderson JE (1979). “A Theoretical Foundation for the Gravity Equation.” The American Economic Review, 69(1), 106–116. ISSN 00028282.
Anderson JE, van Wincoop E (2001). “Gravity with Gravitas: A Solution to the Border Puzzle.” Working Paper 8079, National Bureau of Economic Research. doi:10.3386/w8079.
Anderson JE (2010). “The Gravity Model.” Working Paper 16576, National Bureau of Economic Research. doi:10.3386/w16576.
Baier SL, Bergstrand JH (2009). “Bonus vetus OLS: A simple method for approximating international trade-cost effects using the gravity equation.” Journal of International Economics, 77(1), 77 - 85. ISSN 0022-1996, doi:10.1016/j.jinteco.2008.10.004.
Baier SL, Bergstrand JH (2010). “The Gravity Model in International Trade: Advances and Applications.” In van Bergeijk PAG, Brakman S (eds.), chapter 4. Cambridge University Press. doi:10.1017/CBO9780511762109.
Feenstra RC (2002). “Border effects and the gravity equation: consistent methods for estimation.” Scottish Journal of Political Economy, 49(5), 491–506.
Head K, Mayer T, Ries J (2010). “The erosion of colonial trade linkages after independence.” Journal of International Economics, 81(1), 1 - 14. ISSN 0022-1996, doi:10.1016/j.jinteco.2010.01.002.
Head K, Mayer T (2014). “Chapter 3 - Gravity Equations: Workhorse,Toolkit, and Cookbook.” In Gopinath G, Helpman E, Rogoff K (eds.), Handbook of International Economics, volume 4 of Handbook of International Economics, 131 - 195. Elsevier. doi:10.1016/B978-0-444-54314-1.00003-3.
Silva JMCS, Tenreyro S (2006). “The Log of Gravity.” The Review of Economics and Statistics, 88(4), 641-658. doi:10.1162/rest.88.4.641.
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
Egger P, Pfaffermayr M (2003). “The proper panel econometric specification of the gravity equation: A three-way model with bilateral interaction effects.” Empirical Economics, 28(3), 571–580. ISSN 1435-8921, doi:10.1007/s001810200146.
Gómez-Herrera E (2013). “Comparing alternative methods to estimate gravity models of bilateral trade.” Empirical Economics, 44(3), 1087–1111. ISSN 1435-8921, doi:10.1007/s00181-012-0576-2.
and the references therein.
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- tobit( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "lgdp_o", "lgdp_d"), added_constant = 1, data = grav_small )
# Example for CRAN checks: # Executable in < 5 sec data("gravity_no_zeros") # Choose 5 countries for testing countries_chosen <- c("AUS", "CHN", "GBR", "BRA", "CAN") grav_small <- subset(gravity_no_zeros, iso_o %in% countries_chosen) grav_small$lgdp_o <- log(grav_small$gdp_o) grav_small$lgdp_d <- log(grav_small$gdp_d) fit <- tobit( dependent_variable = "flow", distance = "distw", additional_regressors = c("rta", "lgdp_o", "lgdp_d"), added_constant = 1, data = grav_small )