Chapter 1 Introduction

1.1 Welcome

Cover image

Welcome to our online solutions manual for for An Advanced Guide to Trade Policy Analysis, AGTPA (Yotov et al. 2016).

This material is intended to provide a comprehensive explanation to reproduce the book’s results in R. We don’t attempt to give a thorough discussion of the theory behind gravity models, the references cited through the chapters shall fill those details.

The manual is written for two audiences:

  • People who know R and are interested in learning about gravity models.
  • People with no R knowledge who know gravity models theory.

We only assume that readers are familiar with linear regression, and that they shall read Yotov et al. (2016) and Wickham and Grolemund (2016) alongside this material.

What we did here was to replicate all the results from the book, made with Stata, in R as a way to contribute to Reproducible Research. R is free and available on almost every operating system. It is a wonderful tool for all statistical analysis.

This material was greatly improved thanks to the feedback (and patience!) of Jinbo Hao, Alexey Kravchenko, Hrisyana Stefanova, Chence Sun and Yoto Yotov.

1.2 Obtaining the datasets and functions

yotover is an R package created specifically to distribute the datasets required to reproduce the results from AGTPA. It acts as a metapackage that calls other packages to use several functions that augment R capabilities.

You can get all the functions and datasets if you run these lines from your R console:

# stable version

# development version
if (!require("remotes")) install.packages("remotes")

1.3 Getting the most out of this material

You can clone the GitHub repository to obtain the editable R Markdown files:

git clone

Please read Bryan, Hester, and STAT 545 TAs (2020) if you have questions about git or GitHub.


Bryan, Jennifer, Jim Hester, and STAT 545 TAs. 2020. “Happy Git with r.”
Wickham, Hadley, and Garrett Grolemund. 2016. R for Data Science: Import, Tidy, Transform, Visualize, and Model Data. " O’Reilly Media, Inc.".
Yotov, Yoto V, Roberta Piermartini, José-Antonio Monteiro, and Mario Larch. 2016. An Advanced Guide to Trade Policy Analysis: The Structural Gravity Model. World Trade Organization Geneva.