Skip to contents

Fits 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).

Usage

sus_mod_spatial_reg(
  df,
  formula,
  W,
  model = c("lag", "error", "durbin", "sac"),
  method = c("eigen", "LU", "Chebyshev", "MC"),
  zero_policy = TRUE,
  lang = "pt",
  verbose = TRUE
)

Arguments

df

A data.frame or climasus_df containing all variables in formula. If an sf object, geometry is dropped automatically.

formula

A formula specifying the outcome and predictors, e.g. deaths ~ mean_temp + precip + pib_pc.

W

A climasus_weights object produced by sus_mod_spatial_weights(). Must contain a listw element whose length matches nrow(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:

$model

Character. The model argument value.

$model_label

Character. Human-readable model name.

$coefficients

data.frame with columns term, estimate, std_error, z_value, p_value for all covariates (excluding the spatial parameters rho/lambda).

$rho

Numeric spatial lag parameter (NULL for the error model).

$lambda

Numeric spatial error parameter (NULL for the lag and durbin models).

$impacts

data.frame with columns term, direct, indirect, total (from spatialreg::impacts()), or NULL for the error model or when impact computation fails.

$aic

Numeric. AIC of the spatial model.

$lm_aic

Numeric. AIC of the OLS baseline (same formula, same data).

$moran_residuals

Named list with elements I (Moran statistic), p_value (analytical p-value), and z (z-score).

$fitted

Numeric vector of fitted values.

$residuals

Numeric vector of model residuals.

$call

The 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 parameter rho.

"error" (SEM)

Spatial dependence enters through a spatially autocorrelated error term. Estimated via spatialreg::errorsarlm(). Contains a spatial error parameter lambda.

"durbin" (SDM)

Extends the SAR model by including spatially lagged covariates (Durbin terms). Estimated via spatialreg::lagsarlm() with Durbin = TRUE. Contains both rho and lagged-covariate coefficients.

"sac" (SAC)

Contains both a spatial lag of the outcome (rho) and a spatial error term (lambda). Estimated via spatialreg::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
} # }