Estimating the Spatial Weight Matrix — Interactive Lab

A pedagogical companion to Who Are My Neighbors? Bayesian Estimation of Spatial Weight Matrices in R ↗ Back to the post

Spatial econometrics normally hands you the neighbourhood map before the analysis starts. This lab lets you poke at what happens when you estimate it instead — on 90 European NUTS-1 regions observed annually from 2001 to 2019.

Regions
90
NUTS-1, 26 countries
Observations
1,710
90 × 19 years
Unknown links
8,010
every off-diagonal cell
Per observation
4.7
parameters

Why this is not an ordinary regression

A spatial autoregressive panel needs an n × n matrix W saying who is whose neighbour. Fix it in advance — contiguity, k-nearest neighbours, a distance band — and you have 6 unknowns and 1,710 observations, which is comfortable. Treat every off-diagonal cell as unknown instead and you have 8,016 unknowns against the same 1,710 observations.

A model with 4.7 parameters per observation cannot be estimated by likelihood alone. Everything depends on the prior — which is what tab 2 is about.

The replication

All twelve quantities published in Krisztin & Piribauer (2026), Table 3, reproduce to the five decimal places printed.

Absolute difference between our estimate and the published value, on a log scale. The dashed line is 10−5, the resolution of the printed table.

The prior on the links has two parts: where links can be, and how many there are. The second is where the surprises live.

What your prior actually asserts

Implied prior distribution over the number of neighbours each region has, at n = 90.
Sets b = ((n−1) − k̄) / k̄ in bbinompdf()
That is nr_neighbors_prior = rep(1, n)
b hyperparameter
11.71
Prior P(link)
7.87%

The trap

Writing rep(1, n) feels like imposing nothing. At n = 90 it implies a prior expectation of 44.5 neighbours per region — a belief that every European region is directly wired to half of Europe. With only 19 time periods, that prior would dominate the likelihood rather than be updated by it. Turn the flat curve on above and compare it with an anchor of 7.

Each of the 8,010 possible links has a posterior probability: the share of retained draws in which the model switched it on. Raise the evidence bar and watch which links survive.

What kind of links survive?

Composition of surviving links as the posterior-probability threshold rises. Dashed lines are the base rates across all 8,010 ordered pairs.
Share of the 100 retained draws in which the link was on
Links surviving
of 8,010
Mean distance
baseline 1,331 km
Same country
base rate 7.1%
Share a border
base rate 4.3%

Estimated degree, region by region

Posterior mean number of neighbours with 95% credible intervals, ordered by supranational group. Dashed line: the prior anchor of 7.

The strongest estimated links

The payoff. Fit the identical model three times, changing nothing but the neighbourhood map. Every sign survives; the magnitudes do not.

Direct, indirect and total impacts under each neighbourhood map.

How well does each assumed map predict the estimated one?

Area under the ROC curve, using the posterior link probability as a classifier of each assumed map. 0.5 would be a coin flip.

Sharing a country predicts the estimated network better than sharing a border does. That is the central finding of the exercise — and nothing in the specification mentions countries.