
Global Moran's I and LISA Local Autocorrelation for Health Outcomes
Source:R/sus_mod_spatial_moran.R
sus_mod_spatial_moran.RdComputes Moran's I global spatial autocorrelation statistic and Local Indicators of Spatial Association (LISA) for a numeric health outcome measured at municipality level. The global statistic tests whether the outcome is spatially clustered across the study region; the local statistics identify significant High-High (hotspots), Low-Low (coldspots), High-Low, and Low-High spatial outlier clusters.
Usage
sus_mod_spatial_moran(
df,
outcome,
W,
municipalities = NULL,
permutations = 999L,
alpha = 0.05,
adjust_p = c("fdr", "bonferroni", "none"),
lang = "pt",
verbose = TRUE
)Arguments
- df
A
data.frameorclimasus_dfcontaining at least the columnscode_muni(7-digit IBGE municipality code) and the outcome column named byoutcome. The row order must correspond to the spatial units encoded inWunlessmunicipalitiesis supplied to subset and reorder.- outcome
Character. Name of the numeric outcome column in
df(e.g."deaths","rate_100k","hospitalization_rate").- W
A
climasus_weightsobject produced bysus_mod_spatial_weights(). Must contain alistwelement (alistw-class object from spdep) whose length matchesnrow(df)after any filtering bymunicipalities.- municipalities
Optional character or integer vector of
code_munivalues to include. When supplied the function subsets and reordersdfto match this vector before computation. DefaultNULL(use all rows).- permutations
Positive integer. Number of Monte Carlo permutations for both global and local inference. Default
999.- alpha
Numeric in (0, 1). Significance threshold applied to p-adjusted local Moran p-values when assigning quadrant labels. Default
0.05.- adjust_p
Character. Method passed to
stats::p.adjust()for multiple-testing correction of local Moran p-values. One of"fdr"(default),"bonferroni", or"none".- lang
Character. Output language for messages:
"pt"(default),"en", or"es".- verbose
Logical. If
TRUE(default), print progress messages via cli.
Value
An object of class c("climasus_spatial_moran", "list") with the
following named elements:
$globalOne-row
data.framewith columnsI,E.I,Var.I,Z.I,p_value(analytical), andp_simulated(permutation-based).$localdata.framewith one row per spatial unit and columnscode_muni,Ii(local Moran statistic),Z.Ii(z-score),p_raw(unit-level permutation p),p_adj(adjusted p), andquadrant(factor:"HH","LL","HL","LH","NS").$n_HHInteger. Number of significant HH (hotspot) units.
$n_LLInteger. Number of significant LL (coldspot) units.
$n_HLInteger. Number of significant HL spatial outlier units.
$n_LHInteger. Number of significant LH spatial outlier units.
$outcome_nameCharacter. The
outcomeargument value.$callThe matched function call.
Global statistic
Moran's I is computed via permutation inference using
spdep::moran.mc(). The observed statistic is compared against the
empirical null distribution obtained by randomly permuting the outcome
values across spatial units. The reported p_simulated is the proportion
of permuted values as extreme as or more extreme than the observed I.
Local statistic (LISA)
Local Moran statistics are computed via spdep::localmoran_perm(), which
uses conditional permutation to generate unit-specific null distributions.
Each observation is assigned a LISA quadrant based on its standardised
value and the standardised spatial lag:
HHHigh value surrounded by high neighbours (hotspot).
LLLow value surrounded by low neighbours (coldspot).
HLHigh value surrounded by low neighbours (spatial outlier).
LHLow value surrounded by high neighbours (spatial outlier).
NSNot significant at the specified
alphalevel.
References
Moran, P. A. P. (1950). Notes on continuous stochastic phenomena. Biometrika, 37(1-2), 17-23.
Anselin, L. (1995). Local indicators of spatial association—LISA. Geographical Analysis, 27(2), 93-115.
Bivand, R. S., Pebesma, E., & Gomez-Rubio, V. (2013). Applied Spatial Data Analysis with R (2nd ed.). Springer.
Examples
if (FALSE) { # \dontrun{
# Requires spdep and a climasus_weights object W
library(climasus4r)
# W <- sus_mod_spatial_weights(shp, style = "W")
result <- sus_mod_spatial_moran(
df = my_df,
outcome = "deaths",
W = W,
permutations = 999,
alpha = 0.05,
adjust_p = "fdr",
lang = "pt"
)
print(result)
# Access local clusters
result$local[result$local$quadrant == "HH", ]
} # }