ModelCompare: Model selection tool for multiple groups

View source: R/ModelCompare.R

ModelCompareR Documentation

Model selection tool for multiple groups

Description

This function allows users to input a list/vector of groups (taxonomic or otherwise), each of which has multiple candidate models generated with glmmTMB, and quickly attain AIC tables for each group. Group names supplied to the Groups argument are used as text patterns supplied to ls as pattern argument values, and model objects in the global environment containing the supplied group names are compared via AIC.

Usage

ModelCompare(Groups, TopModOutName)

Arguments

Groups

A character vector of groups (e.g. species, demographics), each with two or more candidate models to be compared. Because the values supplied for this argument are essentially used as regular expression text patterns to search the global environment, model object names must contain a value supplied to this argument to be included in the comparisons.

TopModOutName

An unquoted string used as the object name for the resultant data table showing the top model for each group supplied to the Groups argument.

Value

This function produces n+1 data tables, with n being the number of groups supplied to the Groups argument with corresponding glmmTMB class objects in the global environment. A data table detailing each model in a group and its AIC value is produced for each group. Each of these data tables is named with the group name followed by "AIC" (e.g., the data table associated with a group named "Epfu" would be named "EpfuAIC"). An additional data table is produced detailing the top model for each group. The data table of top models is named with the value supplied to the TopModOutName argument. If a group name is provided to the "Groups" argument that does not have a glmmTMB class object associated with it, a warning mesasge is generated.

Examples

data("Epfu_Nb1_Long", "Epfu_Nb2_Long", "Myev_Nb1_Long",
      "Myev_Nb2_Long", package = "EcoCountHelper")
      
Species <- c("Epfu", "Myev")
ModelCompare(Species, TestCompare)

EpfuAIC
MyevAIC
TestCompare


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