This repository contains the scripts, curated datasets, methodological documentation and generated figure outputs required to reproduce analysis from "Effects of Escalating Trade Barriers on the U.S. Energy System".
The workflow has two stages:
prepare_input_data.Rconverts the curated GTA intervention file plus two mapping tables into two analysis-ready Excel datasets.plot_figures_SetA.Randplot_figures_SetB.Rread those prepared datasets and export the final figures.
The analysis is implemented in two complementary counting frameworks:
- Set A (intervention level): counts unique interventions by sector, with one row per
(intervention_id, sector). - Set B (intervention-product level): counts intervention-product pairs, with one row per
(intervention_id, hs_code)after matching affected HS codes to energy sectors.
Both sets classify observations into five energy system sectors:
- EV & Batteries
- Renewable Electricity
- Other Low-Carbon
- Fossil Fuels
- Grid
Data on trade barriers from 2009 – 2024 in Figure 1 were sourced from the Global Trade Alert database as of May 2026. GTA tracks unilateral government interventions that affect competitive trade and evaluates them in terms of their degree of discrimination of foreign commercial interests.
- Trade-barrier observations are sourced from the Global Trade Alert (GTA) database as of May 2026.
- The analytical sample is limited to U.S.-implementing interventions with
RedorAmberGTA evaluations. - Liberalizing measures are excluded.
- Interventions are assigned to one of three policy categories using the GTA MAST chapter:
TariffNTMSubsidies
- Energy-system exposure is identified through HS-code matching using the curated sector classification in
Method/Energy Sector HS Code Classification.xlsx.
The README and scripts distinguish between the repository's two counting units because they answer different methodological questions:
- Set A measures how many distinct interventions affect each sector.
- Set B measures how broad product coverage is within those interventions by counting matched HS codes separately.
This means one intervention can appear:
- once in a sector in Set A, even if it affects multiple HS codes in that same sector;
- multiple times in Set B if it affects multiple matched HS codes; and
- in multiple sectors in both sets when its affected products map to more than one sector.
Code/prepare_input_data.R: builds the analysis-ready input files for Set A and Set B.plot_figures_SetA.R: generates all Set A figures fromData/Input Data SetA.xlsx.plot_figures_SetB.R: generates all Set B figures fromData/Input Data SetB.xlsx.
Data/GTA Intervention Data.xlsx: curated intervention-level source data.Input Data SetA.xlsx: prepared Set A input data generated byprepare_input_data.R.Input Data SetB.xlsx: prepared Set B input data generated byprepare_input_data.R.
Figures/SetA/: exported Set A figures in.pngand.pdfformats.SetB/: exported Set B figures in.pngand.pdfformats.
Method/GTA Intervention Classification.xlsx: maps MAST chapters to policy categories (Tariff,NTM,Subsidies).Energy Sector HS Code Classification.xlsx: maps HS codes to energy system sectors.US Trade Barriers Energy System_Supplementary Material.docx: supplementary methodological documentation.
The curated GTA sample used in this repository is:
- U.S.-implementing measures
- Red and Amber interventions only
- Liberalizing measures excluded
- Time span: 2009-2024
In prepare_input_data.R, the analysis year is taken from Date Implemented and falls back to Date Announced when Date Implemented is missing. Records are then filtered to the 2009-2024 study window.
Code/prepare_input_data.R implements the following preparation steps:
- Reads the curated GTA intervention file and trims source column names.
- Maps each intervention's
Mast ChaptertoTariff,NTM, orSubsidiesusingMethod/GTA Intervention Classification.xlsx. - Expands the
Affected Productsfield into one row per affected HS code. - Matches HS codes to one of the five energy sectors using
Method/Energy Sector HS Code Classification.xlsx. - Builds:
Set Aby deduplicating to one row per(intervention_id, sector).Set Bby retaining one row per(intervention_id, hs_code)after sector matching.
HS-code handling in the preparation script is intentionally strict:
- codes are normalized to 6-digit strings;
- Excel-style numeric values such as
123456.0are coerced to123456; and - only valid 6-digit HS codes are retained for sector matching.
- R (recommended: R 4.2+)
- Packages:
readxl,writexl,dplyr,tidyr,lubridate,ggplot2,forcats,this.path
Install packages in R:
install.packages(c(
"readxl", "writexl", "dplyr", "tidyr", "lubridate",
"ggplot2", "forcats", "this.path"
))Run all scripts from the repository root or from any location, because each script resolves paths relative to its own file location.
- Prepare the analysis-ready datasets:
Rscript Code/prepare_input_data.RThis script reads:
Data/GTA Intervention Data.xlsxMethod/GTA Intervention Classification.xlsxMethod/Energy Sector HS Code Classification.xlsx
It writes:
Data/Input Data SetA.xlsxData/Input Data SetB.xlsx
- Generate Set A figures:
Rscript Code/plot_figures_SetA.R- Generate Set B figures:
Rscript Code/plot_figures_SetB.Rplot_figures_SetA.R exports six figures to Figures/SetA/:
SetA_US_Energy_Trade_Barriers_2009-2024_with_subsidiesSetA_US_Energy_Trade_Barriers_2009-2024_with_subsidies_no_titleSetA_US_Energy_Trade_Barriers_2009-2024_tariff_ntmSetA_US_Energy_Trade_Barriers_2009-2024_tariff_ntm_no_titleSetA_US_Energy_Trade_Barriers_2009-2024_annualSetA_US_Energy_Trade_Barriers_2009-2024_annual_no_title
plot_figures_SetB.R exports six figures to Figures/SetB/:
SetB_US_Energy_Trade_Barriers_2009-2024_intervention_product_with_subsidiesSetB_US_Energy_Trade_Barriers_2009-2024_intervention_product_with_subsidies_no_titleSetB_US_Energy_Trade_Barriers_2009-2024_intervention_product_tariff_ntmSetB_US_Energy_Trade_Barriers_2009-2024_intervention_product_tariff_ntm_no_titleSetB_US_Energy_Trade_Barriers_2009-2024_intervention_product_annualSetB_US_Energy_Trade_Barriers_2009-2024_intervention_product_annual_no_title
Each exported figure is saved as both .png and .pdf.
The plotted period groupings are:
2009-20122013-20162017-20202021-2024
Set A and Set B should be interpreted together:
- Set A reflects the number of distinct policy interventions affecting each sector.
- Set B reflects the breadth of product coverage within those interventions.
Because one intervention can affect multiple HS codes and multiple sectors, Set A deduplicates to one count per intervention-sector pair, while Set B retains the product-level breadth.
For the figure variants:
- the
with_subsidiesoutputs include all three policy categories; - the
tariff_ntmandannualoutputs excludeSubsidies; and - the annual line charts aggregate only
TariffandNTMobservations.
If you use this repository, please cite the associated paper:
Citation details to be added upon publication.
Please follow the licensing and terms of use for underlying data sources, including Global Trade Alert, and contact the authors for reuse questions if needed.