NAFTA Trade-Watch

Tradewatch is a dashboard, written in R using the flexdashboard framework. Visualizations are made possible thanks to highcharter and other packages.

The main purpose of the dashboard is to monitor trade, mostly from the Mexican perspective, of goods and commodities with countries that are in NAFTA.

In the age of fake news and policy-by-twitter, hopefully this tool will help guide more informed debate (and decisions) with respect to trade between these three countries.

Notes and methodology

The dashboard consists of basically three sections:

Bilateral Trade: These contain two, side-by-side comparisons, of exports and imports of products at a 2-level HS code depth. The color denotes year-over-year growth rate, while the size is related to the dollar value (in the newest month) of exports. The average growth rate for 2 digit codes is a weighted-mean of each 4-digit classification.

US Share-shift: A visualization that describes the shift in share in the U.S. market of Mexican goods relative to Canadian goods. When the shift is lower than 0, Mexican imports lost share (vs. Canada last year) in the United States, and vice-versa. Important caveat: the share is calculated only for goods from Mexico or Canada (Because they are not collectively exhaustive, it is perfectly posible that both lost share against a third competitor)

Terms of Trade & Fx: Prices are important. This section aims to gauge the impact of prices in the trade dynamic. To calculate the Mexican terms of trade (prices of exports divided by prices of imports) I use the inegiR package. To obtain exchange rates and other FRED indicators, I use the tidyquant package.

The names of HS Codes have been abbreviated manually, they can be found here, however the code is still in between parenthesis. Should you want to look it up further, I recommend the UN Comtrade website

Dashboards

Code

The code used to build the dashboard consists of two files: a functions.R file that contains some functions for downloading and cleaning the data and a db.Rmd file that builds the dashboard using the knitr/flexdashboard process in RStudio.