GEPPML (General Equilibrium PPML) is a methodology for analyzing trade policy using general equilibrium models estimated with the Poisson Pseudo-Maximum Likelihood (PPML) estimator. It was developed by Anderson, Larch, and Yotov (2018).
- Accessibility: R is free and open-source
- Flexibility: Easier to customize and extend
- Integration: Better integration with modern data science workflows
- Performance: The
fixestpackage is very fast - Reproducibility: Easier to share and replicate
Yes! The R implementation is designed to replicate the Stata results exactly (within numerical precision). You can verify this using the scripts/validation_report.R script.
R version 4.0 or higher is recommended. The package may work with older versions but has not been tested.
Install the required packages:
install.packages(c("data.table", "fixest", "haven", "dplyr"))If using RStudio:
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))If not using RStudio:
setwd("C:/path/to/GEPPML_R") # Replace with your actual pathOn a modern computer, the full analysis typically takes:
- Baseline scenario: < 1 second
- Conditional scenario: < 1 second
- Full endowment scenario: 10-30 seconds (depending on convergence)
Try:
- Increasing the tolerance:
tolerance <- 0.01(less precise but faster) - Checking your data for errors
- Using a better starting point
The script will stop after 100 iterations by default. You can:
- Increase
max_iterations(e.g., to 200) - Check if results are close enough for your purposes
- Investigate the data for potential issues
Yes! Your data should have:
exporter: Exporting country codeimporter: Importing country codetrade: Bilateral trade flows- Gravity variables (distance, contiguity, etc.)
- Same structure as the original data
- Conditional GE: Only multilateral resistances adjust; output and expenditure are fixed
- Full GE: Everything adjusts including output, expenditure, and prices (complete equilibrium)
A positive rGDP_full_ch means the country's real GDP increases under the counterfactual scenario (e.g., border removal).
Some countries may lose from policy changes due to:
- Trade diversion
- Changes in multilateral resistance
- General equilibrium effects
Sigma is the trade elasticity. The value of 7 is commonly used in the literature based on empirical estimates. You can change it based on your sector or research needs.
Modify the counterfactual trade costs in the script. Examples:
Regional Trade Agreement:
dt[, t_ij_ctrf := exp(DIST_est * LN_DIST + CNTG_est * CNTG +
BRDR_est * BRDR - 0.5 * RTA)]50% reduction in distance friction:
dt[, t_ij_ctrf := exp(DIST_est * LN_DIST * 0.5 + CNTG_est * CNTG +
BRDR_est * BRDR)]Replace "DEU" (Germany) with your desired country code:
dt[exporter == "USA", exporter := "ZZZ"]
dt[importer == "USA", importer := "ZZZ"]Yes! Modify the baseline model specification:
baseline_model <- feglm(
trade ~ LN_DIST + CNTG + BRDR + YOUR_VARIABLE | exporter + importer,
data = dt,
family = poisson()
)And update the trade costs accordingly.
You would need to:
- Have sector-specific data
- Run the analysis separately for each sector
- Aggregate results as needed
This is not currently automated but could be added.
All results are saved in the output/ folder:
all_indexes_geppml.csv: Main results (CSV)all_indexes_geppml.rds: Main results (R format)full_static_all.rds: Complete dataset with all variablesgeppml.log: Execution log
Use the example script:
source("scripts/example_analysis.R")Or install openxlsx:
install.packages("openxlsx")
library(openxlsx)
write.xlsx(results, "output/results.xlsx")Yes! See scripts/example_analysis.R for examples using ggplot2.
Make sure your data has the required column names exactly as specified.
This usually means a variable that should be numeric is character. Check your data types.
Check:
- Data quality and units
- Trade cost specification
- Convergence (was it achieved?)
- Parameter values (especially sigma)
Increase R's memory limit:
memory.limit(size = 16000) # 16GB (Windows only)Or use a computer with more RAM.
See the README for the full citation. Always cite both:
- The original Anderson, Larch, and Yotov (2018) paper
- This R implementation
Yes! The package is open-source under the MIT License. Please cite appropriately.
The methodology is published in a peer-reviewed journal (The World Economy). This R implementation is a replication package.
- Check this FAQ
- Read the README.md
- Look at the example scripts
- Open an issue on GitHub
- Email: jamiubadmus001@gmail.com
Open an issue on GitHub with:
- Description of the bug
- Steps to reproduce
- Error messages
- Your R version and OS
Yes! Open an issue with the "enhancement" tag and describe what you need.
See CONTRIBUTING.md for detailed guidelines. We welcome:
- Bug reports and fixes
- Documentation improvements
- New features
- Examples and use cases
- Testing on different platforms
Last Updated: January 19, 2026
Didn't find your answer?
- GitHub Issues: https://github.com/jamiubadmusng/GEPPML-R/issues
- Email: jamiubadmus001@gmail.com