stgam: Spatially and Temporally Varying Coefficient Models Using Generalized Additive Models

A framework for undertaking space and time varying coefficient models (varying parameter models) using a Generalized Additive Model (GAM) with smooths approach. The framework suggests the need to investigate for the presence and nature of any space-time dependencies in the data. It proposes a workflow that creates and refines an initial space-time GAM and includes tools to create and evaluate multiple model forms. The workflow sequence is to: i) Prepare the data by lengthening it to have a single location and time variables for each observation. ii) Create all possible space and/or time models in which each predictor is specified in different ways in smooths. iii) Evaluate each model via their AIC value and pick the best one. iv) Create the final model. v) Calculate the varying coefficient estimates to quantify how the relationships between the target and predictor variables vary over space, time or space-time. vi) Create maps, time series plots etc. The number of knots used in each smooth can be specified directly or iteratively increased. This is illustrated with a climate point dataset of the dry rain forest in South America. This builds on work in Comber et al (2024) <doi:10.1080/13658816.2023.2270285> and Comber et al (2004) <doi:10.3390/ijgi13120459>.

Version: 1.2.0
Depends: R (≥ 4.1.0), mgcv (≥ 1.9-1), glue
Imports: foreach, doParallel, parallel, dplyr, magrittr, purrr, stringr
Suggests: cols4all, knitr, ggplot2, cowplot, rmarkdown, testthat (≥ 3.0.0), tidyr, lubridate, sf, gratia, kableExtra
Published: 2026-01-29
DOI: 10.32614/CRAN.package.stgam
Author: Lex Comber [aut, cre], Paul Harris [ctb], Gonzalo Irisarri [ctb], Chris Brunsdon [ctb]
Maintainer: Lex Comber <a.comber at leeds.ac.uk>
BugReports: https://github.com/lexcomber/stgam/issues
License: MIT + file LICENSE
URL: https://github.com/lexcomber/stgam
NeedsCompilation: no
Materials: README, NEWS
CRAN checks: stgam results

Documentation:

Reference manual: stgam.html , stgam.pdf
Vignettes: A Geographer's introduction to GAMs (source, R code)
A Geographer's introduction to space-time regression with GAMs using 'stgam' (source, R code)

Downloads:

Package source: stgam_1.2.0.tar.gz
Windows binaries: r-devel: stgam_1.1.0.zip, r-release: stgam_1.1.0.zip, r-oldrel: stgam_1.1.0.zip
macOS binaries: r-release (arm64): stgam_1.2.0.tgz, r-oldrel (arm64): stgam_1.2.0.tgz, r-release (x86_64): stgam_1.1.0.tgz, r-oldrel (x86_64): stgam_1.2.0.tgz
Old sources: stgam archive

Linking:

Please use the canonical form https://CRAN.R-project.org/package=stgam to link to this page.