EffectsPlotter: Visualize model effects

Description Usage Arguments Value Details Examples

View source: R/EffectsPlotter.R

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

1
2
3
4
5
6
7
8
EffectsPlotter(
  TopMods,
  ParamLabs = NULL,
  TopModCol = 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 supply either the unquoted name of a character vector containing model object names, or the name of a data table or data frame containing a character vector of model object names. If using the latter option, be sure to provide a value to the TopModCol argument.

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.

TopModCol

A character string specifying the name of the column containing model object names in a data frame or data table. This argument should only be used if TopMods is supplied with the name of a data frame or data table such as the top model table returned by ModelCompare.

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_errorbar 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
data("EpfuNb2Long", "MyevNb2Long", package = "EcoCountHelper")
Labels <- letters[1:12]

#Effects plot for a single model

EffectsPlotter(EpfuNb2Long, Labels)
EpfuNb2LongEffectsPlot

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

Mods <- c("EpfuNb2Long", "MyevNb2Long")
EffectsPlotter(Mods, Labels)
EpfuNb2LongEffectsPlot
MyevNb2LongEffectsPlot

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

ModTable <- data.frame(Species = c("Epfu", "Myev"),
                        Mods = c("EpfuNb2Long", "MyevNb2Long"))
                        
EffectsPlotter(ModTable, Labels, "Mods")

EpfuNb2LongEffectsPlot
MyevNb2LongEffectsPlot

huntercole25/EcoCountHelper documentation built on July 21, 2020, 8:56 p.m.