README.md

cp2015

Lifecycle: experimental R-CMD-check

The goal of cp2015 package is to implement the Caliendo and Parro (2015) quantitative trade model in R.

Installation

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)

Note

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")

Example

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)

Welfare results

We have extended the welfare decomposition formula to account for the possibility of changes in iceberg trade costs (variations in technical efficiency).

# 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
  <fct>    <dbl>  <dbl> <dbl>   <dbl>    <dbl>
1 Canada -0.108  0.0443     0 -0.0638    0.323
2 Mexico -0.412  1.72       0  1.31      1.72 
3 USA     0.0435 0.0412     0  0.0848    0.112

Vignette

See the vignette for more details:

vignette("cp2015-nafta")


paulofelipe/cp2015 documentation built on Nov. 24, 2024, 11:46 p.m.