Tools for Statistical Inference with Geo-Coded Data
Overview
Fast computation of Conley (1999) doi:10.1016/S0304-4076(98)00084-0 spatial heteroskedasticity and autocorrelation consistent (HAC) standard errors for linear regression models with geo-coded data, with a fast C++ implementation by Christensen, Hartman, and Samii (2021) doi:10.1017/S0020818321000187. Performance-critical distance calculations, kernel weighting, and variance component accumulation are implemented in C++ via 'Rcpp' and 'RcppArmadillo'. Includes tools for estimating the spatial correlation range from covariograms and correlograms following the bandwidth selection method proposed in Lehner (2026) doi:10.48550/arXiv.2603.03997, and diagnostic visualizations for bandwidth selection.
- Initial CRAN release.
Conley spatial HAC standard errors
conley_SE()computes Conley (1999) spatial HAC variance-covariance matrices forlfe::felm()models, with support for cross-sectional spatial correlation, serial (temporal) correlation, and the combined spatial HAC estimator.- Six kernel functions: Bartlett, Epanechnikov, Gaussian, Parzen, Biweight, and Uniform.
- Haversine great-circle distances (default) and a 111 km/degree approximation.
- Balanced-panel optimisation pre-computes the distance matrix once.
compute_conley_lfe()convenience wrapper for quick single-coefficient extraction.lm_sac()all-in-one workflow: regression, Moran's I tests, and Conley standard errors, withmodelsummaryintegration via customtidyandglancemethods.
Show all changes in 0.1.0Hide the rest of the changes in 0.1.0
Bandwidth selection
covgm_range()estimates the spatial correlation range from the empirical covariogram of regression residuals (Lehner 2026).extract_corr_range()extracts the zero-crossing distance from a covariogram (gstat::variogram()) or correlogram (ncf::correlog()).inverseu_plot_conleyrange()diagnostic plot showing how the Conley SE varies with the bandwidth, revealing the inverse-U relationship (Lehner 2026).
Spatial utilities
DistMat()kernel-weighted spatial distance matrix (C++).coords_as_columns()extractssfpoint coordinates into tibble columns.gravity_centroid()computes the (optionally weighted) geographic centroid of ansfobject.grid_FE()assigns observations to spatial grid cells for use as fixed effects.
Performance
- Distance matrix computation, kernel weighting, and variance component accumulation (
XeeXhC,Bal_XeeXhC,XeeXhC_Lg,TimeDist) are implemented in C++ via Rcpp and RcppArmadillo. - Memory-efficient large-sample variant (
XeeXhC_Lg) avoids constructing the full n x n distance matrix when n > 50,000.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-04-22
- ERROR12 OK, 1 ERROR2026-04-18
- OK5 OK2026-03-26
Documentation
- Help pages
- 21 (6 internal)includes a package overview page
- Examples that run
- 11%1 run in a plain check · 8 only when donttest examples are enabled (R CMD check --as-cran)
- Exported functions with examples
- 60%
- Documented parameters
- 100%
- Return-value docs
- 93%
- Help pages citing references
- 48%
- spatial_HAC HTML
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- not measured
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
3 development-tooling and community-health practices detected across 3 families in the upstream repository
Checks run against github.com/axlehner/spatialinference on 2026-10-18.
Dependencies
Installing SpatialInference adds 21 packages (17 with compiled code, 27 MB of source tarballs). Heaviest: sf 9.3 MB, data.table 5.7 MB, s2 2.8 MB.
Code & Tests
Datasets
People & History
- RR 4.6.0 released · 2026-04-24
- 0.1.0Latest2026-03-25 · current release
- RR 4.5.0 released · 2025-04-11
Package metadata
- First published
- 2026-03-25
- Total releases
- 1 / 1 yrs
- License
- GPL (>= 3) OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 439 KB / 1 file
- Download size
- 1.1 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("SpatialInference")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.