Spatial-temporal areal estimation from survey data.
Status: in development. Current release: 0.2.0.
📖 Documentation: mrc-ide.github.io/stareal
Tutorials, the method, and the reference for every function are there. This GitHub page holds the source code only.
stareal fits a Bayesian space-time model to binomial survey data, such as the prevalence of a drug-resistance marker, at an areal level: administrative units, or any other set of polygons. Time runs in regular steps of your choosing, such as months, quarters or years. The model estimates prevalence in every area and time step, including the many with no surveys, and gives the uncertainty of every estimate. Regional and national summaries are made from the joint posterior.
It is built for data that are sparse relative to the space-time grid. Standard areal software carries a latent value for every area-time cell, surveyed or not. stareal integrates the unsurveyed cells out exactly, fits the model to the surveyed cells alone, and rebuilds the full surface from each posterior draw. Its cost depends on the number of surveys, not on the size of the map.
The model offers five spatial priors (Leroux, BYM2, the proper and the intrinsic CAR, and independent areas), optional main effects in space and in time (including random walks), and Knorr-Held's four types of space-time interaction. Models are compared by approximate leave-one-out from a single fit each, or by cross-validation.
# install.packages("remotes")
remotes::install_github("mrc-ide/stareal@v0.2.0")This installs release 0.2.0, which never changes. For results that do not
move as the package develops, install a release like this and report its
version. remotes::install_github("mrc-ide/stareal") gives the latest
release.
library(stareal)
iso3 <- c("DJI", "ERI", "ETH", "KEN", "SOM", "SSD", "SDN", "UGA") # the eight IGAD countries
adm1 <- sf::st_as_sf(geodata::gadm(iso3, level = 1, path = tempdir(), resolution = 2))
adm1 <- adm1[adm1$ENGTYPE_1 != "Water body", ] # lakes are not places
fr <- areal_frame(adm1, id = "GID_1", groups = c(country = "COUNTRY"),
link_within = "country") # areas and their neighbours
tf <- time_frame(1989, 2024, "month") # the time grid
d <- areal_data(igad_crt76t, fr, tf, y = "positive", k = "tested",
coords = c("longitude", "latitude"), date = "collection_day")
fit <- fit_areal(d) # MCMC, chains in parallel
diagnose(fit) # convergence of every parameter
pr <- predict(fit, groups = "country") # every area-month, and countries
plot(pr, time = "2024-01")The data are the chloroquine-resistance marker crt K76T in the eight IGAD countries, from the public STAVE collation. The boundaries are GADM’s, downloaded through geodata. The package website has tutorials, from this analysis to rare markers, covariates, cross-validation and simulation studies.
MIT.
