
Spatial Regression (SAR / SEM / SDM / SAC) for Climate-Health Associations
Source:R/sus_mod_spatial_reg.R
sus_mod_spatial_reg.RdFits maximum-likelihood spatial regression models that account for spatial spillovers between geographic units (e.g. municipalities) in climate-health studies. Four model families are supported: the Spatial Autoregressive Model (SAR / spatial lag), the Spatial Error Model (SEM), the Spatial Durbin Model (SDM), and the Spatial Autocorrelation Model (SAC).
Arguments
- df
A
data.frameorclimasus_dfcontaining all variables informula. If ansfobject, geometry is dropped automatically.- formula
A
formulaspecifying the outcome and predictors, e.g.deaths ~ mean_temp + precip + pib_pc.- W
A
climasus_weightsobject produced bysus_mod_spatial_weights(). Must contain alistwelement whose length matchesnrow(df).- model
Character. Spatial model family. One of
"lag"(SAR, default),"error"(SEM),"durbin"(SDM), or"sac"(SAC).- method
Character. Estimation method passed to the underlying spatialreg function. One of
"eigen"(default),"LU","Chebyshev", or"MC"."eigen"is exact; the others are approximations suitable for large datasets.- zero_policy
Logical. If
TRUE(default), spatial units with no neighbours (islands) are allowed and receive a zero spatial lag/error. Passed to all spatialreg and spdep calls.- 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_reg", "list") with the
following named elements:
$modelCharacter. The model argument value.
$model_labelCharacter. Human-readable model name.
$coefficientsdata.framewith columnsterm,estimate,std_error,z_value,p_valuefor all covariates (excluding the spatial parametersrho/lambda).$rhoNumeric spatial lag parameter (
NULLfor theerrormodel).$lambdaNumeric spatial error parameter (
NULLfor thelaganddurbinmodels).$impactsdata.framewith columnsterm,direct,indirect,total(fromspatialreg::impacts()), orNULLfor theerrormodel or when impact computation fails.$aicNumeric. AIC of the spatial model.
$lm_aicNumeric. AIC of the OLS baseline (same formula, same data).
$moran_residualsNamed list with elements
I(Moran statistic),p_value(analytical p-value), andz(z-score).$fittedNumeric vector of fitted values.
$residualsNumeric vector of model residuals.
$callThe matched function call.
Model families
"lag"(SAR)The outcome in unit \(i\) depends on a weighted average of outcomes in neighbouring units (spatial lag). Estimated via
spatialreg::lagsarlm(). Contains a spatial lag parameterrho."error"(SEM)Spatial dependence enters through a spatially autocorrelated error term. Estimated via
spatialreg::errorsarlm(). Contains a spatial error parameterlambda."durbin"(SDM)Extends the SAR model by including spatially lagged covariates (Durbin terms). Estimated via
spatialreg::lagsarlm()withDurbin = TRUE. Contains bothrhoand lagged-covariate coefficients."sac"(SAC)Contains both a spatial lag of the outcome (
rho) and a spatial error term (lambda). Estimated viaspatialreg::sacsarlm().
Impacts
For models with a spatial lag (lag, durbin, sac), the total effect of
a covariate is decomposed into direct (own-unit), indirect (spillover),
and total effects using spatialreg::impacts() with R simulations for
inference. For the error model impacts equal OLS slopes and no
decomposition is meaningful; the $impacts element will be NULL.
Residual diagnostics
After fitting, spdep::moran.test() is applied to the model residuals to
verify that spatial autocorrelation has been adequately absorbed. A
non-significant Moran p-value indicates a well-specified spatial model.
References
Anselin, L. (1988). Spatial Econometrics: Methods and Models. Kluwer Academic Publishers.
LeSage, J., & Pace, R. K. (2009). Introduction to Spatial Econometrics. CRC Press / Taylor & Francis.
Bivand, R. S., Pebesma, E., & Gomez-Rubio, V. (2013). Applied Spatial Data Analysis with R (2nd ed.). Springer.
Elhorst, J. P. (2014). Spatial Econometrics: From Cross-Sectional Data to Panels. Springer.
Examples
if (FALSE) { # \dontrun{
library(climasus4r)
# W <- sus_mod_spatial_weights(shp, style = "W")
result <- sus_mod_spatial_reg(
df = my_df,
formula = deaths ~ mean_temp + precip + pib_pc,
W = W,
model = "lag",
lang = "pt"
)
print(result)
summary(result)
# SDM with spillovers
result_sdm <- sus_mod_spatial_reg(
df = my_df,
formula = deaths ~ mean_temp + precip,
W = W,
model = "durbin"
)
result_sdm$impacts
} # }