Loading workbench page
Fetching primary parquet sources and computing exhibits.
Fetching primary parquet sources and computing exhibits.
Two countries export the same six-digit product at very different prices. Schott (2004) showed the within-HS6, cross-country dispersion of unit values is large, systematic, and tracks productive capability. Khandelwal (2010, RES77(4): 1450-1476) pushed the quality literature forward by backing quality out of nested-logit demand residuals, and Hallak & Schott (2011, QJE 126(1): 417-474) showed unit-value rankings can diverge from quality rankings once relative prices are netted out. This page plots within-product dispersion over thirty years, shows who exports at the top of each ladder, and measures who has been climbing the fastest between 1996 and 2023.
WITH uv AS (
SELECT year, product_code, country_code,
LN(SUM(export_value) * 1000.0 / NULLIF(SUM(export_qty), 0)) AS lnuv
FROM 'data/parquet/country_year_product/**/*.parquet'
WHERE export_value > 0 AND export_qty > 0
GROUP BY year, product_code, country_code
), per_prod AS (
SELECT year, product_code, STDDEV_SAMP(lnuv) AS sd
FROM uv GROUP BY year, product_code HAVING COUNT(*) >= 5
)
SELECT year, AVG(sd) AS avg_sd FROM per_prod GROUP BY year ORDER BY year;Schott (2004) and Hallak (2006) use within-HS6 unit-value variation across exporters as a descriptive proxy for quality, richer countries tend to sell the same 6-digit good at higher unit prices. Khandelwal (2010) pushed past that proxy by structurally recovering quality from demand residuals, so unit values and quality could be separated; we come back to that distinction in the note at the bottom of the page. Here we stay in the descriptive register: take mid-size passenger cars (Spark-ignition cars, >1.5 to 3 L), plot each exporter's unit value against its GDP per capita in 2023, and eyeball the slope. HS 870323 is a convenient case because BACI's quantity column is reliably in metric tons here; for other HS6 codes quantity can be in pieces, litres, or carats, so USD/t is well-defined only for product-year cells where tonnage coverage is complete.
For each country we compute, within every HS6 it exports, how far its log unit value sits above or below the world cross-country mean for that product, then average across products. Positive numbers mean the country systematically occupies the high-price tier of its markets, a crude revealed-quality premium in the Schott (2004) / Hallak (2006) sense. This is descriptive only: Khandelwal (2010) and Khandelwal, Schott & Wei (2013) show unit values and quality can diverge once demand-side residuals are controlled for.
Change in the revealed-quality premium between 1996 and 2023. A positive delta means a country now sells more of the same HS6 products at higher unit values relative to the world mean than it did in the mid-1990s, Hallak (2006) and Hummels & Klenow (2005) call this the extensive & intensive quality margin of rising exporters.
Not every HS Section offers the same room to move along a price ladder. Homogeneous commodities (iron ore, wheat) show little within-product variation; differentiated manufactures (instruments, machinery, vehicles) show wide ladders. The chart below ranks the 21 HS sections by the average within-product σ(ln UV) across all HS6 codes they contain in 2023. Caveat: BACI's quantity column mixes units (metric tons when reliable; otherwise pieces, litres, carats, or NULL), so 'unit value' at the HS6 level is noisier in sections where non-tonnage units dominate (precious metals, art, some machinery). The ordinal ranking across sections is robust to this; the absolute σ levels are not directly comparable across sections with different unit mixes.
Figure 1 collapses dispersion across all HS6 into a single world number, which hides the sectoral story. Figure 6 tracks within-product σ(ln UV) year by year for four selected sections: HS 16 (machinery & electronics) and HS 17 (vehicles) are canonically differentiated manufactures in the Rauch (1999, JIE 48(1): 7-35) typology; HS 11 (textiles) is a mixed bundle straddling commodity yarns and branded apparel; HS 2 (vegetable products) is homogeneous in Rauch's 'reference-priced' tier. If quality competition has intensified the differentiated-sector lines should separate from the homogeneous line over 1996-2023.
Figures 3 and 4 read the quality ladder through a continuous within-product log premium. A complementary cut, closer to the way trade analysts actually score upgrading, classifies each country-HS6 cell as 'top quartile' if the country's unit value sits at or above the 75th percentile across exporters of that product in that year, and then asks what share of the country's export value falls in those top-tier cells. Hallak (2006, JIE 68(1): 238-265) and Khandelwal (2010) both emphasise that upgrading is concentrated at the top of the distribution rather than shifting the mean; top-quartile share captures exactly that asymmetry. Figure 7 ranks the twenty fastest-rising economies by the change in top-quartile share between 1996 and 2023.
Figures 5 and 6 look at sectional dispersion levels and at four sections' time paths. Figure 8 completes the sectional read by ranking all 21 HS sections by Δσ(ln UV) between 2010 and 2023: a rising σ means within-product price tiers are spreading, the statistical footprint of active quality upgrading by some exporters relative to the rest. Hallak & Schott (2011, QJE126(1)) and Feenstra & Romalis (2014, QJE 129(2): 477-527) both argue that quality-margin widening, not mean movement, is the more informative upgrading signal in trade data.
The nine figures line up with five claims from the primary literature. Schott (2004) established that most trade variation is within the six-digit code, not across it; Figure 1 shows that within-product dispersion in log unit values has been roughly stable at about 1.27 log-points for three decades. Khandelwal (2010) and Hallak & Schott (2011) warn that unit values and quality are not the same object once demand residuals are controlled; the country and climber rankings in Figures 3 and 4 therefore read as revealed-price-tier, not a welfare claim. Henn, Papageorgiou & Spatafora (2013, IMF WP 13/108) reported the same country ranking using IMF trade data and a similar within-product specification, a useful out-of-dataset replication. Feenstra & Romalis (2014, QJE129(2): 477-527) show that quality adjustments substantially raise measured real-income convergence: ignoring quality biases income comparisons in favour of poor countries whose baskets are cheap because they are low-quality. Hummels & Klenow (2005, AER 95(3): 704-723) complete the picture by documenting that richer economies export more varieties at higher unit values, i.e. ladder climbing is both extensive and intensive.
Method note (unit-value adjustments).BACI unit values are reconciled FOB-equivalent values divided by reported quantity (CEPII converts CIF imports to FOB and reconciles bilateral mirror flows). Three well-known biases: (i) quantity mixes metric tons, pieces, litres, carats by HS6, so σ(ln UV) is only comparable within a homogeneous-unit section (HS 72 ferrous metals, HS 87 vehicles); (ii) transport markups load onto unit values, biasing them upward for distant partners (Hummels & Skiba 2004, JPE); (iii) within-HS6 product heterogeneity absorbs what Khandelwal (2010) identifies as vertical quality, so the Schott measure overstates genuine quality dispersion for diversified categories and understates it for homogeneous ones. A structural quality index uses a demand-residual identification (CES or nested logit), projecting out price and size. The workbench ships the Schott/Hallak descriptive register because it is reproducible from BACI alone.
-- exporter UV from BACI, GDP-pc from WDI
SELECT c.iso3, c.name,
SUM(cyp.export_value)*1000.0/ NULLIF(SUM(cyp.export_qty), 0) AS uv,
w.value AS gdp_pc
FROM 'data/parquet/country_year_product/**/*.parquet' cyp
JOIN 'data/parquet/countries.parquet' c ON c.code = cyp.country_code
JOIN 'data/parquet/wdi_data.parquet' w
ON w.iso3 = c.iso3 AND w.indicator='NY.GDP.PCAP.CD' AND w.year=2023
WHERE cyp.product_code='870323' AND cyp.year=2023
AND cyp.export_value>0 AND cyp.export_qty>0
GROUP BY c.iso3, c.name, w.value
HAVING SUM(cyp.export_qty) > 100;WITH uv AS (
SELECT product_code, country_code,
LN(SUM(export_value)*1000.0/ NULLIF(SUM(export_qty), 0)) AS lnuv
FROM 'data/parquet/country_year_product/**/*.parquet'
WHERE year=2023 AND export_value>0 AND export_qty>0
GROUP BY product_code, country_code
), per_prod AS (
SELECT product_code, STDDEV_SAMP(lnuv) AS sd
FROM uv GROUP BY product_code HAVING COUNT(*) >= 5
)
SELECT p.section, AVG(per_prod.sd) AS avg_sd
FROM per_prod
JOIN products p ON p.code = per_prod.product_code
GROUP BY p.section ORDER BY avg_sd DESC;WITH uv AS (
SELECT year, product_code, country_code,
LN(SUM(export_value)*1000.0/ NULLIF(SUM(export_qty), 0)) AS lnuv
FROM 'data/parquet/country_year_product/**/*.parquet'
WHERE export_value>0 AND export_qty>0
GROUP BY year, product_code, country_code
), per_prod AS (
SELECT year, product_code, STDDEV_SAMP(lnuv) AS sd
FROM uv GROUP BY year, product_code HAVING COUNT(*) >= 5
)
SELECT p.section, per_prod.year, AVG(per_prod.sd) AS avg_sd
FROM per_prod
JOIN products p ON p.code = per_prod.product_code
WHERE p.section IN (2, 11, 16, 17)
GROUP BY p.section, per_prod.year ORDER BY p.section, per_prod.year;WITH uv AS (
SELECT year, product_code, country_code,
SUM(export_value) AS v_k,
SUM(export_value)*1000.0/ NULLIF(SUM(export_qty), 0) AS uv
FROM 'data/parquet/country_year_product/**/*.parquet'
WHERE year IN (1996, 2023) AND export_value>0 AND export_qty>0
GROUP BY year, product_code, country_code
), thr AS (
SELECT year, product_code, quantile_cont(uv, 0.75) AS uv_q75
FROM uv GROUP BY year, product_code HAVING COUNT(*) >= 5
), tagged AS (
SELECT uv.year, uv.country_code, uv.v_k,
CASE WHEN uv.uv >= thr.uv_q75 THEN uv.v_k ELSE 0 END AS v_top_k
FROM uv JOIN thr USING (year, product_code)
)
SELECT year, country_code, SUM(v_top_k)/ NULLIF(SUM(v_k), 0) AS share
FROM tagged GROUP BY year, country_code;WITH uv AS (
SELECT year, product_code, country_code,
LN(SUM(export_value)*1000.0/ NULLIF(SUM(export_qty), 0)) AS lnuv
FROM 'data/parquet/country_year_product/**/*.parquet'
WHERE year IN (2010, 2023) AND export_value>0 AND export_qty>0
GROUP BY year, product_code, country_code
), per_prod AS (
SELECT year, product_code, STDDEV_SAMP(lnuv) AS sd
FROM uv GROUP BY year, product_code HAVING COUNT(*) >= 5
), by_sec AS (
SELECT p.section, per_prod.year, AVG(per_prod.sd) AS avg_sd
FROM per_prod JOIN products p ON p.code = per_prod.product_code
WHERE p.section IS NOT NULL GROUP BY p.section, per_prod.year
)
SELECT section,
MAX(CASE WHEN year=2023 THEN avg_sd END)
- MAX(CASE WHEN year=2010 THEN avg_sd END) AS delta
FROM by_sec GROUP BY section ORDER BY delta DESC;WITH uv AS (
SELECT product_code, country_code,
LN(SUM(export_value)*1000.0/ NULLIF(SUM(export_qty), 0)) AS lnuv
FROM 'data/parquet/country_year_product/year=2023/*.parquet'
WHERE export_value>0 AND export_qty>0
GROUP BY product_code, country_code
), gdp AS (
SELECT iso3, LN(value) AS lngdp
FROM 'data/parquet/wdi_data.parquet'
WHERE indicator='NY.GDP.PCAP.CD' AND year=2023 AND value>0
)
SELECT p.section, regr_slope(uv.lnuv, gdp.lngdp) AS slope, COUNT(*) AS n
FROM uv
JOIN 'data/parquet/countries.parquet' c ON c.code = uv.country_code
JOIN gdp ON gdp.iso3 = c.iso3
JOIN products p ON p.code = uv.product_code
WHERE p.section IS NOT NULL
GROUP BY p.section HAVING COUNT(*) >= 100
ORDER BY slope DESC;