The goal of cp2015
package is to implement the Caliendo and Parro (2015) quantitative trade model in R.
To install the development version, run the following command:
remotes::install_github("paulofelipe/cp2015")
# Or use the following command to install the package with vignettes
# remotes::install_github("paulofelipe/cp2015", build_vignettes = TRUE)
The dependency xtensor
is no longer available on CRAN, but it can be installed directly from GitHub using the following command:
devtools::install_github("xtensor-stack/Xtensor.R")
This is a basic example which replicates the simulation presented in the subsection 5.1 of the article "Estimates of the Trade and Welfare Effects of NAFTA".
library(cp2015)
## Data for example
## cp2015_nafta is the data available in the package
data("cp2015_nafta")
## Simulation imposing zero aggregate deficits.
results <- run_cp2015(data = cp2015_nafta, zero_aggregate_deficit = TRUE)
We have extended the welfare decomposition formula to account for the possibility of changes in iceberg trade costs (variations in technical efficiency).
```r # Welfare for NAFTA countries nafta <- c("Canada", "Mexico", "USA") results$welfare %>% dplyr::filter(region %in% nafta) ``` This example considers only variations in tariffs. In this way, there are no variations in technical efficiency. However, the package allows simulations that take into account changes in the iceberg trade costs. ``` # Values are in % # tot = terms of trade # vot = volume of trade # tech = technical efficiency # A tibble: 3 × 6 region tot vot tech welfare realwage