Learn R Programming

glmbb (version 0.1)

glmbb: All Hierarchical Models for Generalized Linear Model

Description

Find all hierarchical models of specified GLM with information criterion (AIC, BIC, or AICc) within specified cutoff of minimum value. Use branch and bound algorithm so we do not have to fit all models.

Usage

glmbb(big, little = ~ 1, family = poisson, data,
    criterion = c("AIC", "AICc", "BIC"), cutoff = 10,
    trace = FALSE, ...)

Arguments

big
an object of class "formula" specifying the largest model to be considered. Model specified must be hierarchical. (See also glm and
little
a formula specifying the smallest model to be considered. The response may be omitted and if not omitted is ignored (the response is taken from big). Default is ~ 1. Model specified must be nested within the model sp
family
a description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See
data
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the models. If not found in data, the varia
criterion
a character string specifying the information criterion, must be one of "AIC" (Akaike Information Criterion, the default), "BIC" (Bayes Information Criterion) or "AICc" (AIC corrected for sample size).
cutoff
a nonnegative real number. This function finds all hierarchical models that are submodels of big and supermodels of little with information criterion less than or equal to the cutoff plus the minimum information crite
trace
logical. Emit debug info if TRUE.
...
additional named or unnamed arguments to be passed to stats{glm.fit}.

Value

  • An object of class "glmbb" containing at least the following components:
  • datathe model frame, a data frame containing all the variables.
  • littlethe argument little.
  • bigthe argument big.
  • criterionthe argument criterion.
  • cutoffthe argument cutoff.
  • enviran R environment object containing all of the fits done.
  • min.critthe minimum value of the criterion.

concept

  • model selection
  • AIC
  • BIC

Details

Typical value for big is something like foo ~ bar * baz * qux where foo is the response variable (or matrix when family is binomial or quasibinomial, see glm) and bar, baz, and qux are all the predictors that are considered for inclusion in models.

A model is hierarchical if it includes all lower-order interactions for each term. This is automatically what formulas with all variables connected by stars (*) do, like the example above. But other specifications are possible. For example, foo ~ (bar + baz + qux)^2 specifies the model with all main effects, and all two-way interactions, but no three-way interaction, and this is hierarchical.

A model $m_1$ is nested within a model $m_1$ if all terms in $m_1$ are also terms in $m_2$. The default little model ~ 1 is nested within every model except those specified to have no intercept by 0 + or some such (see link[stats]{formula}).

References

Hand, D. J. (1981) Branch and bound in statistical data analysis. The Statistician, 30, 1--13.

See Also

link[stats]{family}, link[stats]{formula}, link[stats]{glm},

Examples

Run this code
data(crabs)
gout <- glmbb(satell ~ (color + spine + width + weight)^3,
    criterion = "BIC", data = crabs)
summary(gout)

Run the code above in your browser using DataLab