This function is used run all combinations of explanatory variables and rank them based on their AIC. Then the function averages the coefficients of the models that hold a certain amount of the model weight This function requires the packages 'AICcmodavg' and 'MuMIn'

AIC_avg(
  model,
  data = NULL,
  groups = NULL,
  response = NULL,
  x_vars = NULL,
  cum.weight = 0.95,
  table = FALSE,
  std = "none"
)

Arguments

model

A model object from lm() or glm().

data

The data frame that holds the data used in model.

groups

A data frame with 1 row that holds the groups names. For example, for introduced Anolis lizards groups = data.frame(Genus = 'Anolis', Status = 'I')

cum.weight

A number equal to the cumulative weight of the models to be averaged.

table

Logical. If true a list is returned with the averaged coefficients in the first element and the AIC tables for each full model in the second element.

std

Value passed to dredge and model.avg to indicate whether and how the coefficients are standardized, and must be one of "none", "sd" or "partial.sd". "sd" standardizes the coefficients by the standard deviation, and "partial.sd" standardizes the coefficients by the partial standard deviation (recommended if multicollinearity is present among the predictors).

Value

A data frame with the estimates and their 95 percent confidence interval of the averaged models for each model in x. If table = TRUE then a list is returned with the second slot holding the complete AIC tables for each model in x.

Examples

if (FALSE) {

library(MuMIn)
library(AICcmodavg)

## lm.sr is an object returned from sr.LM()
dat <- lm.sr[['Data']][['Anolis.N']]
out <- AIC_avg(lm.sr[['Models']][['Anolis.N']],
               data = dat,
               response = 'Anolis.N',
               x_vars = c(vars, 'sq_Area'),
               groups = data.frame(Genus = 'Anolis',
                                   Status = 'N'),
               cum.weight = 0.95,
               table = FALSE)

}