এই বইটি এখনো বাংলা ভাষায় পাওয়া যায় না। সংস্করণ: English।
University Economics — Year 3 · স্নাতক তৃতীয় বর্ষ
10Gravity and the Trade Data
The models of the last three chapters say why countries trade. This one asks how much, and finds one of the most reliable regularities in economics: trade between two countries rises with the size of both and falls with the distance between them, like the pull between two masses. The chapter derives that gravity equation from the CES demand of Chapter 9, estimates it on the trade of every pair of countries in the world, and uses it to measure what borders, languages, agreements and distance cost. It ends with the long record: trade as a share of output rose, collapsed and rose again.
Across 28,569 pairs, one variable — the product of the two GDPs over the distance — accounts for 62 % of the variation in log trade, and a 1 % rise in it goes with 1.18 % more trade. Few relations in the social sciences fit so well with so little.
You already know
Chapter 2 absorbed unobserved differences with fixed effects, and Chapter 5 estimated by maximum likelihood. CES demand, the iceberg trade cost and the trade elasticity come from Chapter 9 and Chapter 7.
Notation 10.1 (Symbols of this chapter)
is the value of exports from to ; is ’s output, ’s spending and the world’s; is the iceberg trade cost and the trade elasticity. and are the multilateral resistance terms (not profit and not a price level of the whole economy).
10.1 The trade data
How it is measured — What the trade data record
Customs offices record goods as they cross borders: the exporter’s office values them free on board (FOB), at the border, and the importer’s adds the cost of insurance and freight (CIF). Each flow is therefore declared twice, and the two declarations rarely agree. The flows used in this chapter (BACI, distributed with the CEPII Gravity database) reconcile the two into one value, FOB, in thousands of current dollars. They cover goods, not services; a pair with no flow recorded may have traded too little to report.
"""Load one year of bilateral trade (BACI flows in the CEPII Gravity database)."""
from econdata import gravity
COLS = ["year", "iso3_o", "iso3_d", "tradeflow_baci", "gdp_o", "gdp_d", "dist"]
d = gravity(since=2019, until=2019, columns=COLS) # one year only: the file is large
d["flow"] = d.tradeflow_baci / 1e6 # thousands of dollars -> billions
countries = sorted(set(d.iso3_o) | set(d.iso3_d))
possible = len(countries) * (len(countries) - 1) # ordered pairs, no self-trade
print(f"countries {len(countries)}, ordered pairs with positive trade {len(d):,}")
print(f"pairs with no recorded trade: {1 - len(d) / possible:.1%} of {possible:,}")
print(f"total trade {d.flow.sum():,.0f} billion dollars")
top = d.nlargest(5, "flow")[["iso3_o", "iso3_d", "flow", "dist"]]
print(top.to_string(index=False, float_format="{:,.0f}".format))
share = top.flow.sum() / d.flow.sum()
print(f"the 5 largest flows: {share:.1%} of world trade")
$ python load_trade.py
countries 224, ordered pairs with positive trade 31,120
pairs with no recorded trade: 37.7% of 49,952
total trade 18,098 billion dollars
iso3_o iso3_d flow dist
CHN USA 427 11883
MEX USA 355 3359
CAN USA 314 556
CHN HKG 262 1226
USA CAN 259 556
the 5 largest flows: 8.9% of world trade
The file holds only positive flows. Of the 49,952 ordered pairs of the 224 countries, 37.7 % recorded no trade in 2019, and the five largest flows — China and Mexico to the United States, the United States and Canada to each other, China to Hong Kong — made 8.9 % of world trade.
10.2 The gravity equation
Definition 10.2 (Gravity equation; distance elasticity)
A gravity equation relates bilateral trade to the sizes of the two economies and the costs of trading between them: , where are pair characteristics (a shared border, language, colonial link, trade agreement). The distance elasticity is the percentage change in trade for a 1 % increase in distance.
Definition 10.3 (Multilateral resistance)
The multilateral resistance terms and are averages of the trade costs that exporter faces to all its markets and importer faces from all its suppliers. Trade between two countries depends on their bilateral cost relative to these averages.
Proposition 10.4 (Gravity from CES demand)
Let each country make one variety, buyers everywhere have CES preferences with elasticity , and trade costs be iceberg. If every country’s output is sold (), then
Proof. By the CES demand (9.2), with the factory price of ’s variety (a taste weight can be folded into it), spends on it, where . Market clearing gives , with as defined. So . Substituting into gives the first equation, and into the third. ∎
Gravity is thus predicted, with unit elasticities on both GDPs and a distance elasticity equal to times the elasticity of trade costs to distance. It also says what simple gravity forgets: two countries far from everyone else — Australia and New Zealand — face high resistance with all partners, so they trade more with each other than their distance alone predicts.
10.3 Estimating gravity on logs
Taking logs of the definition gives a linear regression. The listing estimates it for 2019.
"""The gravity equation by OLS on logs, 2019."""
import numpy as np
import statsmodels.formula.api as smf
from econdata import gravity
COLS = ["year", "iso3_o", "iso3_d", "tradeflow_baci", "gdp_o", "gdp_d", "dist",
"contig", "col45", "fta_wto"]
d = gravity(since=2019, until=2019, columns=COLS).dropna()
d["ln_x"] = np.log(d.tradeflow_baci) # positive flows only: zeros have no log
d["ln_gdp_o"], d["ln_gdp_d"] = np.log(d.gdp_o), np.log(d.gdp_d)
d["ln_dist"] = np.log(d.dist)
f = "ln_x ~ ln_gdp_o + ln_gdp_d + ln_dist + contig + col45 + fta_wto"
r = smf.ols(f, data=d).fit(cov_type="HC1") # robust standard errors
print(f"pairs {int(r.nobs):,}, R-squared {r.rsquared:.3f}")
for name in r.params.index[1:]:
print(f"{name:10s} {r.params[name]:7.3f} ({r.bse[name]:.3f})")
$ python gravity_ols.py
pairs 28,113, R-squared 0.658
ln_gdp_o 1.306 (0.007)
ln_gdp_d 0.957 (0.007)
ln_dist -1.206 (0.021)
contig 1.259 (0.102)
col45 1.412 (0.111)
fta_wto 1.054 (0.036)
The fit is good (an of 0.66) and the signs are those of every gravity study: trade rises with both GDPs, falls with distance (elasticity ), and is higher between neighbours, former colonies and partners in an agreement. But the regression is the “naive” gravity the proposition warns about: it omits the resistance terms, which are correlated with GDP and distance, and its estimates are biased.
10.4 Multilateral resistance and fixed effects
The resistance terms are hard to compute, but in a cross-section they are exporter and importer constants: . A dummy for each exporter and each importer absorbs them, together with the GDPs — the fixed effects of Chapter 2, applied to the two sides of a flow.
"""Gravity with exporter and importer fixed effects (OLS on logs), 2019."""
import numpy as np
import statsmodels.formula.api as smf
from econdata import gravity
COLS = ["year", "iso3_o", "iso3_d", "tradeflow_baci", "dist", "contig",
"comlang_off", "col45", "fta_wto"]
d = gravity(since=2019, until=2019, columns=COLS).dropna()
d["ln_x"], d["ln_dist"] = np.log(d.tradeflow_baci), np.log(d.dist)
# C(...) adds one dummy per exporter and per importer: they absorb GDPs and
# multilateral resistance, so GDPs are no longer in the equation
f = "ln_x ~ ln_dist + contig + comlang_off + col45 + fta_wto + C(iso3_o) + C(iso3_d)"
r = smf.ols(f, data=d).fit(cov_type="HC1")
print(f"pairs {int(r.nobs):,}, parameters {len(r.params)}")
for name in ["ln_dist", "contig", "comlang_off", "col45", "fta_wto"]:
print(f"{name:12s} {r.params[name]:7.3f} ({r.bse[name]:.3f})")
$ python gravity_fe.py
pairs 30,446, parameters 440
ln_dist -1.515 (0.022)
contig 1.027 (0.113)
comlang_off 0.825 (0.045)
col45 1.223 (0.122)
fta_wto 0.464 (0.039)
With 440 parameters, the distance elasticity becomes : doubling the distance divides trade by . A shared border multiplies trade by , a common official language by , and a trade agreement by .
10.5 Zeros and Poisson pseudo-maximum likelihood
Two problems remain. Zeros have no logarithm, so OLS on logs drops them. And the log of a variable is not the variable: if the gravity equation holds for the mean of trade, , the error is multiplicative, with .
Proposition 10.5 (Logs and heteroskedasticity)
If and is not constant, then ; if the distribution of depends on , so in general does , and OLS of on is inconsistent for .
Proof. The logarithm is strictly concave, so by Jensen’s inequality . Then . When the last term varies with , it is part of the regression function, and OLS estimates plus the slope of that term. For example, if is normal with variance and mean , then : wherever the spread differs, so does the bias. ∎
Definition 10.6 (Poisson pseudo-maximum-likelihood estimator)
The Poisson pseudo-maximum-likelihood (PPML) estimator of in solves — the first-order condition of a Poisson likelihood, used without assuming that is Poisson.
The estimating equation has mean zero whenever the conditional mean is right, whatever the variance, so PPML is consistent under that condition alone; we admit the proof. It keeps the zeros, and it weights flows in levels. Standard errors must be robust, since the Poisson variance is not assumed.
"""Gravity by Poisson pseudo-maximum likelihood with the same fixed effects, 2019."""
import numpy as np
import statsmodels.api as sm
import statsmodels.formula.api as smf
from econdata import gravity
COLS = ["year", "iso3_o", "iso3_d", "tradeflow_baci", "dist", "contig",
"comlang_off", "col45", "fta_wto"]
d = gravity(since=2019, until=2019, columns=COLS).dropna()
d["x"] = d.tradeflow_baci / 1e3 # millions of dollars, in levels: no log
d["ln_dist"] = np.log(d.dist)
f = "x ~ ln_dist + contig + comlang_off + col45 + fta_wto + C(iso3_o) + C(iso3_d)"
r = smf.glm(f, data=d, family=sm.families.Poisson()).fit(cov_type="HC1")
print(f"pairs {int(r.nobs):,}, converged {r.converged}")
for name in ["ln_dist", "contig", "comlang_off", "col45", "fta_wto"]:
print(f"{name:12s} {r.params[name]:7.3f} ({r.bse[name]:.3f})")
$ python gravity_ppml.py
pairs 30,446, converged True
ln_dist -0.648 (0.025)
contig 0.537 (0.071)
comlang_off -0.030 (0.069)
col45 0.569 (0.127)
fta_wto 0.380 (0.053)
In levels the distance elasticity is , the border coefficient 0.54, the agreement 0.38, and a common language no longer matters (its coefficient, , is smaller than its standard error). PPML gives most weight to the large flows, between large and often close economies, and there the costs of distance and of foreign languages appear smaller. The file has no zeros, so the difference here comes from the weighting and the heteroskedasticity alone (Exercise 10.12).
Neither estimate shrinks over a quarter-century of cheaper transport and communication: the OLS elasticity moves from in 1996 to in 2012 and in 2020, the PPML one from to between and . This is the distance puzzle. A survey of 1,467 estimates from 103 papers found that the estimated effect of distance rose around the middle of the twentieth century and has stayed high since. Distance is not only freight: it stands for time, information and trust, which fall less with technology than shipping costs do.
More than a third of all pairs record no trade in every year since 2007 (37.7 % in 2019). Those zeros carry information: they are the pairs too far, too small or too costly to trade, the extensive margin of Chapter 9. OLS on logs throws them away; PPML keeps them when they are in the data.
10.6 Borders, languages, agreements
Thousands of gravity estimates make a literature large enough for its own meta-analysis.
On the record — Gravity’s typical coefficients
Over 2,508 estimates from 159 papers, the median distance elasticity is ( among studies with fixed effects or equivalent methods); the median coefficients are 0.97 and 0.85 on the exporter’s and the importer’s GDP, 0.49 on a shared border and on a common language, 0.91 on a colonial link, 0.47 on a regional trade agreement (0.28 with fixed effects) and 0.87 on a common currency.
The most striking cost is the border itself. A study of 1995 found that, after controlling for size and distance, Canadian provinces traded 22 times as much with each other as with United States states. With multilateral resistance taken into account, the border cuts trade between the two countries by about 44 % — still large, but far below the first estimate, which partly reflected the small size of Canada’s economy.
Definition 10.7 (Tariff-equivalent trade cost)
The tariff-equivalent of a trade cost measured by a gravity coefficient is the ad valorem tariff that would change trade as much. Since trade varies as , a factor that multiplies trade by is equivalent to multiplying by : a tariff of when , a tariff cut of when .
The tariff-equivalent needs the trade elasticity from outside the regression; the median of the estimates identified from tariff changes is 5.03, the value we use. Not sharing a border is then worth a tariff of (with the fixed-effects coefficient), and an agreement, by PPML, a tariff cut of — of the order of the tariffs that agreements remove.
Model — The gravity equation
Assumes. CES demand over countries’ goods, iceberg trade costs, and market clearing.
Predicts. Trade proportional to the product of the GDPs, divided by trade costs relative to multilateral resistance; a distance elasticity around .
Tested. In thousands of estimates (median distance elasticity ), and in this chapter’s own fits on 2019 data, where size and distance alone account for 62 % of the variation in log trade.
Breaks. Zeros; services, which it was not built for; trade costs that change over time; and a distance elasticity that does not fall as transport gets cheaper.
10.7 The container and the two waves
On the record — The first wave of globalisation and its end
Across these economies, trade rose from 17.5 % of GDP in 1870 to 22.8 % in 1913, collapsed in the First World War, and fell to 12.3 % in 1932, in the Depression. It was back at 17.9 % in 1950 and passed its 1913 level only in 1974; it reached 35.0 % in 2008 and 37.9 % in 2019. Globalisation came in two waves, and the first was undone for half a century.
The second wave rode on falling trade costs: tariffs cut in successive rounds of negotiation and agreements, and a new way of shipping.
On the record — The container
Bernhofen, El-Sahli and Kneller used the dates at which countries first adopted container facilities, and the fact that some goods can be containerised and others cannot, to estimate the effect of containers on product-level trade from 1962 to 1990. Among developed countries, the cumulative effect over twenty years was about 700 %, larger than that of tariff liberalisation (working-paper estimate).
10.8 Exercises
Exercise 10.1 ★
In the opening chart, by how much does trade rise, on average, when the product of GDPs over distance doubles? Where do the binned points depart from the line, and what might explain it?
Solution
Solution of Exercise 10.1.
By : the slope is 1.18. At the left end, the binned points lie above the line: the smallest and most distant pairs trade more than the line predicts, partly because only pairs with positive trade are in the data — among small, distant pairs, those that trade at all are the ones with unusually large flows.
Exercise 10.2 ★
Pair A has GDPs of 2,000 and 500 and is 1,000 km apart; pair B has GDPs of 2,000 and 1,000 and is 4,000 km apart. With unit GDP elasticities and a distance elasticity of , which pair trades more, and by what factor?
Solution
Solution of Exercise 10.2.
: pair A trades 1.74 times as much.
Exercise 10.3 ★
With a distance elasticity of , by what percentage does trade change when distance doubles? When it falls by 10 %?
Solution
Solution of Exercise 10.3.
; .
Exercise 10.4 ★
What observation on one pair of countries would contradict gravity? Why is one such pair not enough to reject it?
Solution
Solution of Exercise 10.4.
Two large, close countries with no other obstacle between them that trade far less than gravity predicts — or far more than a pair of the same size and distance. One pair can be explained by its own pair variables (an embargo, a war, a shared language the regression omits); gravity is a statement about the average across pairs, and is rejected only if the average relation fails.
Exercise 10.5 ★★
Add a common official language to the regression of the OLS listing. How do the coefficients on distance and on a colonial link change, and why?
Solution
Solution of Exercise 10.5.
The tested solution is ex05_language.py, in the chapter’s exercises/ folder. Distance moves from to and colonial link from 1.412 to 0.945; the language coefficient is 0.812, so a common language multiplies trade by 2.25.
Former colonies often share their former ruler’s language, so without the language dummy the colonial link picked up part of the language effect; close countries also share languages more often, so distance had absorbed a little of it too.
Exercise 10.6 ★★
Estimate the agreement coefficient with fixed effects by OLS and PPML for 2005 and 2019. Convert each into a percentage effect on trade. Is the gap between the two estimators stable?
Solution
Solution of Exercise 10.6.
The tested solution is ex06_fta.py, in the chapter’s exercises/ folder. 2005: OLS 0.503, trade (+65 %); PPML 0.373, (+45 %). 2019: OLS 0.464, ; PPML 0.380, . PPML gives the smaller effect in both years; the gap narrows from 0.13 to 0.08, but given standard errors of 0.04 to 0.06 the difference between the two years is not clearly significant.
Exercise 10.7 ★★
With , find the tariff-equivalent of not sharing a border, using the fixed-effects coefficient 1.027 and the PPML coefficient 0.537.
Solution
Solution of Exercise 10.7.
Not sharing a border multiplies trade by , equivalent to a tariff : with fixed effects by OLS, by PPML.
Exercise 10.8 ★★
A new port cuts the ad valorem cost of shipping to one partner from 20 % to 10 %. With , by how much does trade with that partner rise, before any change in multilateral resistance? Will the general-equilibrium effect be larger or smaller, and what happens to trade with other partners?
Solution
Solution of Exercise 10.8.
Trade varies as : , a rise of 54.5 %. With multilateral resistance the effect on this pair is smaller, since the country’s resistance falls as one of its costs falls; trade with other partners falls, because the partner with the new port is now relatively cheaper (diversion).
Exercise 10.9 ★★
Why does OLS on logs drop zero flows? If zeros are most common between small and distant countries, in which direction does dropping them bias the distance elasticity?
Solution
Solution of Exercise 10.9.
The log of zero is not defined, so the rows drop out. The pairs that survive at long distances are those with unusually large shocks; the regression sees large flows where the truth has many zeros, so distance seems to cost less than it does: the elasticity is biased toward zero.
Exercise 10.10 ★★★
Estimate the distance elasticity with fixed effects by OLS every fourth year from 1996 to 2020, and test for a linear trend. Is the elasticity falling?
Solution
Solution of Exercise 10.10.
The tested solution is ex10_distance_puzzle.py, in the chapter’s exercises/ folder. The elasticities are , , , , , and ; the trend is per decade (s.e. 0.026), .
If anything, distance mattered slightly more over the period, though the trend is not significant at 5 % (and seven estimates from overlapping data are a thin basis for a test). The elasticity is not falling: the puzzle.
Exercise 10.11 ★★★
Two countries of equal size each make one variety; and . Use Proposition 10.4 to find and each country’s share of spending on imports. How does the import share depend on and ?
Solution
Solution of Exercise 10.11.
By symmetry , and , so . Then : imports relative to home purchases are . The import share of spending is ; it falls with and falls faster the larger , from at toward 0.
Exercise 10.12 ★★★
Simulate with uniform on , normal with variance and mean . Compare the slope estimated by OLS on with the PPML slope over 200 samples of 2,000. Explain the OLS result with Proposition 10.5.
10.9 Problem: Brenland Joins a Customs Union
Problem 10.1
Weekend problem — Brenland joins a customs union
An invented world has twenty countries: Brenland, Kestria and eighteen others, N01 to N18. Brenland and four neighbours form a customs union. Trade follows the structural gravity of Proposition 10.4, observed with noise that is larger for small flows, and flows below 0.05 billion dalens go unrecorded. Of the 380 ordered pairs, 20 are pairs of members and 6 record no trade.
The union’s members and the two largest non-members, with their GDP (billions of dalens) and distance from Brenland (thousands of km):
Brenland’s GDP is 120. Three regressions of exports on log distance and a dummy for pairs of members, the first also on log GDPs (standard errors in parentheses):
With the PPML coefficients, the model gives Brenland’s trade (exports plus imports, billions of dalens) without and with the union:
Part I — gravity by OLS.
- How many pairs does each regression use, and why does OLS use fewer?
- By the OLS estimate, by how much does trade fall when distance doubles?
- Using the OLS coefficients, by what factor should Brenland’s exports to Kestria exceed its exports to N10, setting the union aside?
- By what percentage does membership raise trade between two members, according to OLS?
- The GDP coefficients are well below 1. Which part of the structural equation does this regression omit, and why does that bias it?
- Compare the OLS distance coefficient with the median of published estimates.
Part II — multilateral resistance and fixed effects.
- Why do the exporter and importer dummies make the GDPs unnecessary?
- How many dummies are needed, with a constant?
- In this world the true distance elasticity is and the true union coefficient 0.5. Is the fixed-effects distance estimate within two standard errors of the truth?
- Give a 95 % confidence interval for the union coefficient by OLS with fixed effects.
- N12 is large and very close to Brenland. How does that affect Brenland’s multilateral resistance and its trade with N10?
- Why would two remote countries in this world trade more with each other than their distance predicts?
Part III — PPML.
- Why can PPML use all 380 pairs?
- Give the PPML union coefficient’s 95 % interval, and the percentage effect on trade between two members that it implies.
- The noise is larger for small flows. Use Proposition 10.5 to explain why OLS on logs and PPML disagree.
- Which estimator came closest to the true distance elasticity, and to the true union coefficient?
- With , find the tariff cut equivalent to the union by PPML.
- In this world, crossing a border divides the cost term by . Find the tariff-equivalent of the border.
Part IV — trade creation and diversion.
- Brenland’s trade with members rises by less than the PPML partial effect. Why?
- What happens to Brenland’s trade with non-members? Name the effect.
- Why do Brenland’s sales at home fall?
- By what percentage does Brenland’s total trade change?
- Can gravity alone say whether Brenland gains from the union? What else would you need?
- Would the union’s effect on Brenland be larger if its members were far away? Explain.
- State the result: the union’s effect on Brenland’s trade with members and with non-members, in percent.
Solution
Solution of Problem 10.1.
1. OLS 374, PPML 380. OLS on logs drops the 6 pairs with no recorded trade.
2. .
3. : Brenland should export to Kestria about two thirds of what it exports to N10.
4. .
5. It omits the multilateral resistance terms. Large economies have many nearby partners and low resistance, which lowers their bilateral trade with any one partner relative to their size: the omitted term is correlated with GDP, and its effect loads onto the GDP coefficients.
6. against a median of in the published estimates: remarkably close.
7. An exporter dummy absorbs everything specific to the exporter — its GDP and its resistance term — and an importer dummy the same for the importer.
8. 19 for exporters and 19 for importers: 38 with a constant.
9. standard errors: yes.
10. : from 0.41 to 1.09. It contains the true 0.5.
11. With a large partner close by, Brenland’s resistance is low: its alternatives are good. Relative to that, N10 is far away, and Brenland trades less with it than with a remote country’s equally distant partner.
12. A remote country has high resistance: all its alternatives are costly, so a given bilateral cost is low relative to them, and two remote countries trade more with each other than distance alone predicts.
13. PPML works with flows in levels, and a zero is a valid value of a non-negative variable whose conditional mean is modelled.
14. : from 0.05 to 0.71. Partial effect .
15. When the variance of the error falls with the size of the flow, is more negative for small flows; small flows are the distant and non-member pairs, so the log regression confounds the noise with distance and with membership.
16. Distance: OLS with fixed effects (), then PPML (); the union: PPML (0.382, against 0.750 with fixed effects by OLS and 0.574 by OLS); both PPML errors are well within their standard errors.
17. .
18. .
19. The union lowers the members’ multilateral resistance: with cheaper access to each other, each member’s average trade cost falls, which offsets part of the fall in their bilateral cost. Trade with members rises by 27.0 %, not 46.5 %.
20. It falls by 10.5 %: trade diversion, purchases switched from non-members to members because members’ goods became relatively cheaper.
21. Members’ goods compete with Brenland’s own at home; with Brenland’s output fixed and more of it exported, home sales fall, by 20.2 %.
22. From to : .
23. No: gravity measures flows, not welfare. One needs the prices paid: whether Brenland now buys from members goods that non-members supplied more cheaply before (and loses the tariff revenue it collected on them), against the gain from cheaper goods from members — a model of welfare such as the gains formula of Chapter 7.
24. In percent of trade with members, slightly larger: distant members would be a small share of Brenland’s trade, so its resistance would fall less, and the rise would be closer to the 46.5 % partial effect. But the union would act on small flows, so the rise in Brenland’s total trade, and the diversion away from non-members, would be smaller.
25. The union raises Brenland’s trade with its members by 27.0 % and lowers its trade with non-members by 10.5 %.