Applies spatial differencing transformations from Mueller and Watson (2024) to remove spatial unit roots. Supports four transformation types: LBM-GLS, nearest-neighbor, isotropic, and cluster.
Usage
spurtransform(
formula,
data,
coords = NULL,
prefix = "h_",
transformation = c("lbmgls", "nn", "iso", "cluster"),
radius = NULL,
cluster = NULL,
latlong = FALSE,
replace = FALSE,
separately = FALSE
)Arguments
- formula
A one-sided formula specifying variables to transform, e.g.,
~ y + x1 + x2.- data
A data frame containing the variables.
- coords
Coordinate specification: a formula (e.g.,
~ s_1 + s_2), a matrix, orNULLto auto-detects_*variables.- prefix
Character prefix for transformed variable names. Default:
"h_".- transformation
Type of transformation:
"lbmgls"(default),"nn"(nearest-neighbor),"iso"(isotropic), or"cluster".- radius
Radius for isotropic transformation. Required when
transformation = "iso".- cluster
Variable name (in
data) for cluster transformation. Required whentransformation = "cluster".- latlong
Logical; are coordinates latitude/longitude?
- replace
Logical; overwrite existing variables with the prefix? Default:
FALSE.- separately
Logical; apply transformation separately for each variable (handling missing values per-variable)?