Logo van Spatial Statistics

Spatial Statistics

Community
muend
spatial-statistics

Always invoke before testing a geographic pattern for clustering, hotspots, dependence, or explanatory regression, even when aggregation or ordinary OLS is proposed as routine. Covers Moran's I, LISA, Getis-Ord Gi*, weights, MAUP and scale sensitivity for areas/grids, residual dependence, and spatial lag/error/GWR/MGWR models. Use ML standards for predictive evaluation and geostatistics for continuous surfaces from sparse samples.

Overzicht

Uitgevermuend
Repositorygeoai-skills
Skillnaamspatial-statistics
Sterren
45
Forks
5
Meegeleverde bestanden
2
LicentieMIT
Links
  • Instructies in Markdown

    Een SKILL.md-bestand dat het model laadt wanneer nodig, zodat het alleen tokens kost als een verzoek er daadwerkelijk bij past.

  • Werkt met elk LLM

    AI-skills zijn gewone Markdown, geen aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • 2 meegeleverde bestanden

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. Bestanden zijn alleen-lezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door muend op GitHub. Lees de broninhoud voordat je de skill installeert.

Installatie

Installeer de AI-skill Spatial Statistics in TypingMind om deze met elke LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map — het leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/muend/geoai-skills/tree/main/skills/spatial-statistics
  4. Schakel de skill in elke chat in waarin je deze beschikbaar wilt hebben.
Plug-ins → Skills → Nieuwe skill → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/muend/geoai-skills.git /tmp/geoai-skills
mkdir -p .claude/skills
cp -r /tmp/geoai-skills/skills/spatial-statistics .claude/skills/spatial-statistics
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Spatial Statistics in een willekeurige chat in TypingMind in en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek erbij past, laadt het model zelf de volledige instructies — je hoeft de skill nooit handmatig aan te roepen en deze kost pas tokens wanneer je de skill daadwerkelijk gebruikt.

Het model laadt Spatial Statistics automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Spatial Statistics niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

Spatial Statistics

Purpose: answer "is it clustered, where, and why" with defensible inference. The core discipline: spatial data violates independence assumptions, so standard statistics silently overstate significance — every analysis here starts with weights design and ends with residual diagnostics.

Spatial weights (W) — the analysis IS the weights

Every result downstream depends on W; choose it for substantive reasons and run a sensitivity check with one alternative:

WeightsUse when
Queen/Rook contiguityIrregular polygons (admin units, parcels)
K-nearest neighborsPoints; islands present (contiguity leaves them unconnected)
Distance bandPhysical process with known range
Kernel (distance-decayed)Smooth influence, GWR-style local models
python
from libpysal.weights import Queen

w = Queen.from_dataframe(gdf, use_index=True)
print(f"islands: {w.islands}")   # unconnected units break stats — fix or document
w.transform = "r"                # row-standardize (default for Moran/lag models)

Always report: weights type, parameters, number of islands, and whether results survive an alternative W.

Global → local workflow

  1. Global Moran's I (esda.Moran, permutation inference ≥999) — answers "any clustering at all?" Report I, p_sim, and the permutation distribution, not the analytical p.
  2. LISA / local Moran (esda.Moran_Local) — maps WHERE: High-High, Low-Low clusters, High-Low/Low-High outliers. Correct for multiple testing (FDR at minimum) before coloring a map — uncorrected LISA maps overstate clusters and this is the field's most common abuse.
  3. Getis-Ord Gi* (esda.G_Local, star=True) — hot/cold spots of intensity (a distinct question from Moran clusters — Gi* finds concentrations of high values, LISA finds similarity structure).
  4. Rates, not counts, for population-based phenomena; use Empirical Bayes smoothing (esda.smoothing) for small-population units before any of the above — raw rates in sparse units are noise.

Point patterns

  • Separate first-order intensity (density varies) from second-order interaction (points attract/repel) — KDE describes the former, Ripley's K/L (pointpats) tests the latter.
  • Always test against an inhomogeneous null when the study area has obvious density gradients (population, roads); CSR against a city is a strawman.
  • KDE bandwidth drives the story: report it, justify it (Silverman/CV), and show one alternative.

Spatial regression decision path

Run OLS first, then diagnose — never start with a spatial model:

python
from spreg import OLS
ols = OLS(y, X, w=w, spat_diag=True, moran=True, name_y="price", name_x=xnames)

Decision (Anselin's rule via LM tests): LM-Lag significant & LM-Error not → spatial lag (SAR); reverse → spatial error (SEM); both → compare robust LM versions; neither → OLS stands (report that as a finding). Interpretation caveats: in SAR, coefficients are NOT marginal effects — report direct/indirect (spillover) effects. In SEM, spatial structure is nuisance correlation, no spillover story allowed.

GWR/MGWR (mgwr): when relationships plausibly vary over space. Bandwidth by AICc search; map local coefficients WITH local t-values masked for insignificance; MGWR when predictors operate at different scales. GWR is exploratory — resist causal language on local coefficients.

Inference honesty

  • Permutation p-values over analytical ones wherever available.
  • Multiple testing: n local tests = n units; FDR-correct.
  • MAUP (modifiable areal unit problem): results can flip with unit aggregation — if the aggregation level is a choice, test one alternative and disclose.
  • Spatial autocorrelation in residuals after modeling = model still wrong; report residual Moran's I for every final model.
  • Correlation ≠ causation applies doubly here: spatially confounded variables (everything correlates with "distance to coast") demand explicit identification strategies before causal claims.

Reporting template

## Spatial analysis: <question>
- Units & n, variable(s), rate smoothing: <...>
- W: <type/params>, islands: <n>, sensitivity W: <type>
- Global: Moran's I = <> (p_perm = <>)
- Local: <k> significant clusters after FDR; map attached
- Model: <OLS/SAR/SEM/GWR> chosen because <LM diagnostics>
- Residual Moran's I: <> — <interpretation>
- Caveats: MAUP, W-sensitivity, causal limits

Execution contract

  • Workflow: define inferential question and unit; inspect distributions and rates; construct and justify spatial weights; run global before local tests; fit models if needed; diagnose residual dependence; report uncertainty.
  • Decision rules: use spatial statistics for dependence and inference, geostatistics for interpolating sampled continuous surfaces, and predictive ML when out-of-sample prediction is the primary goal.
  • Verification protocol: test alternative weights and aggregation, use valid permutation or model inference, correct local multiplicity, inspect residual Moran's I, and distinguish association from causation.
  • Failure modes: withhold inferential claims for arbitrary weights, islands ignored, unstable MAUP results, uncorrected multiple tests, residual autocorrelation, or unsupported causal language.
  • Deliverables: analysis-ready variables, weights specification, global and local results, corrected significance, diagnostic maps, model and residual checks, sensitivity analysis, and caveats.
  • Source freshness: consult the authoritative source registry before applying version-sensitive statistical APIs or defaults.

Meegeleverde bestanden

Het model leest deze bestanden wanneer nodig terwijl de skill geladen is. Ze worden beschikbaar gesteld als leesbare bestanden en worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Spatial Statistics?

Always invoke before testing a geographic pattern for clustering, hotspots, dependence, or explanatory regression, even when aggregation or ordinary OLS is proposed as routine. Covers Moran's I, LISA, Getis-Ord Gi*, weights, MAUP and scale sensitivity for areas/grids, residual dependence, and spatial lag/error/GWR/MGWR models. Use ML standards for predictive evaluation and geostatistics for continuous surfaces from sparse samples.

Waarom Spatial Statistics gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Spatial Statistics bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model, en je kunt midden in een chat van model wisselen zonder dat de skill niet meer werkt. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Spatial Statistics in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/muend/geoai-skills/tree/main/skills/spatial-statistics. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Spatial Statistics gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Spatial Statistics gebruiken?

Zoveel als je wilt. Zolang een model skills ondersteunt, kun je Spatial Statistics ermee gebruiken: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama en meer. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Spatial Statistics gratis?

Ja. Deze skill is door muend op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. Deze volgt het open Agent Skills-formaat: een bestand met de naam SKILL.md met een naam en beschrijving, plus eventuele scripts, sjablonen of referentiebestanden die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇