CAssociation · Guide test 255
LOSH tests
Test local spatial heterogeneity of variability relative to a specified spatial reference.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Hot spots and local spatial patterns (LISA, Getis–Ord Gi and Gi*, LOSH) — Where on the map are the clusters, hot spots, spatial outliers or unusually variable neighborhoods?
In Hot spots and local spatial patterns (LISA, Getis–Ord Gi and Gi*, LOSH), choose Local statistic = LOSH.
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · LOSH test
A side × side grid of areas; neighbors share an edge (rook), weights row-standardized.
Simultaneous autoregression y = ρWy + ε: positive ρ makes neighbors alike; 0 is no dependence.
Raises the center block by this much: a local cluster of high values.
Multiplies the noise in the center block: local heterogeneity in spread.
The area whose local statistic is tested (row-major from the top left; click the map).
Your data
Click an area to test it locallyThe heavy outline is the tested area, the dashed ones its neighbors. Click an area to test it instead; testing every area needs a multiplicity correction.
If H₀ were true
- The reference: how χ² varies across samples when H₀ is true (χ² approximation (Ord & Getis 2012)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .051).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- the local mean of the area's neighbors
- the average squared deviation over the map
The verdict
χ²(5.44) = 11.67, p = .051, Hᵢ = 2.15
p > α = .050: compatible with H₀
Effect size: local spatial heteroscedasticity Hᵢ = 2.146
Detects local heterogeneity of spread, not of level: a hot spot of variance. The χ² approximation is rough with few neighbors.
- Statistic
- 11.673
- p-value
- 0.0514
LOSH test on a 7 × 7 grid of 49 areas: χ²(5.44) = 11.67, p = .051, Hᵢ = 2.15. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0i: no unusual local spatial heterogeneity of deviations.
Assumptions
A prespecified spatial weights/neighborhood matrix W, a clearly defined spatial null, and observations whose labels can be permuted under that null. Model residual tests require model-specific adjustments.
Formula
Parameters and notation
Wi=Σjwij; a>0, usually a=2. ē is the global mean powered deviation; high Hi indicates locally high variability.
Structure of the method
Calculate a neighborhood mean, transform absolute local deviations with the selected exponent, average neighboring transformed deviations, and normalize by global mean deviation. LOSH therefore targets local heterogeneity of spread rather than the high-value concentration measured by Getis–Ord or local signed association measured by Moran.
Estimated and nuisance parameters
Estimate local means, residual/deviation magnitudes, global deviation average, and null moments or Monte Carlo references. There is no fitted spatial variance-regression coefficient. A high normalized value says nearby deviations are large relative to the chosen global baseline; it does not identify the cause of heterogeneity.
Settings and design choices
Choose neighborhood weights, exponent a, analytic versus Monte Carlo method, number of replicates, zero-neighbor policy, and local multiplicity correction. The common a=2 setting targets squared dispersion; a different exponent changes outlier sensitivity and the interpretation, and may not support the same analytic approximation.
Fitting and adaptation
Recompute both local means and deviations within the algorithm required by the chosen calibration; do not permute only a convenient final score without justification. Adaptation to another spatial scale requires a new graph and null assessment. The supplied LOSH.mc route performs Monte Carlo inference and needs a reported random seed.
Sensitivity and robustness
Inspect islands, low-degree boundaries, extreme observations, nonstationary mean structure, heterogeneous measurement precision, and local-test dependence. Local residuals are generated using overlapping neighborhoods, so they are not independent observations. Report the exponent, baseline variability, and adjusted uncertainty to avoid mistaking a noisy measurement region for a confirmed process change.
How to use and calibrate
Use the LOSH permutation procedure or its a=2 moment-matched chi square approximation; account for local multiplicity.
Example application
Find neighborhoods where values vary unusually strongly.
Interpretation and pitfalls
Watch out
LOSH concerns heterogeneity, not high-value clustering. Isolated locations, weights and exponent alter interpretation.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Synthetic 6×6 rook-neighbor lattice; weights and null randomization choices are part of the test. Local tests require multiplicity control before declaring a map of discoveries. localG without self-neighbors is G, not G-star.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: spdep
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
nb<-spdep::cell2nb(6,6,type="rook");lw<-spdep::nb2listw(nb,style="W");x<-rnorm(36)
print(spdep::LOSH.mc(x,lw,nsim=999))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Not run — Syntax checked; runtime not verified in the final environment · needs spdep
set.seed(2026)
nb<-spdep::cell2nb(6,6,type="rook");lw<-spdep::nb2listw(nb,style="W");x<-rnorm(36)
print(spdep::LOSH.mc(x,lw,nsim=999))
Sources
- spdep — spdep · LOSHAuthor documentation/source reviewed: spdep 1.4-2.search.r-project.org
- spdep — spdep · LOSH.mcAuthor documentation/source reviewed: spdep 1.4-2.search.r-project.org
- LOSHsearch.r-project.org
- LOSH.mcsearch.r-project.org
- cell2nbsearch.r-project.org
- nb2listwsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 255, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT255.