Skip to contents

Computes 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.frame or climasus_df containing at least the columns code_muni (7-digit IBGE municipality code) and the outcome column named by outcome. The row order must correspond to the spatial units encoded in W unless municipalities is 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_weights object produced by sus_mod_spatial_weights(). Must contain a listw element (a listw-class object from spdep) whose length matches nrow(df) after any filtering by municipalities.

municipalities

Optional character or integer vector of code_muni values to include. When supplied the function subsets and reorders df to match this vector before computation. Default NULL (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:

$global

One-row data.frame with columns I, E.I, Var.I, Z.I, p_value (analytical), and p_simulated (permutation-based).

$local

data.frame with one row per spatial unit and columns code_muni, Ii (local Moran statistic), Z.Ii (z-score), p_raw (unit-level permutation p), p_adj (adjusted p), and quadrant (factor: "HH", "LL", "HL", "LH", "NS").

$n_HH

Integer. Number of significant HH (hotspot) units.

$n_LL

Integer. Number of significant LL (coldspot) units.

$n_HL

Integer. Number of significant HL spatial outlier units.

$n_LH

Integer. Number of significant LH spatial outlier units.

$outcome_name

Character. The outcome argument value.

$call

The 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:

HH

High value surrounded by high neighbours (hotspot).

LL

Low value surrounded by low neighbours (coldspot).

HL

High value surrounded by low neighbours (spatial outlier).

LH

Low value surrounded by high neighbours (spatial outlier).

NS

Not significant at the specified alpha level.

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", ]
} # }