| Title: | Spatial Correlation-Robust Inference and Unit Root Diagnostics |
|---|---|
| Description: | Spatial correlation-robust regression inference, spatial unit root diagnostics, half-life confidence sets, spatial transformations, and spatial coefficient-variability testing and scale estimation using the methods of Mueller and Watson (2022) <doi:10.3982/ECTA19465>, Mueller and Watson (2023) <doi:10.1080/07350015.2022.2127737>, Mueller and Watson (2024) <doi:10.3982/ECTA21654>, and Mueller and Watson (2025). |
| Authors: | Paul David Boll [aut, cre, cph], Daniel Goettlich [aut, cph], Sascha O. Becker [aut, cph], Hans-Joachim Voth [aut, cph], Ulrich K. Mueller [ctb], Mark W. Watson [ctb], Authors of vendored Rust crates and bundled example data [cph] (see inst/COPYRIGHTS) |
| Maintainer: | Paul David Boll <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.7.0 |
| Built: | 2026-12-02 20:53:02 UTC |
| Source: | https://github.com/spatial-spur/spatial-rust |
Calculate spatial correlation-robust intervals for fitted unweighted regressions,
test for spatially varying coefficients (svptest) and estimate variation
scale (svpscale), run spatial unit root diagnostics, invert spatial
half-life tests, and transform spatial observations. The functions use a shared
native numerical engine.
scpc(model, data = NULL, lon = NULL, lat = NULL, coords_euclidean = NULL, cluster = NULL, ncoef = NULL, avc = 0.03, method = "auto", large_n_seed = 1, uncond = FALSE, cvs = FALSE, backend = NULL, nthreads = NULL, coords = NULL, geographic = FALSE, row_id = NULL, units = NULL, inference = NULL, landmarks = 1000L, landmark_samples = 20L, cv_tolerance = 0.001) spur(formula, data, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, nrep_tune = NULL, seed = 42, avc = 0.03, uncond = FALSE, cvs = FALSE, backend = NULL, nthreads = NULL, draws = NULL, tuning_draws = NULL, method = "auto", large_n_seed = 1) spurtest(formula, data, test, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, nrep_tune = NULL, seed = 42, backend = NULL, nthreads = NULL, draws = NULL, tuning_draws = NULL) spurtest_i0(formula, data, ...) spurtest_i1(formula, data, ...) spurtest_i0resid(formula, data, ...) spurtest_i1resid(formula, data, ...) spurhalflife(formula, data, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, level = 95, normdist = FALSE, seed = 42, backend = NULL, nthreads = NULL, draws = NULL) spurhalflife_point(formula, data, h0, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, level = 95, normdist = FALSE, seed = 42, backend = NULL, nthreads = NULL, draws = NULL) spurtransform(formula, data, lon = NULL, lat = NULL, coords_euclidean = NULL, prefix = "h_", transformation = "lbmgls", radius = NULL, clustvar = NULL, backend = NULL, nthreads = NULL, replace = FALSE) svptest(model, data = NULL, lon = NULL, lat = NULL, coords_euclidean = NULL, cluster = NULL, parm = NULL, avc = 0.01, q = NULL, alpha = 0.05, method = "auto", large_n_seed = 1, landmarks = 1000L, landmark_samples = 20L, cv_tolerance = 1e-5, backend = NULL, nthreads = NULL, coords = NULL, geographic = FALSE, row_id = NULL, units = NULL) svpscale(model, data = NULL, lon = NULL, lat = NULL, coords_euclidean = NULL, cluster = NULL, parm = NULL, avc = 0.01, q = NULL, reference_distance = NULL, seed = 42, nrep = 100000L, max_iter = 200L, multipliers = NULL, method = "auto", large_n_seed = 1, landmarks = 1000L, landmark_samples = 20L, backend = NULL, nthreads = NULL, coords = NULL, geographic = FALSE, row_id = NULL, units = NULL) load_chetty_data() spatial_build_info() ## S3 method for class 'scpc' print(x, ...) ## S3 method for class 'scpc' summary(object, ...) ## S3 method for class 'summary.scpc' print(x, ...) ## S3 method for class 'scpc' coef(object, ...) ## S3 method for class 'scpc' confint(object, parm, level = 0.95, ...) ## S3 method for class 'spatial_spur_halflife' print(x, ...) ## S3 method for class 'spatial_spur_halflife_point' print(x, ...) ## S3 method for class 'spatial_spur_test' print(x, ...) ## S3 method for class 'spatial_spur_test' summary(object, ...) ## S3 method for class 'spatial_spur_pipeline' print(x, ...) ## S3 method for class 'spatial_spur_pipeline' summary(object, ...) ## S3 method for class 'spatial_svp_test' print(x, ...) ## S3 method for class 'spatial_svp_test' summary(object, ...) ## S3 method for class 'spatial_svp_scale' print(x, ...) ## S3 method for class 'spatial_svp_scale' summary(object, ...)scpc(model, data = NULL, lon = NULL, lat = NULL, coords_euclidean = NULL, cluster = NULL, ncoef = NULL, avc = 0.03, method = "auto", large_n_seed = 1, uncond = FALSE, cvs = FALSE, backend = NULL, nthreads = NULL, coords = NULL, geographic = FALSE, row_id = NULL, units = NULL, inference = NULL, landmarks = 1000L, landmark_samples = 20L, cv_tolerance = 0.001) spur(formula, data, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, nrep_tune = NULL, seed = 42, avc = 0.03, uncond = FALSE, cvs = FALSE, backend = NULL, nthreads = NULL, draws = NULL, tuning_draws = NULL, method = "auto", large_n_seed = 1) spurtest(formula, data, test, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, nrep_tune = NULL, seed = 42, backend = NULL, nthreads = NULL, draws = NULL, tuning_draws = NULL) spurtest_i0(formula, data, ...) spurtest_i1(formula, data, ...) spurtest_i0resid(formula, data, ...) spurtest_i1resid(formula, data, ...) spurhalflife(formula, data, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, level = 95, normdist = FALSE, seed = 42, backend = NULL, nthreads = NULL, draws = NULL) spurhalflife_point(formula, data, h0, lon = NULL, lat = NULL, coords_euclidean = NULL, q = 15, nrep = NULL, level = 95, normdist = FALSE, seed = 42, backend = NULL, nthreads = NULL, draws = NULL) spurtransform(formula, data, lon = NULL, lat = NULL, coords_euclidean = NULL, prefix = "h_", transformation = "lbmgls", radius = NULL, clustvar = NULL, backend = NULL, nthreads = NULL, replace = FALSE) svptest(model, data = NULL, lon = NULL, lat = NULL, coords_euclidean = NULL, cluster = NULL, parm = NULL, avc = 0.01, q = NULL, alpha = 0.05, method = "auto", large_n_seed = 1, landmarks = 1000L, landmark_samples = 20L, cv_tolerance = 1e-5, backend = NULL, nthreads = NULL, coords = NULL, geographic = FALSE, row_id = NULL, units = NULL) svpscale(model, data = NULL, lon = NULL, lat = NULL, coords_euclidean = NULL, cluster = NULL, parm = NULL, avc = 0.01, q = NULL, reference_distance = NULL, seed = 42, nrep = 100000L, max_iter = 200L, multipliers = NULL, method = "auto", large_n_seed = 1, landmarks = 1000L, landmark_samples = 20L, backend = NULL, nthreads = NULL, coords = NULL, geographic = FALSE, row_id = NULL, units = NULL) load_chetty_data() spatial_build_info() ## S3 method for class 'scpc' print(x, ...) ## S3 method for class 'scpc' summary(object, ...) ## S3 method for class 'summary.scpc' print(x, ...) ## S3 method for class 'scpc' coef(object, ...) ## S3 method for class 'scpc' confint(object, parm, level = 0.95, ...) ## S3 method for class 'spatial_spur_halflife' print(x, ...) ## S3 method for class 'spatial_spur_halflife_point' print(x, ...) ## S3 method for class 'spatial_spur_test' print(x, ...) ## S3 method for class 'spatial_spur_test' summary(object, ...) ## S3 method for class 'spatial_spur_pipeline' print(x, ...) ## S3 method for class 'spatial_spur_pipeline' summary(object, ...) ## S3 method for class 'spatial_svp_test' print(x, ...) ## S3 method for class 'spatial_svp_test' summary(object, ...) ## S3 method for class 'spatial_svp_scale' print(x, ...) ## S3 method for class 'spatial_svp_scale' summary(object, ...)
model |
An unweighted |
data |
A data frame containing coordinates and, for formula interfaces, analysis variables. |
lon, lat
|
The names of geographic coordinate columns in degrees. |
coords_euclidean |
Names of Euclidean coordinate columns. |
coords |
A numeric coordinate matrix in fitted observation order. |
geographic |
Whether |
row_id |
A shared unique fitted row identifier column. |
cluster |
A site label column or a fitted-order site label vector. |
units |
A descriptive label for the supplied coordinate units. |
ncoef |
The number of coefficients to report. |
avc |
The upper bound on average pairwise correlation. |
method |
Spatial geometry choice |
large_n_seed, landmarks, landmark_samples
|
Settings for the Nyström ensemble ( |
uncond, inference
|
Select conditional OLS, conditional ordinary 2SLS, or unconditional inference. |
cvs |
Whether to return additional critical values. |
cv_tolerance |
The critical-value solver tolerance (in t units for |
backend |
Native backend selector |
nthreads |
Optional positive native thread budget. |
formula |
A regression formula, one-response formula, or supplied variable names, depending on the procedure. |
test |
One of |
q |
The number of low-frequency spatial directions ( |
nrep |
Requested simulation draws. Defaults to 100,000 (minimum 500 when fitting multipliers in |
nrep_tune |
Optional tuning draw count when seeding diagnostics in the core. |
seed |
Unsigned 32-bit integer seed in |
h0 |
Point-null half-life value in |
draws, tuning_draws
|
Optional matrices with |
level |
Confidence level (in percent for |
normdist |
Return half-life in sample diameters when true. |
prefix |
Prefix for transformed columns. |
transformation |
One of |
radius |
A strictly positive ISO radius in input units or meters for geography. |
clustvar |
Site label column for cluster demeaning. |
replace |
Allow replacement of existing output columns in the returned data. |
x, object
|
A fitted result object returned by |
parm |
Optional vector of coefficient names or 1-based indices for |
alpha |
Nominal significance level in |
reference_distance |
Physical reference distance |
max_iter |
Maximum dual optimization iterations for Lagrange multipliers in |
multipliers |
Optional 100-element Lagrange multiplier vector or |
... |
Additional arguments passed to |
scpc returns coefficient estimates, uncertainty, effective critical values
and a spatial basis in the reported site order. Valid conditional 2SLS t intervals
assume strong identification (for weak IV, scalar Anderson–Rubin testing is
recommended). Diagnostics return likelihood
ratios, p-values, critical values, and tuned alternatives; spur runs the
SPUR diagnostics and returns both the levels SCPC fit and the no-intercept
LBM-GLS transformed SCPC fit; spurtransform evaluates formula terms or
variable names on complete cases and returns the augmented data frame;
spurhalflife returns half-life confidence intervals and matrices of confidence
components with units and normalization using spec 0.7.0;
spurhalflife_point returns point-null test exceedance counts, p-values, and
acceptance indicators; svptest returns the Müller–Watson (2025)
coefficient stability test statistics, p-values, critical values, selected
dimension q, and eigenvalues; svpscale returns nearly median-unbiased
LBM scale estimates (kappa_unit, kappa_phys, sigma_delta_beta),
raw psi_hat, and reusable Lagrange multipliers; load_chetty_data returns the Chetty et al. commuting-zone
example data frame; and spatial_build_info returns the compiled methods
version and provider.
d <- load_chetty_data() d <- d[complete.cases(d[c("am", "fracblack", "lat", "lon")]), ][1:60, ] fit <- lm(am ~ fracblack, d) scpc(fit, d, lon = "lon", lat = "lat", nthreads = 1L) svptest(fit, d, lon = "lon", lat = "lat", q = 6L, parm = "fracblack", nthreads = 1L)d <- load_chetty_data() d <- d[complete.cases(d[c("am", "fracblack", "lat", "lon")]), ][1:60, ] fit <- lm(am ~ fracblack, d) scpc(fit, d, lon = "lon", lat = "lat", nthreads = 1L) svptest(fit, d, lon = "lon", lat = "lat", q = 6L, parm = "fracblack", nthreads = 1L)