nested: Identify nested models

nestedR Documentation

Identify nested models


Find models that are ‘nested’ within each model in the model selection table.


nested(x, indices = c("none", "numeric", "rownames"), rank = NULL)



a "model.selection" object (result of dredge or model.sel).


if omitted or "none" then the function checks if, for each model, there are any higher ranked models nested within it. If "numeric" or "rownames", indices or names of all nested models are returned. See “Value”.


the name of the column with the ranking values (defaults to the one before “delta”). Only used if indices is "none".


In model comparison, a model is said to be “nested” within another model if it contains a subset of parameters of the latter model, but does not include other parameters (e.g. model ‘A+B’ is nested within ‘A+B+C’ but not ‘A+C+D’).

This function can be useful in a model selection approach suggested by Richards (2008), in which more complex variants of any model with a lower IC value are excluded from the candidate set.


A vector of length equal to the number of models (table rows).

If indices = "none" (the default), it is a vector of logical values where i-th element is TRUE if any model(s) higher up in the table are nested within it (i.e. if simpler models have lower IC pointed by rank).

For indices other than "none", the function returns a list of vectors of numeric indices or names of models nested within each i-th model.


This function determines nesting based only on fixed model terms, within groups of models sharing the same ‘varying’ parameters (see dredge and example in Beetle).


Kamil Bartoń


Richards, S. A., Whittingham, M. J., Stephens, P. A. 2011 Model selection and model averaging in behavioural ecology: the utility of the IT-AIC framework. Behavioral Ecology and Sociobiology 65, 77–89.

Richards, S. A. 2008 Dealing with overdispersed count data in applied ecology. Journal of Applied Ecology 45, 218–227.

See Also

dredge, model.sel


fm <- lm(y ~ X1 + X2 + X3 + X4, data = Cement, na.action =
ms <- dredge(fm)

# filter out overly complex models according to the 
# "nesting selection rule":
subset(ms, !nested(.)) # dot represents the ms table object

# print model "4" and all models nested within it
nst <- nested(ms, indices = "row")
ms[c("4", nst[["4"]])]

ms$nested <- sapply(nst, paste, collapse = ",")


MuMIn documentation built on March 31, 2023, 8:33 p.m.