Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Independent fits, fast — a Laplace approximation

The same no-pooling GEV as notebook 04, fit in seconds instead of minutes

Abstract

Notebook 04 fit every station independently with NUTS — honest, but on the full century-long Iberian record (107 stations, ragged) a single fit takes minutes, and it needed careful reparameterising just to stop the sampler diverging. Here we fit the same no-pooling model with a Laplace approximation: optimise to the posterior mode and read the covariance off the curvature there. It returns in seconds, and lands on the same maps and the same signal-to-noise verdict — location μ(s) is real geography, the tail ξ(s) is mostly noise. Laplace is the workhorse we lean on for the heavier pooled and spatial models that follow; this notebook calibrates it against the NUTS baseline of notebook 04.

Keywords:Laplace approximationno poolingGEVmasked likelihoodreturn levels

Independent fits, fast: a Laplace approximation

Notebook 04 established the no-pooling baseline — one GEV per station, fit jointly with NUTS — and its verdict: the location μ(s)\mu(s) is smooth and real, while the scale and especially the tail ξ(s)\xi(s) are dominated by sampling noise. It also cost a few minutes per fit on the full record and needed a careful log⁡σ\log\sigma / bounded-ξ\xi reparameterisation to keep the sampler off the GEV’s support edge.

For everything from here on we switch the workhorse inference to a Laplace approximation: find the posterior mode (the MAP) by optimisation, then approximate the posterior by the Gaussian whose covariance is the inverse Hessian at that mode. One optimisation, a few seconds, and — when the posterior is roughly Gaussian — an answer that matches full MCMC. This notebook fits the exact same no-pooling model that way and checks it lands where notebook 04’s NUTS run did.

The model is unchanged: per-station μs\mu_s, log⁡σs\log\sigma_s and ξs=12tanh⁡ξ~s\xi_s = \tfrac12\tanh\tilde\xi_s, with the likelihood masked over the ragged records (each station is seen in a different subset of the 1897–2025 years).

source: REAL | stations 107 | years 1897-2025 (125)
coverage: 23-120 yrs/station, 49% of the 107×125 grid observed

The model and the Laplace fit

Same no-pooling model as notebook 04 — fixed per-station priors, no parameter shared across stations — with the stabilising log⁡σ\log\sigma / bounded-ξ\xi reparameterisation and a masked likelihood that sums log⁡p(ys,t)\log p(y_{s,t}) only over observed station-years (gaps filled with an in-support value and zeroed out via numpyro.factor).

AutoLaplaceApproximation optimises this to its MAP and reads the Gaussian posterior off the curvature. We drive it with Adam (guarding the occasional out-of-support GEV gradient); the ELBO loss should settle onto a flat plateau — the sign it has found the mode.

Laplace fit 107 stations in 2.9s (NUTS in notebook 04 took several minutes)
<Figure size 600x320 with 1 Axes>

Read off the posterior

Draw from the Laplace Gaussian with guide.sample_posterior, then push the draws through Predictive to get posterior samples of μ,σ,ξ\mu, \sigma, \xi per station.

μ  median range: 21.3 -> 42.3 °C
σ  median range: 0.88 -> 4.31 °C
ξ  median range: -0.42 -> 0.22

The maps

Posterior-median μ\mu, σ\sigma, ξ\xi — location on a temperature scale, scale on viridis, shape on plasma. As in notebook 04, μ\mu reads as a map and ξ\xi reads as static.

<Figure size 620x520 with 2 Axes>
<Figure size 620x520 with 2 Axes>
<Figure size 620x520 with 2 Axes>

The same signal-to-noise verdict

The diagnostic from notebook 04: for each parameter, the spread of the point estimates across stations (signal) over the typical within-station 95% credible-interval width (noise). Above 1, the map is real; below 1, it is mostly sampling noise. Laplace should reproduce notebook 04’s ordering — μ\mu well above the floor, ξ\xi well below.

μ:  signal SD(med)= 3.403   noise mean-CI-width= 1.011   ratio= 3.36
σ:  signal SD(med)= 0.455   noise mean-CI-width= 0.670   ratio= 0.68
ξ:  signal SD(med)= 0.096   noise mean-CI-width= 0.306   ratio= 0.31
<Figure size 540x360 with 1 Axes>

Return levels

The 100-year level at every station, with its 95% credible band — the planner-facing summary, now in seconds.

z100 median range: 24.6 -> 47.3 °C
z100 95% CI width: 3.4 °C avg (up to 14.2)
<Figure size 620x520 with 2 Axes>
<Figure size 620x520 with 2 Axes>

Takeaway

Same model, same data, same conclusion as notebook 04 — μ\mu is real geography, ξ\xi is noise — but in seconds rather than minutes, and with no divergences to wrestle (Laplace optimises; it does not sample). That speed is what makes the pooled and spatial models in the rest of the curriculum practical on the full century-long record.

The one caveat, as always with Laplace: a Gaussian at the mode can mis-state interval widths when the true posterior is skewed — most acutely for the tail. Where the calibrated uncertainty is the deliverable, it is worth a confirmatory NUTS run (as in notebook 04, and the spatial notebooks’ Laplace-vs-NUTS checks). For mapping and model-building, Laplace is the right default.