forked from jpburgard/gravity
-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
README.Rmd
89 lines (57 loc) · 7.26 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
output: github_document
bibliography: inst/REFERENCES.bib
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# gravity
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![R-CMD-check](https://github.com/pachadotdev/gravity/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pachadotdev/gravity/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/gravity)](https://cran.r-project.org/package=gravity)
[![Coverage status](https://codecov.io/gh/pachadotdev/gravity/branch/master/graph/badge.svg)](https://codecov.io/github/pachadotdev/gravity?branch=master)
[![JOSS](http://joss.theoj.org/papers/10.21105/joss.01038/status.svg)](https://doi.org/10.21105/joss.01038)
[![Austrian Journal of Statistics](https://zenodo.org/badge/doi/10.17713/ajs.v47i4.688.svg)](https://doi.org/10.17713/ajs.v47i4.688)
## About
Gravity models are used to explain bilateral flows related to the sizes of bilateral partners, a measure of distance between them and other influences on interaction costs.
The underlying idea is rather simple. The greater the masses of two bodies and the smaller the distance between them, the stronger their attraction. This concept is applied to several research topics such as trade, migration or foreign direct investment. Even though their basic idea is rather simple, gravity models can become complex regarding the choice of models or estimation methods.
As especially for gravity beginners it is difficult to get an overview of the different methods and implement them in R, the package provides a wrapper of different standard estimation methods for gravity models. By considering the descriptions and codes of the estimation methods, users get a comprehensive and application-oriented overview of the different methods, see which method may be suitable for a certain research question or type of data and extend the code available to their research projects.
The package provides estimation methods for log-log models and multiplicative models.
Log-log estimation covers:
- Ordinary Least Squares (OLS)
- Fixed Effects
- Double Demeaning (DDM)
- Bonus vetus OLS with simple averages (BVU) and with GDP-weights (BVW)
- Structural Iterated Least Squares (SILS)
- Tetrads
- Different Tobit models (Tobit, ET-Tobit, EK-Tobit)
Log-log models are partly complex to understand and program and thus a comparison of them is not straightforward, wherefore the package aims at easing an overview of the different methods combined with a direct application.
Multiplicative estimation covers:
- Poisson Pseudo Maximum Likelihood (PPML)
- Gamma Pseudo Maximum Likelihood (GPML)
- Negative Binomial Pseudo Maximum Likelihood (NBPML)
- Nonlinear Least Squares (NLS)
Multiplicative models are covered with a log-link and different families of distributions. These models are relatively easy to compute.
All functions named estimate gravity models, but they differ in whether they estimate them in their additive or multiplicative form, their requirements and assumptions with respect to data, their handling of Multilateral Resistance terms as well as their possibilities concerning the inclusion of unilateral independent variables. Therefore, they normally lead to different estimation results. We refer the user to the [Gravity Cookbook website](https://sites.google.com/site/hiegravity/) for more information on gravity models in general.
@Head2014 provide a comprehensive and accessible overview of the theoretical and empirical development of the gravity literature as well as the use of gravity models and the various estimation methods, especially their merits and potential problems regarding applicability as well as different datasets. In order to have a straightforward application of all methods, the package comes with two example datasets, one including and the other one excluding zero trade flows.
Examples utilizing these dataset are included in the description of the methods. As the range of gravity models and their suitable estimation methods is huge and specific to data and research question at hand, the functions are kept simple such that researchers can utilize them as a starting point of their research and get familiar with them.
On the [Gravity Cookbook website](https://sites.google.com/site/hiegravity/), Keith Head and Thierry Mayer provide Stata code for most methods. Where possible, the functions are tested to lead the same results as the Stata code when choosing the option of robust variance estimation. However, compared to the Stata code available, the functions presented in this package provide users with more flexibility regarding the type of estimation, the number and type of independent variables as well as the possible data.
Furthermore, additional functions are added. The functions of the package include distance as an independent variable. If a panel model is used time-invariant effects, such as geographical distance, may have to be excluded; see the respective descriptions. 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.
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.
For a state-of-the-art exposition about cross-sectional data see @WoelwerBressleinBurgard2018, and for a comprehensive overview of gravity models for panel data see @Egger2003, @Gomez-Herrera2013 and @Head2010 as well as the references therein (see also the references included in the descriptions of the different functions).
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. As, to our knowledge at the moment, there is no explicit literature covering the estimation of a gravity equation by Double Demeaning, Structural Iterated Least Squares or Bonus vetus OLS using panel data, we do not recommend to apply these methods in this case.
Contributions, extensions and error corrections are very welcome. Please do not hesitate to contact us. We thank Martin Bresslein for valuable comments and advice on early versions of the package.
## How to install
From R console:
```{r, eval = FALSE}
# Install from CRAN
install.packages("gravity")
# Install from GitHub
devtools::install_github("pachadotdev/gravity")
```
## Community guidelines
If you want to contribute to the software, report issues or problems with the software, please fork the repo and send us a Pull Request or open an issue. We are happy to receive ideas and we would do our best to coordinate efforts and improve this package without reinventing the wheel.
If you seek support or have questions you can start a thread on the issues section, or you can email us but we prefer open issues as probably more users have the same questions as you.
## References