Learn R Programming

camtrapR (version 2.3.0)

plot_effects,commOccu-method: Plot Marginal Effects of Covariates

Description

Plot marginal effect plots (= response curves if covariates are continuous) for all species in a community (multi-species) occupancy model. Takes into account species-specific intercepts (if any). Currently only supports continuous covariates, not categorical covariates.

Usage

# S4 method for commOccu
plot_effects(
  object,
  mcmc.list,
  submodel = "state",
  response = "occupancy",
  draws = 1000,
  outdir,
  level = 0.95,
  keyword_quadratic = "_squared",
  ...
)

Value

A list of ggplot objects (one list item per covariate).

Arguments

object

commOccu object

mcmc.list

mcmc.list. Output of fit called on a commOccu object

submodel

character. Submodel to get plots for. Can be "det" (detection submodel) or "state" (occupancy submodel)

response

character. response type on y axis. Only relevant for submodel = "state". Default is "occupancy", can be set to "abundance" for Royle-Nichols models

draws

integer. Number of draws from the posterior to use when generating the plots. If fewer posterior samples than specified in draws are available, all posterior samples are used.

outdir

character. Directory to save plots to (optional)

level

numeric. Probability mass to include in the uncertainty interval.

keyword_quadratic

character. A suffix in covariate names in the model that indicates a covariate is a quadratic effect of another covariate which does not carry the suffix in its name (e.g. if the covariate is "elevation", the quadratic covariate would be "elevation_squared").

...

additional arguments for ggsave - only relevant if outdir is defined

Details

Users who wish to create their own visualizations can use the data stored in the ggplot output. It is accessed via e.g. output$covariate_name$data