Package: stgam 1.2.1

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>.

Authors:Lex Comber [aut, cre], Paul Harris [ctb], Gonzalo Irisarri [ctb], Chris Brunsdon [ctb]

stgam_1.2.1.tar.gz
stgam_1.2.1.zip(r-4.7)stgam_1.2.1.zip(r-4.6)stgam_1.2.1.zip(r-4.5)
stgam_1.2.1.tgz(r-4.6-any)stgam_1.2.1.tgz(r-4.5-any)
stgam_1.2.1.tar.gz(r-4.7-any)stgam_1.2.1.tar.gz(r-4.6-any)
stgam_1.2.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
stgam/json (API)

# Install 'stgam' in R:
install.packages('stgam', repos = c('https://lexcomber.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/lexcomber/stgam/issues

Datasets:
  • chaco - Chaco dry rainforest data

On CRAN:

Conda:

6.19 score 7 stars 11 scripts 229 downloads 4 exports 26 dependencies

Last updated from:ed77303303. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK171
source / vignettesOK253
linux-release-x86_64OK174
macos-release-arm64OK172
macos-oldrel-arm64OK224
windows-develOK139
windows-releaseOK122
windows-oldrelOK136
wasm-releaseOK136

Exports:calculate_vcseffect_sizeevaluate_modelsgam_model_rank

Dependencies:clicodetoolsdoParalleldplyrforeachgenericsglueiteratorslatticelifecyclemagrittrMatrixmgcvnlmepillarpkgconfigpurrrR6rlangstringistringrtibbletidyselectutf8vctrswithr

A Geographer's introduction to space-time regression with GAMs using stgam
Overview | 1. Data and variables | 2. Space-time GAM contruction and considertations | 2.1 Overview | 2.2 Space-time GAMs | 2.3 Space-time GAM Refinement II: Effect size | 2.4 Space-time GAM Refinement III: k the number of knots | 2.5. Extracting, summarising and plotting the coefficients | title | plot | join to the grid | select the variables and pivot longer | rename and select with transmute | make the new time object a factor (to enforce plotting order) | 4. and plot | adjust default shading | facet | apply and modify plot theme | 2.6 Summary | 3. Working with stgam: model selection | 3.1 Using AIC to evaluate models | 3.2 Model selection: determining GAM form | 3.3 The 'best' model | 3.4 Plot and map the results | 3.5 Summary | 3.6 Useful resources | 3.7 Final words | References

Last update: 2026-05-18
Started: 2026-01-26

A Geographer's introduction to GAMs
Overview | 1. Data considerations | map the data layers | 2. Detecting variability | 2.1 Initial investigations with OLS and dummy variables | 2.2 Detecting variability using GAM smooths | create simulated data | plot x and y | 2.3 Temporal variability | 2.4 Spatial variability | the second GAM | 2.5 Space-time variability I | 2.6 Space-time variability II | 2.8 Summary | References

Last update: 2026-04-13
Started: 2026-01-26