Skip to contents

Model the effect of between 0 and 2 categorical variables on taxa richness within a context. Highlight, based on thresholds, contexts where taxa richness is 'excessively' high or low.

Usage

make_effort_mod(
  df,
  context = "cell",
  cat_cols = NULL,
  threshold_lo = 0.05/2,
  threshold_hi = 0.05/2,
  use_family = rstanarm::neg_binomial_2(),
  ...
)

Arguments

df

Dataframe. Cleaned data specifying context.

context

Character. Column names that define context, usually a 'visit' to a 'cell'.

cat_cols

Character. Name of column(s) (0 to 2) specifying the categorical variables to model. Usually a taxonomic level (say, class) and a geographic level (say, IBRA Region). If NULL (default), model is y ~ 1.

threshold_lo, threshold_hi

Numeric between 0 and 1 specifying the threshold above/below which richness is excessively above or below 'normal' and should be filtered.

use_family

Passed to rstanarm::stan_glm family argument.

...

Other arguments passed to rstanarm::stan_glm (e.g. chains, iter).

Value

List of model outputs:

dat_exp

dataframe of data used in pre-model data exploration

mod

model object

mod_pred

dataframe resulting from rstanarm::posterior_predict

mod_resid

dataframe of residuals

mod_resid_plot

plot of residuals (ggplot object)

mod_res

dataframe of summarised mod_pred results

mod_plot

plot of distribution of credible values, faceted by any variables in the model

mod_cell_result

dataframe of all contexts with column keep indicating whether the context is outside acceptable taxa richness

mod_cell_tab

dataframe tabulating how many contexts were above and below the acceptable richness quantile thresholds