Plot site occupancy and detection rates
plot_sites.RdPlots species-level occupancy and detection rates combining site predictors
(if included via make_data()) and site random effects (iota).
Usage
plot_sites(
fit,
species = NULL,
sites = NULL,
map = TRUE,
intercepts = TRUE,
back_transform = TRUE,
include_predictors = TRUE,
restricted = TRUE,
ndraws = NULL,
seed = NULL,
...
)Arguments
- fit
A fitted model object from
fit_model().- species
character. Vector of species to plot. IfNULL(default), all species are plotted. Must be one ofattr(occARU_data, "species").- sites
character. Vector of sites to plot. IfNULL(default), all sites are plotted. Must be one ofattr(occARU_data, "sites").- map
logical. IfTRUE(default), plot site effects summarised with posterior medians on a map using UTM coordinates. Requires site coordinates to have been supplied tomake_data(). IfFALSE, or if no coordinates are present, site effects are plotted withggdist::stat_pointinterval().- intercepts
logical. IfTRUE(default), species-level baseline log detection rates are added to the site effects. IfFALSE, only the site deviations are plotted on the log scale.- back_transform
logical. Only used whenintercepts = TRUE. IfTRUE(default), log detection rates are back-transformed to the natural scale viaexp(). IfFALSE, values are left on the log scale.- include_predictors
logical. IfTRUE(default), includes predictors in the site effects, if included. IfFALSE, only plots the random effects.- restricted
logical. IfTRUE(default), wheninclude_predictorsisFALSE, plots random site effects with orthogonal projection, i.e., \(\boldsymbol{\iota}(\boldsymbol{I} - \boldsymbol{P_{X_2}})\), where \(\boldsymbol{I} - \boldsymbol{P_{X_2}}\) is the orthogonal complement of the column space of the site design matrix. IfFALSE, plots random effects without orthogonal projection, i.e., \(\boldsymbol{\iota}\) only. Has no effect wheninclude_predictorsisTRUEas the linear predictor is unaffected by orthogonal projection.- 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
ndrawsis notNULL. Default: random integer.- ...
Additional arguments passed to
ggplot2::geom_point()whenmap = TRUEandggdist::stat_pointinterval()whenmap = FALSE.
Value
A ggplot object with occARU-specific attributes attached:
plot_dataThe 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 fit_model(), 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[s, i])).