Skip to content

CAssociation · Guide test 255

LOSH tests

Test local spatial heterogeneity of variability relative to a specified spatial reference.

Runs in CodeSplashPython (calls R) example not runR example not run

Do it in CodeSplash

In the app, set it up in Analyze with this method:

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

7

A side × side grid of areas; neighbors share an edge (rook), weights row-standardized.

0.20

Simultaneous autoregression y = ρWy + ε: positive ρ makes neighbors alike; 0 is no dependence.

0.0

Raises the center block by this much: a local cluster of high values.

3.0

Multiplies the noise in the center block: local heterogeneity in spread.

25

The area whose local statistic is tested (row-major from the top left; click the map).

0.050

Your data

Click an area to test it locally
13.475.78

The 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

χ² = 11.67
  1. The reference: how χ² varies across samples when H₀ is true (χ² approximation (Ord & Getis 2012)).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .051).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Hi=∑jwij ∣xj−xˉi∣2h1∑jwij,2HiVar(Hi) ∼˙ χ2/Var(Hi)2H_i=\frac{\sum_jw_{ij}\,|x_j-\bar x_i|^2}{h_1\sum_jw_{ij}},\qquad \frac{2H_i}{\mathrm{Var}(H_i)}\ \dot\sim\ \chi^2_{2/\mathrm{Var}(H_i)}

With your numbers

H25=2.15,Var=0.37,χ2=11.67, ν=5.44H_{25} = 2.15,\quad \mathrm{Var} = 0.37,\quad \chi^2 = 11.67,\ \nu = 5.44
xˉi\bar x_i
the local mean of the area's neighbors
h1h_1
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, Hi = 2.15. The p-value is above α = .050, so the data are compatible with H0.

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

xˉiloc=∑jwijxjWiei=∣xi−xˉiloc∣aHi=∑jwijejWieˉ\begin{gathered}\bar x_i^{loc}=\frac{\sum_jw_{ij}x_j}{W_i}\\[5pt] e_i=|x_i-\bar x_i^{loc}|^a\\[5pt] H_i=\frac{\sum_jw_{ij}e_j}{W_i\bar e}\end{gathered}

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.

Python · invokes R

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()
R

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

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.