map function

Map Relevant Quantities from a Small Area Model

Map Relevant Quantities from a Small Area Model

The map() function enables to plot maps containing relevant model outputs by accounting for their geographical dimension. The shapefile of the area must be provided via a SpatialPolygonsDataFrame or sf object.

map( x, spatial_df, spatial_id_domains, match_names = NULL, color_palette = c("snow2", "deepskyblue4"), quantity = c("HB_est", "Direct_est", "SD"), time = NULL, style = "quantile", ... )

Arguments

  • x: An object of class summary_fitsae or benchmark_fitsae.
  • spatial_df: A object of class SpatialPolygonsDataFrame (spatial polygons object) from sp package or sf from the sf package, accounting for the geographical dimension of the domains.
  • spatial_id_domains: A character string indicating the name of spatial_df variable containing area denominations, in order to correctly match the areas.
  • match_names: An encoding two-columns data.frame: the first with the original data coding (domains) and the second one with corresponding spatial_df object labels. This argument has to be specified only if spatial_df object labels do not match the ones provided through the original dataset.
  • color_palette: A vector with two color strings denoting the extreme bounds of colors range to be used.
  • quantity: A string indicating the quantity to be mapped. When a summary_fitsae is given as input, it can be selected among "HB_est" (model-based estimates), "SD"(posterior standard deviations) and "Direct_est"(direct estimates). While when a benchmark_fitsae class object is given as input, this argument turns automatically to "Bench_est", displaying the benchmarked estimates.
  • time: A string indicating the year of interest for the quantities to be treated, in case of temporal or spatio-temporal objects.
  • style: Method to process the color scale, see tmap documentation.
  • ...: Arguments passed to tm_fill (e.g. n, breaks).

Returns

Atmap object.

Examples

## Not run: library(tipsae) # loading toy dataset data("emilia_cs") # fitting a model fit_beta <- fit_sae(formula_fixed = hcr ~ x, data = emilia_cs, domains = "id", type_disp = "var", disp_direct = "vars", domain_size = "n", # MCMC setting to obtain a fast example. Remove next line for reliable results. chains = 1, iter = 150, seed = 0) # check model diagnostics summ_beta <- summary(fit_beta) # load shapefile of concerned areas data("emilia_shp") # plot the map using model diagnostics and areas shapefile map(x = summ_beta, spatial_df = emilia_shp, spatial_id_domains = "NAME_DISTRICT") ## End(Not run)

See Also

summary.fitsae to produce the input object and SpatialPolygonsDataFrame to manage the shapefile.

  • Maintainer: Silvia De Nicolò
  • License: GPL-3
  • Last published: 2024-09-13

Useful links