Can machine learning improve trade modelling?

This is the question that Lucien Chaffa, Martin Trépanier and Thierry Warin seek to answer in their latest research. Amidst a flurry of trade policy changes in recent years, trade modelling has become increasingly important for understanding the economic outcomes of shifting policy.

In this regard, the gravity model of trade provides a theoretically intuitive means of explaining bilateral trade while also being empirically robust. It predicts that the volume of trade between two countries is positively related to their economic size and inversely related to the trade costs between them1. In simple terms, large economies that are geographically close tend to trade more with each other, akin to the gravitational pull between celestial objects.

The model incorporates variables to capture trade costs, such as shared land borders (which reduce transport costs) and common languages (which reduce information costs). These variables can be expressed in logarithmic form, which allows their coefficients to be interpreted as elasticities i.e., the percentage change in trade associated with a one percent change in the variable.

The issue

As more variables are added to a gravity model, it becomes harder to isolate the unique contribution of each in explaining trade flows. Standard gravity models also assume that relationships are linear, which means they may not capture more complex interactions between variables such as the varying effect of geographic distance and the mode of transport used for a particular trade.

Removing observations with zero trade values is required when using logarithmic transformations, but this distorts the overall picture. It biases the model toward existing trade relationships and underestimates the barriers that prevent trade from happening in the first place. While methods like Poisson Pseudo Maximum Likelihood (PPML) can address this issue, it may not fully capture the real-world relationships between variables.

Research and findings

Given the constraints of conventional estimation methods, this study investigates whether machine learning (ML) based methods are better at explaining bilateral trade flows.

The study uses a comprehensive dataset on trade among ten Canadian provinces and fifty U.S. states to compare traditional and ML-based approaches applied to two versions of the gravity equation. Two sets of estimations are conducted, one that includes zero trade values and one that excludes them.

The comparison between the approaches evaluates the predictive accuracy, robustness to zero trade values, and interpretability of results. This makes it possible to assess the strengths and limitations of each estimator.

Performance Comparison of Estimation Approaches
Gravity EquationTrade ValuesEstimation ApproachEstimation ModelRMSEMAE
1Non-zero flows onlyTraditionalOLS1.871.290.70
PPML4228.45895.380.17
GPML3053.94596.240.65
NBPML3340.50636.39 0.65
Machine LearningRandom Forest1.491.050.81
XGBoost1.330.940.85
Neural Network1.831.200.73
All flowsTraditionalPPML3974.63930.280.22
NBPML4661.11852.790.82
Machine LearningRandom Forest2678.07689.710.53
XGBoost2190.64748.740.68
Neural Network3120.31864.290.40
2Non-zero flows onlyTraditionalOLS1.471.050.83
PPML4271.081032.070.20
GPML84051.748377.110.53
NBPML49478.334955.340.53
Machine LearningRandom Forest1.320.910.86
XGBoost1.270.880.87
Neural Network1.330.910.86
All flowsTraditionalPPML3972.851072.200.18
NBPML30867.105462.120.68
Machine LearningRandom Forest2624.04730.890.54
XGBoost2169.56714.910.70
Neural Network3033.20869.840.43

Note: Lower RMSE and MAE values indicate higher predictive accuracy, while a higher R2 reflects a better model fit.

As shown in the table above, ML-based approaches significantly outperform traditional methods in predicting trade flows, demonstrating a stronger ability to capture complex patterns. This holds true even when zero trade values are included, though performance declines slightly across both versions of the gravity equation.

This suggests that ML-based approaches are effective at capturing nonlinearities and intricate interactions without imposing a functional form. However, this advantage diminishes when interpretability is required for analysis and policy use.

Key takeaways

This study finds that while ML-based approaches outperform traditional models like PPML, their limited interpretability reduces their usefulness for policy design. PPML remains reliable even when handling zero trade values and offers clearer insights into how variables affect trade flows. However, ongoing advancements in ML algorithms are likely to improve the interpretability of their results in the near future.

For policymakers who need robust forecasting tools, ML-based approaches can complement traditional models, especially in projecting the impact of changes to trade policies or regional trade agreements. These results highlight the importance of integrating ML tools thoughtfully into trade policy analysis to balance predictive power with interpretability.

Read the working paper here.


  1. Piermartini, R., & Teh, R. (2005). Demystifying modelling methods for trade policy (WTO Discussion Paper 10). World Trade Organization (WTO). https://hdl.handle.net/10419/107045

FR