MGWR — Interactive Lab

A pedagogical companion to Multiscale Geographically Weighted Regression: Spatially Varying Economic Convergence in Indonesia ↗ Back to the post

Why MGWR? Why allow each variable its own bandwidth?

A single regression line for all 514 Indonesian districts says poorer regions catch up at rate β = −0.195. But what if that average hides huge geographic variation — strong catching-up in Sumatra, none at all in Papua, divergence in a handful of mining districts? Multiscale Geographically Weighted Regression (MGWR) fits one regression at every location, with each variable allowed to operate at its own spatial scale.

This app lets you turn the dials yourself. In four tabs you will: watch a smoothing parameter sweep from "very local" to "essentially global" and see the bias-variance trade-off in real time; see how spatial heterogeneity in the data-generating process turns one global coefficient into a whole map of local ones; and explore the headline contrast between Global OLS (R² = 0.21) and MGWR (R² = 0.76) from the Indonesia analysis.

Hard vs soft selection — and why bandwidth is the analogue of a penalty knob

The animation below shows two ways of "borrowing strength" from data: a hard threshold (orange — coefficient goes to zero abruptly, like LASSO selection) and a soft shrinkage (steel blue — coefficient decays smoothly, like a Gaussian kernel). The same idea sits inside GWR: a tight bandwidth keeps very few neighbours (local, noisy); a wide bandwidth keeps many (smooth, but it averages out the heterogeneity MGWR exists to find).

Tab 2

Bandwidth Lab

Sweep a kernel-bandwidth analogue and watch how many "neighbours" each local model uses. Smaller bandwidth = noisier, more local; larger = smoother, more global.

Tab 3

Global vs Local

Same data, two estimators. The asymmetry slider turns spatial heterogeneity on and off. Run 100 simulations to see when a single coefficient is misleading.

Tab 4

Forest Plot

The Indonesia headline numbers from §6–§8 of the post — Global OLS vs MGWR on three diagnostics (β, R², AICc). Hover for SE, CI, and effective parameters.

Glossary (open a card if a term is unfamiliar)

Local regression β̂(s)
One regression per location s, weighted by spatial proximity. Coefficients become functions of geographic position. In the post: the slope on ln_gdppc2010 varies from −1.74 to +0.42 across 514 districts.
Bandwidth h
The number of nearest neighbours each local regression uses. The post selects h = 44 districts (about 8.6% of the sample) for both regressors.
Adaptive bisquare kernel
The weighting scheme: include the nearest h districts, weight them by a bisquare function of distance, ignore the rest. "Adaptive" means h is a count not a fixed radius — handy when district sizes vary.
GWR vs MGWR
GWR uses one bandwidth for all coefficients. MGWR allows each coefficient its own bandwidth. The methodological advance: different processes can operate at different spatial scales.
Spatial heterogeneity
βi ≠ βj. The relationship between predictors and outcome is not constant geographically. The reason a single regression misleads in 365 of 514 districts.
Effective number of parameters
Trace of the hat matrix. The post's MGWR uses 52 — far more than OLS's 2 but far less than 514×2 = 1028 (one regression per district).
AICc
Corrected Akaike Information Criterion — lower is better. Global OLS: 1341.25 · MGWR: 838.41. A difference of 500+ strongly favours MGWR.
β-convergence
The classic growth test: poor regions catching up with rich ones gives a negative coefficient on initial income. The Indonesia global β = −0.195 hides that only 29% of districts show this catching-up.

Bandwidth Lab — turn the kernel knob yourself

A penalty parameter in LASSO does the same job that a bandwidth parameter does in MGWR: it controls how much information is borrowed across observations. In a stylised model with one "treatment-like" variable and many control-like covariates, the slider sweeps a smoothing knob from "very local" (left, few neighbours, noisy) to "very global" (right, many neighbours, all coefficients shrink toward zero). Watch the orange treatment coefficient: that is the spatially varying β we care about in MGWR.

Larger n is more like Indonesia's 514 districts — each local estimate is steadier.
About 15% of these covariates have a true nonzero effect; the rest are noise.
Magnitude of true coefficients relative to noise — analogue of how strongly initial income predicts growth.
Left = highly local (few neighbours kept); right = highly global (all averaged together).
covariates kept
analogue of effective parameters (post: 52)
β̂ (shrunk)
"global-style" smoothed estimate
β̂ (refit on support)
"local-style" unshrunk estimate
true β
0.50
held fixed for comparison

What to look for

  • Small bandwidth = many "effective parameters". Slide left: more coefficients are kept, each estimated from a narrow window. That is what MGWR's bandwidth-of-44 looks like in spirit: a model that respects local structure.
  • Large bandwidth = a single, smooth, global story. Slide right: most coefficients shrink to zero. You recover something like the global OLS regression — one line for the whole country.
  • The treatment-like coefficient (orange) is what MGWR maps. In Indonesia, it ranges from −1.74 (strong local catching-up) to +0.42 (local divergence) — even though the global average is just −0.195.

Global vs Local — when one number misleads

Same simulated dataset. Two estimators of the convergence-like coefficient β: a Global-style estimator (one coefficient for the whole sample, the analogue of Indonesia's β = −0.195) and a Local-style estimator (each region gets its own coefficient, the analogue of MGWR's location-specific β). The asymmetry slider turns spatial heterogeneity on and off: at 0, the truth is the same everywhere and global is fine; at 1, the truth varies enormously and only the local estimator recovers it.

Capped at 300 so the "Run 100 sims" button finishes quickly.
Capped at 50 for the 100-sim run.
Common scale for both nuisance and treatment-like coefficients.
0 = β is constant in space (global is fine) · 1 = β varies sharply across regions (only MGWR-style local estimators work).

Local (MGWR-style)

Allows β to vary across regions — analogue of MGWR's location-specific β̂(s).

β̂
SE(β̂)
|I_y|
|I_d|
union
λ_y, λ_d

Global (OLS-style)

A single coefficient for the whole sample — analogue of Indonesia's β = −0.195.

β̂
SE(β̂)
|I_y|
|I_d|
union
λ_y, λ_d

Why does this happen?

  • Global averages out heterogeneity. If β is +1 in some regions and −1 in others, the global estimator returns ≈ 0 — and may declare "no effect" when in fact there are two strong, opposite effects.
  • Local estimators recover the variation at the cost of more parameters. In Indonesia, MGWR uses 52 effective parameters vs OLS's 2 — but R² jumps from 0.21 to 0.76 because the gain in fit dwarfs the parameter cost.
  • When the asymmetry slider is near 0, global is fine. If reality is genuinely homogeneous (β is the same everywhere), the simpler model is the right one. MGWR pays off precisely when the world is heterogeneous — and the Indonesia AICc drop from 1341 to 838 is the diagnostic that says it does.

Bias vs variance over many simulations

Single runs are noisy. Run the whole pipeline 100 times with fresh draws (same parameters, different errors) to see whether the global estimator is systematically biased when β varies in space.

Indonesia headline numbers — Global OLS vs MGWR

These numbers come straight from §6–§8 of the post — the same diagnostics used to declare MGWR a clear winner. Toggle outcomes (β, R², AICc) and methods (Global OLS, MGWR) to compare. Hover a point to see its standard error, 95% CI, and the effective bandwidth or sample-size analogue.

What to look for

  • The convergence coefficient β collapses from −0.195 (global) to a median of −0.085 (MGWR) with a range from −1.74 to +0.42. The CI on the MGWR row in the forest plot reflects the full district-level spread, not a sampling-error band.
  • R² triples: 0.21 → 0.76. This is the single most striking number in the post and the main reason MGWR is preferred for Indonesia's archipelago.
  • AICc drops by 503 points: 1341 → 838. AICc penalises complexity, so the win is not free-flexibility-only — MGWR's gain in fit dwarfs the cost of estimating 52 effective parameters.

Outcomes

Methods

Why MGWR's "CI" looks different from OLS's

For Global OLS, the CI on the slope is a standard β̂ ± 1.96 · SE band: a sampling-error statement about uncertainty in the single coefficient. For MGWR, the "CI" shown here is the empirical range of the 514 local coefficients — what economists sometimes call the cross-sectional dispersion of the location-specific β̂(s). The two intervals answer different questions: the first says "how precisely we estimate the global average", the second says "how much the relationship actually varies in space".

Connecting back to Tab 3

The Global-vs-Local contrast you just simulated on Tab 3 maps directly to the Indonesia panel:

  • Convergence β: Global says −0.195; MGWR's local median is −0.085 with a range from −1.74 to +0.42.
  • R²: Global 0.21; MGWR 0.76 — a 3.5× improvement.
  • AICc: Global 1341.25; MGWR 838.41 — a 503-point drop confirming the gain is genuine, not free flexibility.

The takeaway from the post (§7–§10) is therefore visible twice: once on a controlled simulation where you set the truth (Tab 3), and once on the actual 514-district Indonesia panel (this tab).