Learn R Programming

spmodel: Spatial Statistical Modeling and Prediction

Overview

spmodel is an R package used to fit, summarize, and predict for a variety of spatial statistical models applied to point-referenced and areal (lattice) data. Parameters are estimated using various methods, including likelihood-based optimization and weighted least squares based on variograms. Additional modeling features include anisotropy, non-spatial random effects, partition factors, big data approaches, and more. Model-fit statistics are used to summarize, visualize, and compare models. Predictions at unobserved locations are readily obtainable. Visit our website at https://usepa.github.io/spmodel/.

Installation

Install and load the most recent approved version from CRAN by running

# install the most recent approved version from CRAN
install.packages("spmodel")
# load the most recent approved version from CRAN
library(spmodel)

Install and load the most recent development version ofspmodel from GitHub by running

# Installing from GitHub requires you first install the remotes package
install.packages("remotes")

# install the most recent development version from GitHub
remotes::install_github("USEPA/spmodel", ref = "develop")
# load the most recent development version from GitHub
library(spmodel)

Install the most recent development version of spmodel from GitHub with package vignettes by running

install the most recent development version from GitHub with package vignettes
devtools::install_github("USEPA/spmodel", ref = "develop", build_vignettes=TRUE)

View the introductory vignette in RStudio by running

vignette("introduction", "spmodel")

We have several other vignettes that are not shipped with CRAN but are available on our website (located at https://usepa.github.io/spmodel/) in the "Articles" tab:

  1. A Detailed Guide to spmodel
  2. Spatial Generalized Linear Models in spmodel
  3. Technical Details

Further detail regarding spmodel is contained in the package's documentation manual.

Citation

If you use spmodel in a formal publication or report, please cite it. Citing spmodel lets us devote more resources to it in the future. View the spmodel citation by running

citation(package = "spmodel")
#> 
#> To cite spmodel in publications use:
#> 
#>   Dumelle M, Higham M, Ver Hoef JM (2023). spmodel: Spatial statistical modeling and prediction in R. PLOS ONE, 18(3): e0282524.
#>   https://doi.org/10.1371/journal.pone.0282524
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Article{,
#>     title = {{spmodel}: Spatial statistical modeling and prediction in {R}},
#>     author = {Michael Dumelle and Matt Higham and Jay M. {Ver Hoef}},
#>     journal = {PLOS ONE},
#>     year = {2023},
#>     volume = {18},
#>     number = {3},
#>     pages = {1--32},
#>     doi = {10.1371/journal.pone.0282524},
#>     url = {https://doi.org/10.1371/journal.pone.0282524},
#>   }

Package Contributions

We encourage users submit GitHub issues and enhancement requests so we may continue to improve spmodel.

EPA Disclaimer

The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity , confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.

License

This project is licensed under the GNU General Public License, GPL-3.

Copy Link

Version

Install

install.packages('spmodel')

Monthly Downloads

419

Version

0.14.0

License

GPL-3

Maintainer

Michael Dumelle

Last Published

September 10th, 2026

Functions in spmodel (0.14.0)

fc_borders

Four Corners State Borders
eacf

Compute the empirical autocovariance
decorrelate_data

Apply the Spatial Decorrelation Transformation to a Data Object
deviance.spmodel

Fitted model deviance
decorrelate_grid

Create a Spatial Decorrelation Transformation Grid
dispersion_params

Create a dispersion parameter object
dispersion_initial

Create a dispersion parameter initial object
esv

Compute the empirical semivariogram
decorrelate

Apply the Spatial Decorrelation Transformation for Machine Learning Models
decorrelate_newdata

Apply the Spatial Decorrelation Transformation to a Newdata Object for Prediction
kcv

Perform k-fold cross validation
labels.spmodel

Find labels from object
influence.spmodel

Regression diagnostics
hatvalues.spmodel

Compute leverage (hat) values
fitted.spmodel

Extract model fitted values
lake_preds

Lakes Prediction Data
lake

National Lakes Assessment Data
glance.spmodel

Glance at a fitted model object
glances

Glance at many fitted model objects
formula.spmodel

Model formulae
model.matrix.spmodel

Extract the model matrix from a fitted model object
plot.spmodel

Plot fitted model diagnostics
moose

Moose counts and presence in Alaska, USA
print.spmodel

Print values
predict.spmodel

Model predictions (Kriging)
logLik.spmodel

Extract log-likelihood
model.frame.spmodel

Extract the model frame from a fitted model object
loocv

Perform leave-one-out cross validation
satterthwaite.splm

Compute Satterthwaite denominator degrees of freedom
recorrelate_newdata

Recorrelate Machine Learning Predictions
pseudoR2

Compute a pseudo r-squared
randcov_initial

Create a random effects covariance parameter initial object
residuals.spmodel

Extract fitted model residuals
spautor

Fit spatial autoregressive models
reexports

Objects exported from other packages
moss

Heavy metals in mosses near a mining road in Alaska, USA
moose_preds

Locations at which to predict moose counts and presence in Alaska, USA
randcov_params

Create a random effects covariance parameter object
spautorRF

Fit random forest spatial residual models
seal

Estimated harbor-seal trends from abundance data in southeast Alaska, USA
spcov_initial

Create a spatial covariance parameter initial object
spmodel-package

spmodel: Spatial Statistical Modeling and Prediction
splm

Fit spatial linear models
sprbinom

Simulate a spatial binomial random variable
spcov_params

Create a spatial covariance parameter object
splmRF

Fit random forest spatial residual models
tidy.spmodel

Tidy a fitted model object
varcomp

Variability component comparison
sprbeta

Simulate a spatial beta random variable
summary.spmodel

Summarize a fitted model object
texas

Texas Turnout Data
vcov.spmodel

Calculate variance-covariance matrix for a fitted model object
spgautor

Fit spatial generalized autoregressive models
spglm

Fit spatial generalized linear models
sulfate

Sulfate atmospheric deposition in the conterminous USA
sprnbinom

Simulate a spatial negative binomial random variable
sprinvgauss

Simulate a spatial inverse gaussian random variable
sulfate_preds

Locations at which to predict sulfate atmospheric deposition in the conterminous USA
sprnorm

Simulate a spatial normal (Gaussian) random variable
sprpois

Simulate a spatial Poisson random variable
sprgamma

Simulate a spatial gamma random variable
AICc

Compute AICc of fitted model objects
cooks.distance.spmodel

Compute Cook's distance
covmatrix

Create a covariance matrix
conditional

Conditionally simulate from a model
confint.spmodel

Confidence intervals for fitted model parameters
AUROC

Area Under Receiver Operating Characteristic Curve
augment.spmodel

Augment data with information from fitted model objects
coef.spmodel

Extract fitted model coefficients
anova.spmodel

Compute analysis of variance and likelihood ratio tests of fitted model objects
caribou

A caribou forage experiment