Skip to contents

Plots species-level occupancy and detection rates combining site predictors (if included via make_data()) and site random effects (iota).

Usage

plot_sites(
  fit,
  map = TRUE,
  intercepts = TRUE,
  back_transform = TRUE,
  include_predictors = TRUE,
  species = NULL,
  sites = NULL,
  regions = NULL,
  seasons = NULL,
  ndraws = NULL,
  seed = NULL,
  ...
)

Arguments

fit

A fitted model object from occARU().

map

logical. If TRUE (default), plot site effects summarised with posterior medians on a map using UTM coordinates. Requires site coordinates to have been supplied to make_data(). If FALSE, or if no coordinates are present, site effects are plotted with ggdist::stat_pointinterval().

intercepts

logical. If TRUE (default), species-level baseline log detection rates are added to the site effects. If FALSE, only the site deviations are plotted on the log scale.

back_transform

logical. Only used when intercepts = TRUE. If TRUE (default), log detection rates are back-transformed to the natural scale via exp(). If FALSE, values are left on the log scale.

include_predictors

logical. If TRUE (default), includes predictors in the site effects, if included. If FALSE, only plots the random effects.

species

character. Vector of species to plot. If NULL (default), all species are plotted. Must be one of attr(occARU_data, "species").

sites

character. Vector of sites to plot. If NULL (default), all sites are plotted. Must be one of attr(occARU_data, "sites").

regions

character. Vector of regions to plot. If NULL (default), all regions are plotted. Must be one of attr(occARU_data, "regions").

seasons

character. Vector of seasons to plot. If NULL (default), all seasons are plotted. Must be one of attr(occARU_data, "seasons").

ndraws

Positive integerish. Number of draws to use for plotting, passed to tidybayes::spread_rvars(). Default: NULL (uses all draws).

seed

Positive numeric. Seed to use when subsampling draws when ndraws is not NULL. Default: random integer.

...

Additional arguments passed to ggplot2::geom_point() when map = TRUE and ggdist::stat_pointinterval() when map = FALSE.

Value

A ggplot object with occARU-specific attributes attached:

plot_data

The tibble used to produce the plot.

Details

If map = TRUE and site coordinates are present in the fitted object, effects are displayed as points sized by the magnitude of the detection rate on a map; otherwise site effects are plotted as point-intervals. When latent = TRUE was set in occARU(), sites with median posterior occupancy of 0 are shown as red crosses. When latent = FALSE, detection rates are weighted by occupancy probability (inv_logit(logit_psi[i, s])).