EffectsPlotter: Visualize model effects

View source: R/EffectsPlotter.R

EffectsPlotterR Documentation

Visualize model effects

Description

This function produces effects plots for the conditional model of model objects produced by glmmTMB. Effects can be plotted for multiple models in a single function call. These effects plots are based on those found in this document.

Usage

EffectsPlotter(
  TopMods,
  ParamLabs = NULL,
  ConfInts = c(90, 80),
  Scaled = T,
  ThemeBlack = T
)

Arguments

TopMods

This argument can accept multiple input types, and is used to specify which models effects plots should be generated for. If an effects plot is desired for a single model, users can supply the unquoted model object name. If effects plots for multiple models are desired, users can specify a chahracter vector of model names.

ParamLabs

A character vector of labels for each model estimate. Labels must be supplied for estimates in the same order as the vector returned by row.names(summary(x)$coeff$cond), where x is a model object name.

ConfInts

A numeric vector specifying up to three condifence intervals as percent values from largest to smallest (e.g., for 80%, 90%, and 95% confidence intervals, supply ConfInts = c(95, 90, 80)).

Scaled

A logical value indicating whether model estimates are scaled (T) or not (F). When Scaled = T, there will be a dotted geom_abline where estimates = 0.

ThemeBlack

A logical value indicating whether theme_nocturnal should be applied to plots (T) or not (F).

Value

This function generates effects plots using geom_point for point estimates and geom_crossbar for confidence intervals. Resultant plots are named with the model name followed by "EffectsPlot" (e.g., for a model named "EpfuNb2", the effects plot would be named "EpfuNb2EffectsPlot").

Details

Because all models specified in a call to this function share estimate labels, all models in a a given call to this function must have the same model formula.

Examples

data("Epfu_Nb2_Long", "Myev_Nb2_Long", package = "EcoCountHelper")
Labels <- letters[1:12]

#Effects plot for a single model

EffectsPlotter(Epfu_Nb2_Long, Labels)
Epfu_Nb2_LongEffectsPlot

#Effects plot for multiple models specified
#in a character vector.

Mods <- c("Epfu_Nb2_Long", "Myev_Nb2_Long")
EffectsPlotter(Mods, Labels)
Epfu_Nb2_LongEffectsPlot
Myev_Nb2_LongEffectsPlot

#Effects plot for multiple models specified
#in a data frame

ModTable <- data.frame(Species = c("Epfu", "Myev"),
                        Mods = c("Epfu_Nb2_Long", "Myev_Nb2_Long"))
                        
EffectsPlotter(ModTable$Mods, Labels)

Epfu_Nb2_LongEffectsPlot
Myev_Nb2_LongEffectsPlot


huntercole25/EcoCountHelper documentation built on Jan. 14, 2023, 4:13 a.m.