
Visualizations for Bayesian Spatial Disease Mapping Results
Source:R/sus_mod_plot_spatial_bayes.R
sus_mod_plot_spatial_bayes.RdProduces three types of visualization for a climasus_spatial_bayes object
returned by sus_mod_spatial_bayes(): a relative risk choropleth map,
a credible interval width (uncertainty) choropleth, a forest plot of fixed
effects, or a combined panel of both maps.
Usage
sus_mod_plot_spatial_bayes(
x,
municipalities = NULL,
type = c("rr", "uncertainty", "coef", "both"),
title = NULL,
base_size = 12,
lang = "pt",
...
)Arguments
- x
A
climasus_spatial_bayesobject fromsus_mod_spatial_bayes().- municipalities
An
sfobject containing municipality polygons with acode_municolumn (7-digit IBGE code). Required fortype = "rr","uncertainty", and"both". Typically obtained viageobr::read_municipality().- type
Character. One of
"rr"(default),"uncertainty","coef", or"both". See Plot types.- title
Character or
NULL. Custom plot title. WhenNULL(default), a multilingual default is used.- base_size
Numeric. Base font size passed to ggplot2 themes. Default
12.- lang
Character. Language for axis labels and titles:
"pt"(default),"en", or"es".- ...
Currently unused; reserved for future arguments.
Value
For
type = "rr","uncertainty","coef": aggplotobject.For
type = "both": apatchworkobject when patchwork is installed, otherwise a named list with elements$rrand$uncertainty.
Plot types (type)
"rr"Choropleth map of the smoothed posterior mean relative risk (
rr_mean). Uses a diverging colour scale centred at 1.0 (navy = below, white = 1.0, red = above). Municipalities where the entire 95\ interval lies above 1 (rr_lower95 > 1) receive a black border to flag significantly elevated risk."uncertainty"Choropleth of the 95\ (
rr_upper95 - rr_lower95), rendered with the plasma palette fromggplot2::scale_fill_viridis_c(). Highlights areas with high posterior uncertainty, often due to small populations or sparse data."coef"Horizontal forest plot of the fixed-effect posterior summaries stored in
x$fixed. A dashed vertical reference line marks zero. Points show the posterior mean; horizontal bars show the 95\ credible interval."both"Side-by-side panel combining the
"rr"and"uncertainty"maps. Uses patchwork when available; falls back to a named list with$rrand$uncertaintyotherwise.
Examples
if (FALSE) { # \dontrun{
library(climasus4r)
library(geobr)
shp <- geobr::read_municipality(code_muni = "all", year = 2022)
W <- sus_mod_spatial_weights(shp, return_matrix = TRUE)
result <- sus_mod_spatial_bayes(
df = agg,
outcome = "deaths",
W = W,
covariates = c("temp_mean", "prec_total"),
offset = "expected_deaths"
)
# Relative risk map
sus_mod_plot_spatial_bayes(result, municipalities = shp, type = "rr")
# Uncertainty map
sus_mod_plot_spatial_bayes(result, municipalities = shp, type = "uncertainty")
# Forest plot of fixed effects
sus_mod_plot_spatial_bayes(result, type = "coef", lang = "en")
# Combined panel (requires patchwork)
sus_mod_plot_spatial_bayes(result, municipalities = shp, type = "both")
} # }