Skip to contents

Plots coefficients of continuous, categorical, or ordinal predictors on occupancy or detection submodels.

Usage

plot_coefficients(
  fit,
  submodel = c("detection", "occupancy"),
  component = c("site", "survey"),
  type = c("continuous", "categorical", "ordinal"),
  level = c("species", "mean"),
  facet_by = c("species", "predictor"),
  species = NULL,
  unconditional = FALSE,
  ordinal_categories = FALSE,
  ...
)

Arguments

fit

A fitted model object from occARU().

submodel

character. Predictors of submodel to plot. One of "detection" (default) or "occupancy".

component

character. Whether to plot "site" (default) or "survey" predictors. If "survey", submodel must be "detection".

type

character. Type of predictors to plot. One of "continuous" (default), "categorical", or "ordinal".

level

character. For multi-species models, whether to plot species-specific ("species", default) or mean coefficients ("mean").

facet_by

character. Whether to use ggplot2::facet_wrap() or ggh4x::facet_grid2() to facet by "predictor" (default) or "species". Only used if level is "species".

species

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

unconditional

logical. If TRUE, plot the unconditional regression coefficients, e.g., \(\boldsymbol{\beta} + (\boldsymbol{X}^\prime \boldsymbol{X})^{-1} \boldsymbol{X}^\prime \boldsymbol{\iota}\), which attribute variance shared between the fixed and random effects back to the covariates. If FALSE (default), plot the conditional coefficients \(\boldsymbol{\beta}\).

ordinal_categories

logical. If FALSE (default), plots coefficients associated with maximum category (full effect). If TRUE, plots realised coefficient associated with each ordered category, where the first is used as the reference.

...

Additional arguments passed to ggdist::stat_pointinterval().

Value

A ggplot object with occARU-specific attributes attached:

plot_data

The tibble used to produce the plot.

Details

occARU accommodates three types of predictors: continuous, categorical, and ordinal (ordered categorical). Categorical predictors are modeled as zero-sum Gaussians, and coefficients are plotted for each level in each predictor. Ordinal predictors are modeled with a simplex decomposition of the category differences. Ordinal coefficients can be plotted as the overall effect (coefficient when the ordinal predictor has the maximum value) or plotted for each level.