NAFTA trade dashboard
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 obtain exchange rates, I use the tidyquant package. The other indexes refer to the price index of products imported from each of those countries.
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
This release is a first and fast dive into the data, so I would be happy to listen to improvements to the tool, including some new indicators I haven’t added. FYI, I tried to build the export matrixes at a 4-level granularity, but highcharts couldn’t handle it, any suggestions on how to do it would be welcome.
The newest I could build is from november 2016, which is the month all three countries have statistics ready.
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.