## wpiea2020175-print-pdf - Section 6 uses the algorithms to analyze the export structure of Paraguay and diversification

## Source details

**Canonical URL:** [wpiea2020175-print-pdf - Section 6 uses the algorithms to analyze the export structure of Paraguay and diversification](https://www.imf.org/-/media/files/publications/wp/2020/english/wpiea2020175-print-pdf.pdf)

## Other formats

- [Markdown version](/-/media/files/publications/wp/2020/english/wpiea2020175-print-pdf.pdf.md)
- [Structured JSON version](/-/media/files/publications/wp/2020/english/wpiea2020175-print-pdf.pdf.json)

---

### The Case for Optimized Diversification
- Export diversification is widely associated with stronger economic development, particularly for developing and emerging market countries.
- Empirical literature and country studies cited indicate a positive association between export diversification and economic development (examples: Imbs and Wacziarg, 2003; Klinger and Lederman 2004 and 2011; Cadot et al., 2011; Feenstra and Kee, 2008; IMF, 2014; Al-Marhubi, 2000; Balaguer and Cantavella-Jorda, 2004; Herzer and Danzinger, 2006; Hausmann et al., 2007).
- Empirical stylized facts (SIC 4-digit industry data):
  - Higher-income economies tend to have more diversified export structures.
  - Regressing the number of export products with Revealed Comparative Advantage (RCA) on real GDP per capita relative to the US indicates a strong positive relationship.
  - Regressing average RCA among a country’s high-RCA exports on income level relative to the US shows a negative relationship (controlling for country size): interpreted as richer countries earning export income from a wider variety of products.
  - More diversified exporters tend to grow faster subsequently: regressing average annual growth rate (2007–2017) on the number of high-RCA exports in 2007 (controlling for initial GDP per capita) shows a positive association. Panel regressions with country fixed effects corroborate.
  - Countries with more diversified export structures have lower growth volatility: regressing standard deviation of annual real GDP growth (2007–2017) on number of high-RCA exports in 2007 (controlling for initial GDP level and country size) indicates a strong negative relationship. Panel regressions corroborate.
- Caveats:
  - Not all diversification is beneficial; diversification misaligned with country fundamentals can have negative consequences (example: forced industrialization of former Soviet-block nations).
  - Overdependence on commodity exports (delayed diversification) also leads to negative outcomes.
  - Exporting more sophisticated or knowledge-intensive products is associated with faster growth, controlling for initial income.
- Objective of the paper: construct a diversification recommendation system that accounts for a country’s current fundamentals and future potentials to create optimized diversification strategies supporting long-term growth.

### Data and Definitions
- Source data:
  - UN Comtrade database, annual export value data by the 786 SITC 4-digit product categories, for around 260 countries.
  - Data cleaned by the Atlas of Economic Complexity.
  - The number of countries available varies by year.
- Key concept: Revealed Comparative Advantage (RCA), introduced by Balassa & Noland (1965).
- RCA formula (as provided):
  - RCA_ij = E_ij / E_i  E_j / ∑_{i' ∈ I} E_{i'}
    - where E_ij is the export value of product i from country j,
    - E_i is the total export values of country i,
    - E_j is the total exports of product j from all countries around the world,
    - ∑_{i' ∈ I} E_{i'} is the total world exports.
- Definition used:
  - High-RCA product for country i: RCA_ij > 1.
  - Example: vehicle exports were about 12 percent of total world exports in 2017, while they constituted 22 percent of total exports from Mexico. Therefore, RCA_ij = 22/12 = 1.8 for Mexico’s vehicle exports in 2017; since it is >1, automobiles is a high-RCA product for Mexico’s 2017 exports.
- Clarification of "diversification":
  - Goal is increasing the number of products in which a country has comparative advantages (increasing number of high-RCA products), not merely increasing the count of exported product lines whose shares mirror world shares.
  - Developing-world challenge: too few specializations that dominate export baskets; some commodity exports can have RCA > 100.
- Product classification:
  - SITC 4-digit classification chosen as generally appropriate for measuring export diversification.
  - Rationale: 4-digit distinctions can imply different market dynamics, technologies, storage/transportation needs, and geographic reach.
  - Caveats: suitability may vary by product and country size; SITC is a statistical tool not designed exclusively for diversification analysis.

### Empirical Methodology
- Objective: construct a recommendation system for export categories using collaborative filtering recommender algorithms:
  - Product-based K-nearest neighbors (KNN)
  - Country-based K-nearest neighbors (KNN)
  - Singular Value Decomposition (SVD)
- Goal: produce "top-N recommendations" — list N product categories a country should export the most of by predicting RCA scores and recommending N products with highest predicted RCA.
- Data matrix representation:
  - R is an m×n matrix where m = number of countries in database, n = total number of SITC 4-digit products.
  - Entry r_ij is country i’s RCA score in product j.
  - R is sparse; r_ij = 0 if country i does not export product j.
  - If multiple years included, each country-year is a row in R (m = c × y). Most implementations use y = 1.
  - Experimentation: including multiple years did not significantly improve evaluation metrics and increased computation time.
- Neighborhood-based algorithms — implementations:
  - Product-based KNN
    - Products represented as vectors p_j = [r_1j, r_2j, ..., r_mj]^T.
    - Similarity measure: cosine similarity (ranges from -1 to 1).
    - Prediction for country i: weighted average RCA of country i’s high-RCA product set (RCA > 1), weights = cosine similarity to target product.
    - Recommendations: N products with highest predicted r_ij.
  - Country-based KNN
    - Countries represented as vectors q_i across n products.
    - Similarity: cosine similarity between q_i and q_j.
    - Prediction for country i: weighted average RCA of product l across K most similar countries, weights = similarity scores.
    - Recommendations: N products with highest predicted r_il.
  - Comparative note: with n > m in sample, product-based KNN may more accurately identify relatedness among products than country-similarity methods; empirical results support this.

### Matrix Factorization Algorithm (SVD)
- Limitations of KNN:
  - Scalability: computation increases at O(n) time as m and n increase.
  - Poor performance with sparse data: similarity calculations become inaccurate with many missing entries.
  - Implicit equal weighting of features: all rows treated as independent features of equal importance.
  - Context note: "There are close to 800 product categories in the SITC 4-digit product space, while there are just over 250 countries in the sample."
- SVD decomposition: R = U S V′ where U and V are orthogonal matrices of size m×r and n×r, r = rank(R), S is r×r diagonal of singular values sorted in decreasing magnitude.
- Interpretation:
  - U relates countries to latent factors; V′ relates products to latent factors; S scales latent factors.
  - Latent factors are implicit and generally not human-interpretable.
- Optimization objective used in practice (due to sparsity and computational constraints):
  - min_{u_i, v_j} ∑_{r_ij ∈ R} (r_ij − u_i · v_j)² + λ(‖u_i‖² + ‖v_j‖²)
    - λ is a regularization factor.
  - Minimization method: stochastic gradient descent using the python Surprise library.
  - Recommendation criterion: products with highest predicted r̂_ij = û_i · v̂_j.

### Evaluation approach and challenges
- Standard ML metrics (accuracy score, mean squared error) are backward-looking and insufficient for assessing usefulness for future-oriented diversification recommendations.
- A successful export-diversification recommender should:
  - Correctly predict a country’s current comparative advantage ("taste").
  - Be forward-looking enough to guide future development choices—recommend both aligned and "stretch" products.
- Evaluation approach in study:
  - Two criteria:
    1. How well recommendations capture the country’s export structure at present.
    2. How well recommendations predict long-term structural changes (comparison of recommendations generated in a given year with actual export composition 20 years later).
  - Implicit assumption: high-growth countries that diversified successfully provide a legitimacy benchmark for diversification direction.
- Implementation choices for evaluation:
  - Baseline N = 100 for top-N metrics.
  - Cutoff score of 1 chosen across models when reporting number of recommended items classified as high-RCA.
  - Top-N hit rate computed based on the 100 recommendations with highest scores to avoid bias from different score scalings across models.

### Key empirical findings (test cases: China, India, Chile, Poland)
- China (data year: 1995; outcomes by 2015)
  - 1995: 242 high-RCA exports; 2015: 302 high-RCA exports.
  - Product-based KNN:
    - Top-N hit rate for existing 1995 exports: 17 percent.
    - Recommended basket closer to China’s 2015 export-share distribution for 9 out of 10 SITC 1-digit categories than to 1995.
    - Correctly predicts direction and structural change at macro level for a majority of product categories.
  - Country-based KNN:
    - Higher hit rate than product-based KNN but less forward-looking.
    - Correctly predicted directional change for 5 out of 10 1-digit categories.
  - SVD:
    - Recommendations overlap almost perfectly with China’s 1995 high-RCA basket; only 2 percent of recommendations are new.
    - Correctly predicted directional change for 4 out of 10 1-digit categories.
- India (data year: 1985; outcomes by 2005)
  - 1985: 160 high-RCA exports; 2005: 256 high-RCA exports.
  - Product-based KNN:
    - Lowest hit rate among models; produced the largest number of recommendations.
    - Correctly predicted structural changes for 9 out of 10 SITC 1-digit industries.
  - Country-based KNN:
    - Intermediate performance; correctly aligned with directional change in 4 categories.
  - SVD:
    - Best at recommending products closely aligned with existing 1985 export portfolio.
    - Correctly aligned with directional change in 5 categories.
- Chile (data year: 1980; outcomes by 2000)
  - Per capita real GDP growth averaged over 4 percent from mid 80s to 2000.
  - Number of high-RCA exports increased by 45 percent from 1980 to 2000.
  - 1980: 75 high-RCA exports.
  - Hit rates lower across models compared to China and India.
    - Product-based KNN and SVD under-recommended commodity categories and recommended more industrial exports.
    - Country-based KNN recommendations were more closely aligned with Chile’s 1980 export portfolio.
  - Product-based KNN recommendations were closer to Chile’s export structure in 2000 than to 1980.
  - Possible explanations: small initial set of high-RCA exports (75) limited source material; algorithms may recommend less reliance on commodity exports given country fundamentals.
- Poland (data year: 1985; outcomes by 2005)
  - 1985: 187 high-RCA exports; 2005: 287 high-RCA exports (50 percent increase).
  - SVD yielded recommendations most closely aligned with 1985 export profile.
  - Product-based KNN had the lowest hit rate but was fairly forward-looking; correctly predicted directional change for 7 out of 10 SITC 1-digit categories.
  - Country-based KNN performance intermediate.

### Analytical implications and policy guidance
- Tradeoffs across algorithms:
  - SVD tends to produce conservative recommendations closely fitting current export profiles (high hit rates) but limited novelty (example: China SVD produced only 2 percent new items).
  - Product-based KNN tends to be more forward-looking and better at predicting structural change over 20-year horizons but has lower hit rates for matching current export baskets.
  - Country-based KNN provides intermediate outcomes.
- Practical guidance:
  - Structural change is long-term; diversifying into higher-value-added categories can coexist with short-to-medium-term diversification aligned with current comparative advantages to reduce volatility.
  - Suggested analytic approach:
    - Give more weight to product-based KNN recommendations, as test cases indicate it is the apparent best among the three algorithms for guiding structural change.
    - Still reference results from country-based KNN and SVD to provide context and cross-checks.
- Limitations for policy adoption:
  - Opacity and interpretability: machine learning recommendations often lack explicit, linearly sequenced economic rationales, which challenges uptake by economists and policymakers.
  - Product-based KNN can outperform country-based methods because it identifies product relatedness beyond contemporaneous country similarities, but the algorithms do not provide tidy economic theories explaining recommendations.
  - For commodity-dependent countries, algorithms may recommend moving away from primary-material dependence, but do not supply the policy instruments or causal explanation for how to achieve such transitions.

*Source: wpiea2020175-print-pdf — Section 6, and sections 4.2 and 5.2 from the supplied content unit.*

### Section 6 uses the algorithms to analyze the export structure of Paraguay and diversification

### wpiea2020175-print-pdf - Section 6 uses the algorithms to analyze the export structure of Paraguay and diversification

### The Case for Optimized Diversification
- Export diversification is widely associated with stronger economic development, particularly for developing and emerging market countries.
- Empirical literature cited indicates a positive association between export diversification and economic development (examples: Imbs and Wacziarg, 2003; Klinger and Lederman 2004 and 2011; Cadot et al., 2011).
- Country studies cited:
  - Feenstra and Kee (2008): sustained increase in export diversification results in increases in productivity and a notable increase in GDP of the exporters.
  - IMF (2014): diversification in exports and domestic production has been conducive to faster economic growth in LICs.
  - Al-Marhubi (2000): similar findings for a set of developing economies.
  - Balaguer and Cantavella-Jorda (2004): export variety key in Spain’s development.
  - Herzer and Danzinger (2006): positive impact of export diversification on Chile’s growth.
- Empirical stylized facts from SIC 4-digit industry data:
  - Higher-income economies tend to have more diversified export structures.
  - Regressing the number of export products with Revealed Comparative Advantage (RCA) on real GDP per capita relative to the US indicates a strong positive relationship (Figure 3).
  - Regressing average RCA among a country’s high-RCA exports on income level relative to the US shows a negative relationship, controlling for country size—interpreted as richer countries earning export income from a wider variety of products.
  - More diversified exporters tend to grow faster subsequently: regressing average annual growth rate (2007–2017) on the number of high-RCA exports in 2007, controlling for initial GDP per capita, shows positive association (Figure 4). The pattern holds in panel regressions with country fixed effects.
  - Countries with more diversified export structures have lower growth volatility: regressing standard deviation of annual real GDP growth (2007–2017) on number of high-RCA exports in 2007, controlling for initial GDP level and country size, indicates a strong negative relationship (Figure 5). Panel regressions corroborate.
- Caveats on diversification:
  - Not all diversification is beneficial; diversification misaligned with country fundamentals can have negative growth consequences (example: forced industrialization of former Soviet-block nations).
  - Overdependence on commodity exports (delayed diversification) also leads to negative outcomes.
  - Hausmann et al. (2007): exporting more sophisticated or knowledge-intensive products is associated with faster growth, controlling for initial income.
- Objective of the paper: construct a diversification recommendation system that accounts for a country’s current fundamentals and future potentials to create optimized diversification strategies supporting long-term growth.

### Data and Definitions
- Source data: UN Comtrade database, annual export value data by the 786 SITC 4-digit product categories, for around 260 countries.
  - Data is cleaned by the Atlas of Economic Complexity.
  - The number of countries available varies by year.
- Key concept: Revealed Comparative Advantage (RCA), introduced by Balassa & Noland (1965), measures relative importance of a product in a country’s export basket.
- Formal RCA formula (as provided):
  - RCA_ij = E_ij / E_i  E_j / ∑_{i' ∈ I} E_{i'}
    - where E_ij is the export value of product i from country j,
    - E_i is the total export values of country i,
    - E_j is the total exports of product j from all countries around the world,
    - ∑_{i' ∈ I} E_{i'} is the total world exports.
- Definition used in the paper:
  - A high-RCA product for country i is defined as a product with RCA_ij > 1.
  - Interpretation: the product’s share in the country’s exports is greater than its share in total world exports.
  - Example: vehicle exports were about 12 percent of total world exports in 2017, while they constituted 22 percent of total exports from Mexico. Therefore, RCA_ij = 22/12 = 1.8 for Mexico’s vehicle exports in 2017; since it is >1, automobiles is a high-RCA product for Mexico.
- Clarification of "diversification":
  - Goal is increasing the number of products in which a country has comparative advantages (i.e., increasing number of high-RCA products), not merely increasing the count of exported product lines whose shares merely mirror world shares.
  - The developing world’s challenge: too few specializations that dominate export baskets; some commodity exports can have RCA > 100.
- Product classification level for measuring diversification:
  - SITC provides 5 levels; the paper concludes SITC 4-digit classification is generally appropriate for measuring export diversification.
  - Rationale: 4-digit distinctions (e.g., bovine animals vs swine; bovine meat fresh or chilled (0111) vs frozen (0112)) can imply different market dynamics, technologies, storage/transportation needs, and geographic reach—thus relevant for diversification goals.
  - Caveats: suitability may vary by product and by country size; SITC is a statistical tool not designed exclusively for diversification analysis; diversification value likely stems from differences in raw material, degree of processing, use/function, and economic activity.

### Empirical Methodology
- Objective: construct a recommendation system for export categories based on algorithms used in collaborative filtering recommender systems.
- Algorithms used:
  - Product-based K-nearest neighbors (KNN)
  - Country-based K-nearest neighbors (KNN)
  - Singular Value Decomposition (SVD)
- Goal of methods: produce "top-N recommendations" — generate a list of N product categories that a country should export the most of by predicting RCA scores and recommending N products with highest predicted RCA.
- Data matrix representation:
  - R is an m×n matrix where m = number of countries in database, n = total number of SITC 4-digit products.
  - Entry r_ij is country i’s RCA score in product j.
  - R is sparse; r_ij = 0 if country i does not export product j.
  - If multiple years included, each country-year is a row in R, i.e. m = c × y, where c = number of countries, y = number of years. In most implementations discussed, y = 1.
  - Experimentation found including multiple years did not significantly improve evaluation metrics and increased computation time.
- Neighborhood-Based Algorithms

  Product-Based KNN
  - Basic idea: look at products a country already has a revealed comparative advantage in, then recommend other products similar to those.
  - Products represented as vectors:
    - R = [p_1, p_2, ..., p_n], where p_j is a vector of length m representing RCA scores of product j for all m countries:
      - p_j = [r_1j, r_2j, ..., r_mj]^T
    - Each product has m features in machine learning terminology.
  - Similarity measure: cosine similarity between product vectors p_j and p_l:
    - cosine = (p_j · p_l) / (‖p_j‖‖p_l‖), ranges from -1 to 1.
  - Implementation steps for country i:
    1. Represent each product as vector of RCA scores p_j.
    2. Select set of K products in which country i has RCA > 1 (the high-RCA product set).
    3. For each j ∈ [1, n], calculate predicted r_ij as the weighted average RCA score of the high-RCA product set, weighted by cosine similarity between product j and products in the country’s high-RCA set.
    4. Recommended products for country i are the N products with the highest predicted r_ij values.

  Country-Based KNN
  - Idea: find countries similar to the country in question and recommend products those similar countries export beyond the target country’s current exports.
  - Country vectors:
    - R = [q_1; q_2; ...; q_m], where q_i is a vector of length n representing country i’s RCA scores across n product categories.
  - Implementation steps for country i:
    1. Calculate cosine similarity between q_i and q_j for all j ≠ i.
    2. Select set of K countries with highest similarity scores to country i.
    3. For each l ∈ [1, n], calculate predicted r_il as the weighted average RCA score of product l across the K countries, weighted by similarity score to country i.
    4. Recommended products for country i are the N products with the highest predicted r_ij values.
  - Note on comparative performance:
    - Although both KNN approaches have similar logic, perspectives differ and produce different recommendation results.
    - Since in the data sample n > m, it may be easier to identify relatedness between products with more accuracy than to identify similar countries, suggesting product-based KNN may be superior. Results in the paper support this hypothesis.

*Source: wpiea2020175-print-pdf - Section 6 uses the algorithms to analyze the export structure of Paraguay and diversification*

### 4.2    Matrix Factorization Algorithm

### 4.2    Matrix Factorization Algorithm

### Limitations of KNN algorithms
- Scalability: computation required to calculate similarity scores increases at O(n) time as m and n increase.
- Poor performance with sparse data: explicitly calculating similarities among vectors becomes increasingly inaccurate when there’s a lot of missing data in matrix R.
- Implicit equal weighting of features: the algorithm treats each row of the product vector (or the country vector) as independent features of equal importance, making missing rows more damaging compared to algorithms that impose discretion on relative importance of different data points.
- For the current use case, the first drawback is less concerning because m and n of the country-product space are relatively small when not including multiple years; the second drawback is more problematic, as KNN would perform worse on under-diversified countries with many missing entries in R—precisely the countries most in need of diversification recommendations.
- Context note from source: "There are close to 800 product categories in the SITC 4-digit product space, while there are just over 250 countries in the sample."

### Singular Value Decomposition (SVD) — purpose and interpretation
- Decomposition: R = U S V′ where
  - U and V are orthogonal matrices of size m×r and n×r respectively.
  - r is the rank of R.
  - S is an r×r diagonal matrix with singular values of R on the diagonal sorted in decreasing magnitude.
- Latent factors: products and countries are represented as combinations of latent factors (implicit, orthogonal features).
  - U represents the relationship between countries and latent factors.
  - V′ represents similarity between products and latent factors.
  - Diagonal elements of S are relative scaling values assigned to latent factors.
- Illustrative (hypothetical) example:
  - u_i = [.55, .4, .05] interpreted as country i described as 50% labor, 40% land, and 5% knowledge (resource-rich, developing country).
  - v_j = [.15, .05, .80]′ interpreted as product j characterized as 15% labor, 5% land, and 80% knowledge (technology-intensive product).
  - r_ij = u_i · v_j scaled by appropriate diagonal element in S; in the example r_ij would be relatively small (country i lacks comparative advantage in product j).
- Practical note: latent factors computed by optimization are not human-interpretable and serve as features that more efficiently characterize the data.

### SVD implementation and objective
- Goal: find best estimations of U and V′ and produce recommendations based on estimated r̂_ij = û_i · v̂_j.
- Due to sparsity of R, orthogonality constraints for U and V′ are computationally untenable in practice.
- Optimization problem solved:
  - min_{u_i, v_j} ∑_{r_ij ∈ R} (r_ij − u_i · v_j)² + λ(‖u_i‖² + ‖v_j‖²)
  - λ is a regularization factor.
- Minimization method: stochastic gradient descent using the python Surprise library for building recommender systems.
- Recommendation criterion: products with highest predicted r̂_ij value for country i.

### Evaluation challenges for recommender systems applied to export diversification
- Standard ML metrics (accuracy score, mean squared error) are backward-looking and assess fit to test data; they do not fully capture usefulness of recommendations for unseen future outcomes.
- Defining a "good recommendation" depends on the use case and is not unambiguous.
- E-commerce metrics (click-through rate, purchase rate) can lead to local optimization and may not capture broader usefulness.
- For news recommendations, focusing exclusively on past-aligned suggestions can reinforce echo chambers and limit knowledge expansion.
- For export diversification recommendations, a successful system should:
  - Correctly predict a country’s current comparative advantage ("taste").
  - Be forward-looking enough to guide future development choices—recommend both products aligned with current advantages and "stretch goals" that support diversified and sustainable growth.
- Evaluation approach used in study:
  - Two criteria:
    1. How well recommendations capture the country’s export structure at present.
    2. How well recommendations predict long-term structural changes of the country’s export basket (comparison of recommendations generated in a given year with actual export composition 20 years later).
  - Implicit assumption: high-growth countries that diversified successfully provide a legitimacy benchmark for the direction of diversification.

### Key empirical findings from test cases (models compared: product-based KNN, country-based KNN, SVD)
- General methodological notes:
  - Baseline N = 100 for top-N metrics.
  - Cutoff score of 1 chosen across models when reporting number of recommended items classified as high-RCA.
  - Top-N hit rate computed based on the 100 recommendations with highest scores to avoid bias from different score scalings across models.

- China (data year: 1995; outcomes by 2015)
  - China had 242 high-RCA exports in 1995; by 2015 the number increased to 302.
  - Product-based KNN:
    - Lowest top-N hit rate for existing 1995 exports: top-N hit rate of 17 percent.
    - Export-share-wise, recommended basket is closer to China’s export basket in 2015 for 9 out of 10 SITC 1-digit categories than to 1995.
    - Correctly predicts direction and structural change at macro level for a majority of product categories.
  - Country-based KNN:
    - Higher hit rate than product-based KNN but less forward-looking.
    - Correctly predicted direction of export structural change for 5 out of 10 1-digit categories.
  - SVD:
    - Recommendations overlap almost perfectly with China’s high-RCA export basket in 1995.
    - Only 2 percent of the recommendations are new (not already among existing high-RCA exports), limiting aspirational value.
    - SVD only correctly predicted 4 out of 10 1-digit categories’ directional change toward 2015.

- India (data year: 1985; outcomes by 2005)
  - India had 160 high-RCA exports in 1985; by 2005 the number increased to 256.
  - Product-based KNN:
    - Lowest hit rate among models; produced the largest number of recommendations.
    - Correctly predicted structural changes for 9 out of 10 SITC 1-digit industries.
  - Country-based KNN:
    - Intermediate performance; correctly aligned with directional change in 4 categories.
  - SVD:
    - Best performing in terms of recommending products closely aligned with existing export portfolio in 1985.
    - Correctly aligned with directional change in 5 categories.

- Chile (data year: 1980; outcomes by 2000)
  - From mid 80s to 2000, per capita real GDP growth averaged over 4 percent; number of high-RCA exports increased by 45 percent from 1980 to 2000.
  - In 1980 Chile had 75 high-RCA exports.
  - Hit rates were lower across models compared to China and India, especially for product-based KNN and SVD.
    - Both product-based KNN and SVD under-recommended commodity categories and recommended more industrial exports.
    - Country-based KNN recommendations were more closely aligned with Chile’s 1980 export portfolio.
  - Product-based KNN recommendations were closer to Chile’s export structure in 2000 than to 1980.
  - Possible explanations discussed:
    - Smaller existing number of high-RCA exports in 1980 (75) gave less source material.
    - Algorithms may recommend less reliance on commodity exports given country fundamentals, aligning with human-expert recommendations for commodity-exporting countries in Latin America.

- Poland (data year: 1985; outcomes by 2005)
  - Poland had 187 high-RCA exports in 1985; by 2005 the number increased to 287 (50 percent increase).
  - SVD:
    - Yielded recommendations most closely aligned with existing export profile in 1985.
  - Product-based KNN:
    - Lowest hit rate but offered fairly forward-looking recommendations.
    - Correctly predicted directional change in Poland’s export portfolio for 7 out of 10 SITC 1-digit product categories.
  - Country-based KNN:
    - Performance between product-based KNN and SVD.

### Analytical implications
- Tradeoff evident across algorithms:
  - SVD tends to produce recommendations that closely fit the current export profile (high hit rates) but may lack novelty—few new recommendations (example: China, SVD produced only 2 percent new items).
  - Product-based KNN tends to be more forward-looking, better at predicting structural change over 20-year horizons, but has lower hit rates for matching current export baskets.
  - Country-based KNN provides intermediate outcomes.
- For policy use in export diversification:
  - A recommender system aiming to guide development should balance:
    - Practical alignment with existing comparative advantages (to be actionable).
    - Aspirational guidance toward stretch products that support sustainable structural transformation.
  - Reliance on a single algorithm may either produce overly conservative recommendations (SVD) or recommendations that better anticipate structural change but may have lower short-term plausibility (product-based KNN).

*Source: IMF working paper section "4.2    Matrix Factorization Algorithm" and accompanying results in section 5 (Results, Test Cases). *

### 5.2    Discussion

### 5.2    Discussion

### Opacity and interpretability of machine learning in economic policy
- Machine learning algorithms often produce predictions and judgments without a clear, linearly sequenced, cause-and-effect explanation, which challenges economists and policy makers who expect logical rationales for policy recommendations.
- The human analogy: the cognitive process that distinguishes a picture of a dog from a cat is intuitive rather than explicable in a neat logical narrative; many machine learning algorithms share this characteristic.
- Even simple models such as the KNNs give results without easy explanations of how those results arise.

### Why product-based KNN may outperform country-based methods in tests
- The algorithms themselves do not provide a clear answer for why one method outperforms another; explanations must be inferred from the nature of the data and algorithmic focus.
- Country-based KNN (and to an extent SVD) looks for contemporaneous similarities among countries when making recommendations.
  - Risk: pigeonholing a country with others at a similar income level or region may approximate current fundamentals but offer little insight regarding future directions.
  - Example: In 1995, China looked similar to Haiti in terms of how rich they were and what they exported; Haiti’s data may have had limited usefulness for forward-looking diversification strategy for China.
- Product-based KNN looks for products similar to those a country already exports well.
  - Advantage: allows identification of promising products both up and down the value chain and discovers relations among products not defined by geography or development stage.
  - Strength: better at connecting today’s fundamentals with tomorrow’s potential to produce evolutionary recommendations.
- Additional data-structure explanation: there may be more products than countries, so an algorithm focusing on relatedness among products can capture more nuanced information than one focusing on similarities among countries.

### Limitations of recommendations: absence of explicit economic rationales
- Even when product-based KNN produces forward-looking recommendations that align well with observed export-structure evolution in test cases, the recommendations usually do not come with explicit economic rationales.
  - Example: For Chile, both product-based KNN and SVD appear to disfavor the country’s heavy reliance on primary material exports and concentrate recommendations in other sectors, but the algorithms do not explain why.
- The lack of tidy economic theories attached to algorithmic recommendations can be a major obstacle to wider adoption of machine-learning-generated policy recommendations.
- Section 6 (next) will further illustrate analysis of recommendation results with a Paraguay case study.

### Practical guidance on using these models for diversification analysis
- Structural change is a long-term process; diversifying into higher-value added categories that support long-term growth need not conflict with short-to-medium-term diversification into categories aligned with current comparative advantages.
  - Short-to-medium-term diversification can be easier and can reduce growth volatility.
- Suggested analytic approach:
  - Give more weight to the product-based KNN recommendations, as test cases indicate it is the apparent best among the three algorithms for guiding structural change of an export portfolio.
  - Still reference results from other algorithms (country-based KNN and SVD) to provide additional context and cross-checks.

*Source: 5.2 Discussion (section text) from the supplied content unit.*

---


_Source: https://www.imf.org/-/media/files/publications/wp/2020/english/wpiea2020175-print-pdf.pdf_
