Skip to contents

Create a multi-panel figure with ratio estimate and uncertainty maps side by side.

Usage

plot_map_panel(x, newdata = NULL, ncol = 2, ...)

Arguments

x

A ratiod_fit object with spatial structure.

newdata

Optional data frame with prediction locations.

ncol

Number of columns in the grid. Default 2.

...

Additional arguments passed to plot_map().

Value

A patchwork object (if patchwork is installed) or a list of ggplots.

Examples

# \donttest{
# Twenty sites on a chain, each visited three times
set.seed(123)
n_sites <- 20
sites <- data.frame(site = factor(seq_len(n_sites)),
                    x = sort(runif(n_sites)), y = runif(n_sites))
df <- sites[rep(seq_len(n_sites), 3), ]
df$count <- rpois(nrow(df), lambda = 8)
df$effort <- rgamma(nrow(df), shape = 4, rate = 1)
df$elevation <- rnorm(nrow(df))
adj <- matrix(0, n_sites, n_sites)
for (i in 1:(n_sites - 1)) adj[i, i + 1] <- adj[i + 1, i] <- 1
fit <- tratio(
  count | effort ~ elevation,
  data = df,
  family = ratiod_poisson_gamma(),
  spatial = spatial_car(adj, group_var = "site"),
  mode = "laplace"
)
if (requireNamespace("ggplot2", quietly = TRUE) &&
    requireNamespace("patchwork", quietly = TRUE)) {
  plot_map_panel(fit, coords = df[, c("x", "y")], ncol = 1)
}

# }