plot,VGMSFH-method {vmsae}R Documentation

Plot VGMSFH Result

Description

This method plots spatial summaries of results from a VGMSFH object, including model estimates and comparisons with direct estimates.

Usage

## S4 method for signature 'VGMSFH'
plot(x, shp = NULL, var_idx = 1, type = "compare", verbose = TRUE)

Arguments

x

An object of class VGMSFH, containing posterior samples and direct estimates from the model.

shp

An sf object representing the spatial shapefile. If NULL, the function will automatically download a shapefile associated with the pretrained model.

var_idx

Integer. The index of the variable of interest (for multivariate models).

type

Character. The type of plot to generate. Options are:

  • "compare" – compare direct estimates and model-based estimates.

  • "estimate" – show the posterior mean and standard deviation of the model estimate.

verbose

Logical; if TRUE (default), prints error messages.

Details

The function provides spatial visualization of model results. It supports both univariate and multivariate response settings. When type = "compare", it generates side-by-side choropleth maps for the direct and model-based estimates. When type = "estimate", it plots the posterior mean and standard deviation of the VGMSFH model output.

If no shapefile is provided, a default geometry is loaded from the pretrained repository.

Value

A ggplot object. The plot is rendered to the active device.

Examples

library(vmsae)
library(sf)
example_model <- readRDS(system.file("example", "example_model.Rds", package = "vmsae"))
example_shp <- read_sf(system.file("example", "mo_county.shp", package = "vmsae"))
plot(example_model, shp = example_shp, type = "compare")
plot(example_model, shp = example_shp, type = "estimate", var_idx = 2)


[Package vmsae version 0.1.1 Index]