EconStatsCraft rigorous, plain-spoken econometrics
Econometrics that explains itself.
Regression, panel data, time series and the whole battery of tests. Every result is followed by a verdict you can defend.
Load a dataset to see it here.
EconStatsCraft › Gravity model of trade
The workhorse of empirical trade, estimated the way the field actually estimates it: Poisson pseudo-maximum likelihood, which keeps the zero flows and stays consistent when the error variance moves with the regressors. Reports the log-linear regression beside it so you can see what taking logs costs.
Trade between two countries behaves like Newton's law: proportional to the product of their economic masses, inversely proportional to the distance between them. That analogy was noticed in 1962 and dismissed as atheoretical for twenty years, until Anderson and others derived it from proper trade models. The modern estimation problem is not the specification, which is agreed, but the fact that the obvious way to fit it - take logs, run OLS - is wrong twice over.
Any question about what moves trade between places: does a trade agreement raise it, how much does distance still cost in an age of container ships, what would leaving a customs union do. The same model is used for migration flows, foreign direct investment and commuting.
The structural gravity equation is X_{ij}=\frac{Y_iE_j}{Y}\left(\frac{\tau_{ij}}{\Pi_i P_j}\right)^{1-\sigma}, where \tau_{ij} is bilateral trade cost, \sigma the elasticity of substitution, and \Pi_i, P_j the OUTWARD and INWARD multilateral resistance terms - how hard it is for i to sell anywhere and for j to buy from anywhere. Those terms are unobservable and vary by country and year, which is exactly what exporter-time and importer-time fixed effects absorb. Estimation is by PPML: maximise \sum_{ij}\left[y_{ij}\,x_{ij}'\beta-\exp(x_{ij}'\beta)\right], whose first-order condition is \sum_{ij}\left(y_{ij}-e^{x_{ij}'\beta}\right)x_{ij}=0 - a moment condition on the MEAN alone, which is why nothing about the variance or the distribution needs to hold for consistency.
X_{ijt}=\exp\!\big(\beta_0+\beta_1\ln Y_{it}+\beta_2\ln Y_{jt}+\beta_3\ln d_{ij}+\beta_4 \mathrm{RTA}_{ijt}+\eta_{it}+\theta_{jt}+\mu_{ij}\big)\varepsilon_{ijt}
On 13,464 pair-years with the elasticities built in, PPML returns distance -1.05, GDP 0.91 and 0.90, an agreement worth 0.33 - against a truth of -1.00, 0.90, 0.90 and 0.30. The log-linear regression on the same data returns -0.90 and 0.67, missing the size elasticity by a quarter, and it does so having discarded 4,416 rows - a third of the sample - because log(0) has no value. The Park-style test gives lambda = 1.57, between Poisson and Gamma, which is the sense in which the variance was "wrong" for logs all along. Nothing about this depends on the data being simulated; Santos Silva and Tenreyro found the same pattern in real trade flows.
| If you see this | It means | Do this |
|---|---|---|
| PPML and log-OLS far apart | Heteroskedasticity, as theory predicts | Report PPML; the gap is the bias, not noise |
| Distance coefficient vanishes with pair effects | Distance does not vary within a pair | Correct. It has been absorbed, not disproved |
| GDP coefficients vanish with exporter-time effects | GDP varies only by country and year | Same reason; the effects contain it |
| Trade-agreement effect implausibly large | Selection: countries sign with partners they already trade with | Pair effects and lead terms, or treat it as a correlation |
| PPML will not converge | Perfect separation, or a regressor on a wild scale | Drop separated fixed effects; scale the regressors |
| Standard errors tiny on 100,000 rows | Not clustered by pair | The same pair recurs every year and its shocks persist |
Panel regression, for the fixed-effects machinery without the exponential mean. Count models, which share the Poisson likelihood but ask a different question.
Panel regression · Panel cointegration tests · Heterogeneous panel: Mean Group & PMG · Dynamic panel GMM · Panel diagnostics · Panel unit-root tests
Line chart · Area chart · Bar chart · Stacked bar · Scatter plot · Bubble chart · Histogram · Box plot · Pie chart · Heat map · Rebased to 100 · Lorenz curve and Gini
World map · Bivariate map · Flow map · India - state map · India - district map
Descriptive statistics · Summary by group · Two-way table · Classical statistical tests
Multiple regression (OLS) · Logit / Probit · Tobit (censored) · Truncated regression · Multinomial logit · Ordered logit / probit · Quantile regression · Poisson / Negative binomial
Time-varying coefficients (Kalman) · Unit root tests · Correlogram (ACF / PACF) · ARIMA / SARIMA · Rolling-origin cross-validation · Theta method · Unobserved components · STL forecasting · Forecast combination · Markov regime switching · Change frequency (resample) · ARCH / GARCH volatility · Decompose & filter · Spectral analysis · Exponential smoothing · Forecast accuracy
Yield curve (Nelson–Siegel / Svensson) · Dynamic factor model · Dynamic regression (ARIMAX) · Structural VAR · VAR · Granger causality · Cointegration · VECM · ARDL & bounds test
Panel regression · Panel cointegration tests · Heterogeneous panel: Mean Group & PMG · Gravity model of trade · Dynamic panel GMM · Panel diagnostics · Panel unit-root tests
Principal components (PCA) · Factor analysis · Cluster analysis
Conjoint analysis · MaxDiff (best–worst scaling) · TURF - reach of a product line · Price sensitivity (Van Westendorp) · Market basket analysis · Perceptual map · Scale reliability (Cronbach’s alpha) · Key driver analysis
Spatial autocorrelation · Spatial regression · Heckman selection · Instrumental variables (2SLS) · Difference-in-differences · Staggered difference-in-differences · Regression discontinuity · Matching & weighting · Oaxaca–Blinder decomposition
Black–Scholes option pricing · Bond price, duration & convexity · Merton distance to default · EMI / home loan planner · CAPM / beta estimation · Multi-factor model · Portfolio optimization · Value at Risk & Expected Shortfall · Performance & drawdown · Time value of money & NPV/IRR · Equity valuation (DDM, FCF, residual income) · Cost of capital (WACC) · Binomial option pricing · Option strategies (payoff & profit) · Forwards, futures & swaps · Credit risk & Basel capital · Extreme value theory (tail risk)
Life table · Life annuity · Life insurance pricing · Chain ladder reserving · Buhlmann credibility · Survival analysis · Mortality graduation · Aggregate loss model · Ruin probability · Multi-state Markov model · Loss severity fitting
Monte Carlo experiment · F-test, Wald & Chow · Structural breaks & stability
Regression vs machine learning · Ridge / Lasso / Elastic Net · Random forest · Gradient boosting
EconStatsCraft rigorous, plain-spoken econometrics
Regression, panel data, time series and the whole battery of tests. Every result is followed by a verdict you can defend.
Load a dataset to see it here.
Pick the example closest to your question. You get a spreadsheet with the right columns and a few rows showing the expected format - replace the numbers with your own, then paste or upload it back.
Copy the header row from the table above (or from the downloaded template), put your own rows underneath, and paste the whole thing here. It is checked against the layout before anything is imported.
Or click a row in the preview below.
For a units or notes row.
Search every source at once. World Bank indicators need countries and years; everything else loads in one click.
Loading the catalogue…
The engine stays loaded, so this is quick - and it leaves your open tab and panel layout alone.
⌘/Ctrl+Enter runs the current analysis. ⌘/Ctrl+P exports the session as a PDF. Esc closes this.
In the Notebook: Enter starts a new block and
Shift+Enter a new line inside one; Backspace at the start
joins back into the paragraph above; / on an empty line inserts anything.
⌘/Ctrl+B, I, E, H and
M apply bold, italic, code, highlight and maths.
#, ##, -, 1., > and
``` at the start of a line convert it.
Sign in to run unlimited analyses.
Scroll to pan · Esc to close