
Visualizations for Space-Time Bayesian Disease Mapping Results
Source:R/sus_mod_plot_spacetime.R
sus_mod_plot_spacetime.RdProduces five types of visualization for climasus_spacetime_bayes and
climasus_spacetime_exceedance objects returned by
sus_mod_spacetime_bayes() and sus_mod_spacetime_exceedance():
choropleth maps of relative risk, temporal trend charts, space-time
interaction heatmaps, exceedance probability maps, and fixed-effect forest
plots. Static ggplot2 output is returned by default; set
interactive = TRUE for plotly::ggplotly() output.
Usage
sus_mod_plot_spacetime(
x,
type = c("rr_map", "temporal", "interaction", "exceedance", "coef"),
municipalities = NULL,
time_point = NULL,
time_range = NULL,
threshold = 1,
facet_time = FALSE,
palette = "RdYlBu",
title = NULL,
base_size = 11,
interactive = FALSE,
lang = "pt",
...
)Arguments
- x
A
climasus_spacetime_bayesobject fromsus_mod_spacetime_bayes()or aclimasus_spacetime_exceedanceobject fromsus_mod_spacetime_exceedance().- type
Character. One of
"rr_map"(default),"temporal","interaction","exceedance","coef". See Plot types.- municipalities
An
sfpolygon object with acode_municolumn (7-digit IBGE code). Required fortype = "rr_map"andtype = "exceedance". Typically fromgeobr::read_municipality().- time_point
Integer or
NULL. Single time index to display intype = "rr_map". Ignored whenfacet_time = TRUEor for other types. DefaultNULL(aggregate mean across all periods).- time_range
Integer vector of length 2 (
c(t_start, t_end)) to restrict the time axis intype = "temporal"andtype = "interaction". DefaultNULL(all periods).- threshold
Numeric. RR threshold used to select the exceedance layer from
x$exceedancewhentype = "exceedance". Default1.0.- facet_time
Logical. When
TRUEandtype = "rr_map", produces a faceted map with one panel per time period. DefaultFALSE.- palette
Character. Name of a diverging RColorBrewer palette for RR maps (e.g.
"RdYlBu","RdBu","PuOr"). Default"RdYlBu".- title
Character or
NULL. Custom plot title.NULLuses a multilingual default.- base_size
Numeric. Base font size for ggplot2 themes. Default
11.- interactive
Logical.
TRUEwraps the ggplot object withplotly::ggplotly()(requires plotly). DefaultFALSE.- lang
Character. Language for axis labels and titles:
"pt"(default),"en","es".- ...
Currently unused; reserved for future arguments.
Plot types (type)
"rr_map"Choropleth map of the posterior mean relative risk (
rr_mean) merged with themunicipalitiessf polygon layer. Uses a diverging colour scale centred at 1.0. Municipalities where the entire 95\ Supplytime_pointto show a single period; setfacet_time = TRUEto produce one facet per period; leave both as defaults to display the mean across all periods. Requiresmunicipalities."temporal"Line chart of the population-averaged posterior mean RR (aggregated across municipalities) with a shaded 95\ interval ribbon over time. Supply
time_rangeto restrict the displayed periods."interaction"Tile heatmap of the space-time interaction term (
gamma_mean) with municipalities on the y-axis and time periods on the x-axis. Requiresx$interactionin the input object. Supplytime_rangeto restrict columns."exceedance"Choropleth map of the exceedance probability P(RR >
threshold). Requires aclimasus_spacetime_exceedanceobject (or aclimasus_spacetime_bayesthat has an$exceedanceslot). Requiresmunicipalities."coef"Horizontal forest plot of the fixed-effect posterior summaries (
x$fixed). A dashed vertical reference line marks zero.
References
Knorr-Held, L. (2000). Bayesian modelling of inseparable space-time variation in disease risk. Statistics in Medicine, 19(17-18), 2555-2567. doi:10.1002/sim.1030
Blangiardo, M. & Cameletti, M. (2015). Spatial and Spatio-temporal Bayesian Models with R-INLA. Wiley. doi:10.1002/9781118950203
Examples
if (FALSE) { # \dontrun{
library(climasus4r)
library(geobr)
shp <- geobr::read_municipality(code_muni = "all", year = 2022)
fit <- sus_mod_spacetime_bayes(
df = agg,
outcome = "deaths",
covariates = c("temp_mean", "prec_total"),
offset = "expected"
)
# Choropleth map: mean RR across all periods
sus_mod_plot_spacetime(fit, municipalities = shp, type = "rr_map")
# Choropleth for a single period (t = 3)
sus_mod_plot_spacetime(fit, municipalities = shp, type = "rr_map",
time_point = 3L)
# Faceted map
sus_mod_plot_spacetime(fit, municipalities = shp, type = "rr_map",
facet_time = TRUE)
# Temporal trend
sus_mod_plot_spacetime(fit, type = "temporal", lang = "en")
# Space-time interaction heatmap
sus_mod_plot_spacetime(fit, type = "interaction")
# Exceedance probability (requires climasus_spacetime_exceedance input)
exc <- sus_mod_spacetime_exceedance(fit, thresholds = c(1.0, 1.5, 2.0))
sus_mod_plot_spacetime(exc, municipalities = shp, type = "exceedance",
threshold = 1.5)
# Fixed-effect forest plot
sus_mod_plot_spacetime(fit, type = "coef", lang = "en")
} # }