Personal project · open data · England, Wales & Scotland

The Price of Place — how it works

A territorial car-insurance pricing model covering all 41,729 census small areas of Great Britain, built entirely from open data, calibrated against published price indices, and shipped as an interactive premium map. Every estimate decomposes into exact £ steps, ships with an honest uncertainty band, and traces to a cited source.

41,729LSOAs / Data Zones priced (32,844 England · 1,909 Wales · 6,976 Scotland)
R² 0.930panel fit on 106 matched anchor observations (30 areas, up to 11 quarters)
£76.51leave-one-area-out MAE — strict spatial holdout
£69.76temporal back-test MAE (train ≤T, predict T+1)
0.974Spearman rank agreement, predicted vs actual
£186–£1,578modelled annual-premium span across GB

The question

Why does the same car cost several times more to insure in one postcode than another?

Insurers price location aggressively but publish nothing about how. This model reverse-engineers the territorial effect from the outside: it takes the open data an insurer's territory model plausibly summarises — vehicle crime, area deprivation, traffic intensity, who lives there — and regresses it against the only ground truth that exists publicly: published premium indices (WTW/Confused.com quarterly index, MoneySuperMarket regional figures), transcribed into a 137-row anchor panel under a strict no-invented-figures rule — every £ figure traces to an explicitly published, cited source.

A deliberate design choice follows from that: the model predicts a relative territorial index — each area's premium as a multiple of the national average — not absolute £ directly. Modelling the ratio strips out the national price level and its drift over time, isolating the thing the project is actually about: the effect of place. Absolute £ is reconstructed at the end by pinning to the latest published national average (£558.55).

The model

One regression, aggressively audited

The core is a deliberately small model — ordinary least squares on the log relative index, with area-clustered standard errors — because the calibration sample is honest but small (106 observations across 30 areas). The sophistication is spent on auditing it rather than growing it:

log(premium ÷ national avg) = β₀ + β·place[vehicle_crime, imd_crime, aadf_intensity] + β·composition[young_driver_share, cars_per_household]

Every feature enters as a rank percentile (0–100), ranked within comparable groups (within nation, or England+Wales vs Scotland for crime, whose recording definitions differ). Percentiles bound extrapolation — no outlier area can blow the prediction up — and make three nations' incompatible source scales comparable by construction.

Features earn their place through an evidence gate

Nothing is in the premium model by intuition. A candidate feature must show an independent partial correlation (p < 0.05) at acceptable collinearity (VIF < 10), or win a leave-one-area-out head-to-head. The gate has real veto power — it has said no more often than yes:

FeatureVerdictEvidence
Young-driver shareDRIVERstrongest independent predictor (partial r ≈ +0.55) — kept as a composition control
IMD crime sub-domainDRIVERpartial r +0.43, p=3.7×10⁻⁶ — replaced overall deprivation, which collapsed to p=0.78 once its crime component stood alone
Vehicle crime rateDRIVERindependent significant keeper in every wave
Cars per householdDRIVERcomposition control, negative sign (car-dense suburbs price lower)
AADF traffic intensityDRIVERkept on LOAO head-to-head: dropping it worsens MAE £76.51 → £82.54
Population densityGATED OUTalways collinear with the urban-intensity features — replaced by point-level AADF, which resolved the "it's just a density model" critique
Flood riskGATED OUTwrong-signed for car premiums (r = −0.94 — it tracks rurality, which is cheap); ingested for all three nations, shown as a map diagnostic, banked as evidence for a future home-insurance line
Road casualties / KSIGATED OUTno independent signal once traffic exposure is controlled
IMD income sub-domainGATED OUTVIF 33 — redundant within the deprivation family

Place vs composition — the model's most honest finding

Demographics enter as controls, so each area gets three numbers: the full premium, a place-only counterfactual (demographics held at the national median), and the composition uplift between them. Composition alone explains more of the spread (R² 0.88) than place alone (R² 0.82) — who lives there beats what happens there. That is reported as a finding, not hidden as an inconvenience.

Explainable to the pound

Each area's premium decomposes through an exact LMDI (logarithmic-mean) waterfall: a £ step per factor from a typical-GB baseline (every feature at the median), summing to the headline premium exactly — no residual, independent of factor ordering — with a train/serve-consistency test guarding the served map against stale coefficients.

Uncertainty, stated honestly

Intervals come from a 200-rep cluster bootstrap (resampling anchor areas, not rows) — but coefficient uncertainty alone gave an implausibly tight £241 median width, so bands are widened by the out-of-sample LOAO residual variance to an honest median width of £373. Every one of the 41,729 areas ships with its premium_low/premium_high.

Sanity anchors the docs keep returning to: West-Central London prices at ≈1.9× Rugby; the City of London at ≈2.5× Truro — consistent with the published index geography the model calibrates against.

Pipeline

Open data in, priced map out

Four make-target stages, each writing intermediate Parquet files, so every step is inspectable and re-runnable. One module per source, pure-function cores with isolated I/O, ~one pytest file per module. All spatial maths in the British National Grid (EPSG:27700); reprojection to WGS84 happens only at final map output.

M1 · ingestsrc/ingest/*

Ten source modules → data/interim/*.parquet. Each pulls one open source (bulk CSV, ArcGIS REST, SPARQL, WFS, SFTP), validates it, and normalises to the 2011 LSOA / Data-Zone geography that all sources share.

M2 · featuresaggregate_to_lsoa

Join everything onto the boundary master list — one row per area: crime rates per 1k population per year, severity-weighted casualties, deprivation ranks, traffic intensity, demographics. Missing features reweight per-row rather than being zero-filled.

M3 · riskbuild_risk_index

Percentile features + calibrated coefficients → £. Reads the calibration, reconstructs each area's premium, place-only counterfactual, waterfall contributions, intervals and quintile — writes lsoa_risk.parquet and the GeoJSON the map serves.

M4 · calibratesrc/calibrate/*

The regression and its audit. Anchor-panel ingest, OLS with clustered SEs, ridge cross-validation, leave-one-area-out, temporal back-test, VIF/partial-correlation feature gate — then re-runs M3 and the map bake so served data can never lag the coefficients.

bakeshowcase

Topology-aware simplification (mapshaper) of 41,729 polygons into the static GeoJSON a React + MapLibre frontend streams from GitHub Pages — no server in production; the FastAPI app is a local dev convenience only.

Data sources

Ten open sources, one geography

Everything is public and licensed under the Open Government Licence. The unglamorous core decision: standardise on 2011 census geography — the lowest common denominator that deprivation indices, boundaries and Scottish Data Zones all share.

SourceAccessFeedsThe interesting transform
ONS / ScotGov boundariesarea_boundaries.parquet ArcGIS RESTspatial backbone Paginated ESRI features → ring-winding repair → unified GB schema; areas computed in EPSG:27700; make_valid is always the last geometry op (re-simplifying after it once re-broke Scottish areas)
data.police.ukvehicle_crime.parquet bulk archivevehicle_crime (E+W) 36 months of street-level vehicle crime, already LSOA-coded → incidents per 1k residents per year
Recorded Crime in Scotlandscotland_vehicle_crime.parquet SPARQLvehicle_crime (Scot) Council-level theft-of/from-vehicle counts disaggregated to Data Zones by population share; ranked within Scotland only — recording definitions differ from E+W, so absolute rates are never compared cross-border
IoD2019 / WIMD / SIMDdeprivation.parquet CSV · ArcGIS · workbookimd_crime + diagnostics Three incompatible national indices → within-nation percentile ranks; the crime sub-domain is the premium driver (Wales has no pure crime domain — its Community Safety domain is the documented nearest analogue)
DfT AADF count pointsaadf.parquet bulk ZIPaadf_intensity ~22k GB traffic count points → KD-tree radius query: mean annual daily flow of points within 2 km of each area centroid (nearest-point fallback recorded for audit)
Census 2021 / 2022demographics.parquet Nomis · UKDSyoung_driver_share · cars_per_household E+W age bands split uniformly-within-band for the 17–24 share; Scotland's 2022 tables publish exact single-year counts on 2011 Data Zones — no crosswalk needed
DfT STATS19collisions.parquet bulk CSVdiagnostics only Severity-weighted collisions (slight 1 / serious 3 / fatal 8); Scottish rows carry no area code natively → point-in-polygon spatial join
EA · NRW · SEPA floodflood.parquet SFTP · WFS · RESTdiagnostic only High+Medium flood extents (326k England features) dissolved then areal-overlaid against every area → % of area at risk; within-nation ranked because "Medium" means 1-in-100yr to the EA and 1-in-200yr to SEPA
DfT LA road traffictraffic.parquet bulk CSVdiagnostic only The cautionary tale: local-authority traffic per resident is an inverse-density proxy (rural motorway corridors score highest) — demoted, and the reason point-level AADF exists
ONSPDpostcode_lookup.parquet bulk ZIPpostcode search Postcodes filtered to GB; one unified column maps each postcode to its LSOA or Data Zone (the newer NSPL product dropped that column in 2026 — hence ONSPD)

Calibration ground truth (not a feature): a 137-row anchor panel hand-transcribed from the WTW/Confused.com quarterly price index and MoneySuperMarket's published regional figures, pooled with a source fixed-effect — 106 matched observations across 30 areas survive into the regression.

Honesty

What it doesn't claim

Validation grain ≠ prediction grain. The model validates at postcode-area/region grain (where published premiums exist) and predicts at LSOA grain. Per-LSOA figures are principled extrapolation — directionally strong rankings, not precise quotes.
Small anchor sample, by design. 106 observations is what honestly exists in public. That is why the model is linear, and why LOAO / temporal back-tests / ridge CV carry the argument rather than fit statistics.
Ecological inference. Area aggregates predict area premiums; nothing here supports individual-level conclusions.
Known blind spot. Wealthy-but-central areas can under-price: deprivation-family signals are low there while real premiums are driven by unmodelled factors (vehicle values, congestion, claims cost).
Scotland caveats. Crime arrives at council grain (no within-council variation) and Scottish anchors validate the place-effect at a thinner sample than E+W.
Northern Ireland excluded — no open street-level crime source; the model would carry only half its features there.

Evolution

Lessons the model was forced to learn

The current form is the residue of arguments the data won:

Model the ratio, not the £. Absolute premiums conflate national price drift with the spatial effect; the log relative index isolates place.
Replace proxies when the critique is valid. Population density, always collinear, was swapped for measured traffic flow at count points, which answered the "it's just a density model" critique; the feature gate, not intuition, now decides what stays.
Give the gate veto power. The 2026-07 wave tested three candidates; the gate admitted one (IMD crime, which displaced its own parent index) and rejected two — including flood risk, whose wrong sign for car premiums is now banked evidence for a home-insurance line.
Explainability must reconcile. Driver breakdowns that "gesture" at contributions were replaced by an exact decomposition that sums to the pound, with a serve-consistency test that guards the served map against stale coefficients.
Composition dominating place is a finding. Rather than tuning it away, the model reports both numbers per area — and the place-only counterfactual became a product feature.

Sources & access

Where the data actually comes from

Every source is open and OGL-licensed, but "open" spans five very different access routes — from a one-click bulk download to a credentialed SFTP drop that had to be requested by email:

Bulk downloads — street-level crime archive from data.police.uk; STATS19 road-safety data and AADF traffic count points from DfT road traffic statistics / data.gov.uk; English Indices of Deprivation 2019 from gov.uk; the ONS Postcode Directory and LSOA boundaries from the ONS Open Geography Portal.
APIs — Scottish recorded crime via the statistics.gov.scot SPARQL linked-data endpoint; Welsh WIMD via the Welsh Government's ArcGIS services (the original ArcGIS organisation was decommissioned mid-project — the ingest now targets the official data_WG org); Scottish Data Zone boundaries and SIMD from gov.scot / NHS Scotland open data; census tables via Nomis (England & Wales, 2021) and the UK Data Service (Scotland, 2022).
Flood data — the hard one. Wales (NRW FRAW) streams from DataMapWales WFS and Scotland from SEPA's flood maps (whose API intermittently rejects complex geometries — the ingest retries feature-by-feature). England's RoFRS/NaFRA2 extents, however, are not a public download: the full dataset had to be requested from Defra's data services by email, which provisioned credentialed SFTP access to an 83-tile geodatabase (326k flood-extent features; credentials kept out of git). A reminder that "open data" sometimes still means asking a human.
Hand transcription — the calibration anchors: the WTW/Confused.com quarterly price index and MoneySuperMarket's published regional premiums are transcribed by hand into a cited per-row panel — the project's strict rule being that no premium figure exists in the model without a published, cited source behind it.