Spatial Dynamic Panels with Common Factors — Interactive Lab

A pedagogical companion to Spatial Dynamic Panels with Common Factors in Stata: Credit Risk in US Banking ↗ Back to the post

Why do common factors matter for spatial panel estimation?

The 2007-2009 Global Financial Crisis hit every US bank's non-performing loan (NPL) ratio simultaneously. Two distinct mechanisms were at work: spatial spillovers from balance-sheet interdependencies among interconnected banks, and common factors from macroeconomic shocks (Fed funds rate, housing collapse, unemployment) that hit all banks at once but with bank-specific intensity. Ignoring either channel produces biased estimates and misleading policy advice.

This app lets you turn the dials yourself. Across four tabs you will: visualise how a global shock and a local-contagion shock look identical on a single chart but require different fixes; simulate a spatial dynamic panel with and without common factors so you can see Nickell-style bias plus factor-omission bias in a single bar chart; explore the post's four model variants side-by-side; and trace how a short-run coefficient of 2.45 amplifies to a long-run total effect of 7.77 through temporal persistence and spatial contagion.

The factor-omission intuition (animation)

Two estimators of the spatial parameter ψ are tracked as the share of variance coming from common factors grows from 0 to 50%. The orange curve is spxtivdfreg with factmax(0) — it ignores factors. The teal curve is the full spxtivdfreg with defactoring. When factors are absent (left), the two curves agree. When factors contribute even modest variance (right), the no-factor estimator is biased.

Tab 2

Defactored-IV Simulator

Set spatial ψ, temporal ρ, and factor strength. Draw a fresh spatial dynamic panel. Watch the no-factor estimator drift away from the truth while the defactored estimator stays close.

Tab 3

Model Comparison

Every coefficient from the post's four model variants — full, no-factors, no-spatial-lag, heterogeneous (MG) — with 95% CIs. Toggle which coefficient and which variant to see; hover for SE and the Hansen J p-value.

Tab 4

Long-Run Multipliers

The post's central economic finding: a short-run LIQUIDITY coefficient of 2.45 has a long-run total effect of 7.77, of which 4.22 is indirect spillover through the bank network. Slide the multipliers ψ and ρ yourself.

Glossary (open a card if a term is unfamiliar)

Spatial autoregressive parameter ψ
Strength of cross-unit spillovers. A bank's NPL today depends on its neighbours' NPL today via a weighted average W·NPL; ψ is the coefficient on that average. The post estimates ψ = 0.394 in the full model.
Temporal autoregressive parameter ρ
Persistence of the outcome. About 29% of last quarter's NPL carries to this quarter. Without common factors in the model, ρ inflates to 0.59 — the temporal lag soaks up macro persistence.
Common factors λᵢ'fₜ
Latent macro shocks that affect every unit but with unit-specific intensities. Pesaran (2006). The post extracts 2 factors in the regressors and 1 in the errors; together they explain 33.5% of the residual variance.
Defactored IV estimation
Two steps: (1) extract latent common factors from the data and remove them; (2) run IV on the defactored data. Removes the cross-sectional dependence created by factors before the IV step so standard 2SLS asymptotics hold.
Spatial weight matrix W
A 350×350 matrix encoding which banks count as neighbours of which. In this post, W is built from Spearman correlations of debt ratios — economic distance, not geographic distance. Row-standardised so each row sums to 1.
Hansen J test
Joint test of instrument validity. χ² under the null that all instruments are orthogonal to the error. Full model: J = 18.83, p = 0.47 (pass). No-factor model: J = 48.15, p < 0.001 (reject).
Short-run vs long-run effects
SR coefficient β is the immediate impact. LR total effect is β / [(1−ρ)(1−ψ)] — amplified by the temporal multiplier 1/(1−ρ) and the spatial multiplier 1/(1−ψ). For LIQUIDITY: 2.45 short-run → 7.77 long-run.
Mean-group (MG) estimator
Heterogeneous slopes: estimate one regression per bank, then average. Drives ψ to 0.03 (n.s.) — suggesting the strong pooled spatial parameter may partly reflect cross-bank slope heterogeneity rather than genuine contagion.

Defactored-IV Simulator — what happens when you omit factors?

The data-generating process is a stylised spatial dynamic panel: y[i,t] = ρ y[i,t-1] + ψ (W·y)[i,t] + β x[i,t] + λᵢ fₜ + εᵢₜ. Slide the true spatial parameter ψ, the temporal persistence ρ, the sample (N, T), and the share of variance from common factors. Each refit draws a fresh panel, then estimates two ways: defactored IV (teal) which removes the factors before estimating, and no-factor IV (orange) which ignores them. Watch how the no-factor ψ̂ drifts away from the truth as factor strength grows.

Strength of cross-bank spillovers. The post estimates ψ ≈ 0.39 in the full model.
Outcome persistence. The post estimates ρ ≈ 0.29.
Cross-sectional units. The post has N = 350; capped here for browser speed.
The post has T = 36 quarters.
Standard deviation of the latent common factor. At 0 there are no factors; at 0.6 they explain about a third of the variance — close to the post's ρ_factor = 0.335.
true ψ
0.40
target
ψ̂ defactored IV
removes factors first
ψ̂ no-factor IV
ignores factors
true ρ
0.30
target
ρ̂ defactored IV
ρ̂ no-factor IV
soaks up factor persistence

What to look for

  • Set σ_f to 0. Both estimators agree — there is nothing to defactor. This is the textbook case.
  • Slide σ_f upward. The orange (no-factor) ψ̂ drifts down while the orange ρ̂ drifts up. The temporal lag absorbs the factor persistence, exactly as in §5 of the post (ρ doubles from 0.29 to 0.59 when factors are omitted).
  • Increase N and T. The defactored IV estimator's gap to the truth shrinks (consistency); the no-factor estimator's bias does not — adding data does not fix omitted-variable bias.
  • Click "Reseed". Each redraw gives slightly different numbers but the systematic pattern persists: the orange estimator is biased whenever factors are present.
  • Bottom line. When the J-test rejects without factors (p < 0.001 in the post), it is telling you that the orange bars are not consistent — the instruments are invalid in the misspecified model.

Run 100 simulations to see the bias systematically

Single runs are noisy. Run the whole pipeline 100 times with fresh draws (same parameters, different ε and f) to see whether the no-factor bias is systematic.

The post's model comparison — interactively

These numbers come straight from the production Stata run captured in analysis.log. Toggle coefficient rows and model variants to compare. Hover a point to see its standard error, 95% CI, and the Hansen J p-value for that specification.

What to look for

  • The headline row is ρ (L1.NPL). Full model 0.29, no-factor model 0.59 — a doubling. The no-factor temporal lag absorbs the persistence that belongs to the common factors. This is the §5 finding made visible.
  • LIQUIDITY collapses by 66% in the no-factor model. 2.45 → 0.84. Banks with high loan-to-deposit ratios were disproportionately hit by aggregate liquidity stress during the GFC; without factors to absorb that aggregate movement, the LIQUIDITY coefficient is biased downward.
  • ψ (W*NPL) drops from 0.394 to 0.288 when factors are omitted. Counter-intuitive — one might expect ψ to inflate (factors create cross-sectional dependence that could look like spatial spillovers). But the inflated ρ absorbs some of the spatial dynamics, compressing ψ.
  • The heterogeneous (MG) column drives ψ to 0.032 (n.s.). When each bank is allowed its own slopes, the average spatial lag effect shrinks to near zero. The strong pooled ψ may partly reflect slope heterogeneity, not contagion.
  • SIZE flips significance. In the full model SIZE = 0.223 (p < 0.05). In the no-factor model SIZE = 0.089 (n.s.). Larger banks are more exposed to macro shocks; without factors, this exposure is masked.

Coefficient rows

Model variants

Hansen J p-values across model variants

Bars above the dashed 0.05 line are consistent with valid instruments. The no-factor model fails (p < 0.001), confirming that common factors are essential for this dataset.

Why does omitting factors invalidate the instruments?

The IV strategy uses INTEREST and lagged exogenous regressors as instruments for INEFF. The exclusion restriction requires that these instruments are uncorrelated with the residual ε. But if common factors enter the residual and the regressors (as Pesaran (2006) shows they must in a typical macro panel), then any instrument that loads on the same factors is no longer exogenous. Defactoring removes the factors from both sides before the IV step, restoring exclusion. The Hansen J test is precisely the statistical fingerprint of this failure: J p < 0.001 in the no-factor model, J p = 0.47 once factors are removed.

Long-Run Multipliers — from 2.45 to 7.77 in two steps

In a spatial dynamic panel, the coefficient on a variable does not measure its total effect. A permanent shock propagates over time (through ρ) and across banks (through ψ), so the long-run total effect equals β / [(1−ρ)(1−ψ)]. With ρ = 0.29 and ψ = 0.39, the temporal multiplier is 1.41 and the spatial multiplier is 1.65 — a combined amplification of about 3.16. Drag the sliders below to see how the post's headline LIQUIDITY effect of 2.45 grows from short-run to long-run, and how each multiplier contributes.

Spatial multiplier = 1/(1−ψ). The post's full-model estimate is 0.394.
Temporal multiplier = 1/(1−ρ). The post's full-model estimate is 0.290.
The contemporaneous coefficient. The post reports β = 2.452 for LIQUIDITY in the full model.
Temporal multiplier
1.41
1/(1−ρ)
Spatial multiplier
1.64
1/(1−ψ)
LR direct = β · 1/(1−ρ)
3.45
own-bank effect compounded over time
LR total = β / [(1−ρ)(1−ψ)]
5.66
amplified by network

Long-run effects for every covariate (from the post)

Each bar is the LR total effect β / [(1−ρ)(1−ψ)] with the post's full-model multipliers. Spillover indirect effects are typically larger than direct effects.

What to look for

  • Slide β to 2.45. The LR total effect reads about 5.66 with default ψ = 0.39 and ρ = 0.29. The post reports 7.765 because the “total” in the post combines direct (3.547) and indirect (4.218) where indirect is from the full spatial multiplier (I − ψW)⁻¹, not just 1/(1−ψ). The slider here uses the simpler analytical approximation; the bar chart below shows the post's exact estat impact, lr numbers.
  • Drag ρ toward 0.6. This is the value the no-factor model produces. The temporal multiplier jumps from 1.41 to 2.50, more than doubling the LR direct effect. This is why "omitting factors inflates ρ" is not a harmless technicality — it cascades into large policy implications.
  • Drag ψ toward 0.7. The spatial multiplier explodes. In a dense network with strong contagion, even a small short-run shock has system-wide consequences. The Cui-Norkutė-Sarafidis-Yamagata estimator is consistent for ψ in this regime; OLS-on-the-spatial-lag is not.
  • The covariate bar chart. LIQUIDITY dominates at 7.765 (total LR). BUFFER is negative at −0.173, showing that capital-adequacy regulation has a protective system-wide spillover, not just an own-bank effect. This is the macroprudential policy argument from §10.

Connecting back to Tab 2

The temporal-multiplier and spatial-multiplier sliders you just played with depend on consistent estimates of ρ and ψ. The defactored-IV simulator in Tab 2 showed that omitting common factors biases ψ down (0.39 → 0.29) and ρ up (0.29 → 0.59). Feeding those biased estimates into the long-run formula does not just shift the result — it changes the qualitative story. A policy that looks modestly effective at ρ = 0.59, ψ = 0.29 becomes much more impactful at the true ρ = 0.29, ψ = 0.39 because the spatial multiplier is larger and the persistence is smaller (faster equilibration).