nested.Rd
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"
.
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.
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.
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
).
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.
fm <- lm(y ~ X1 + X2 + X3 + X4, data = Cement, na.action = na.fail)
ms <- dredge(fm)
#> Fixed term is "(Intercept)"
# filter out overly complex models according to the
# "nesting selection rule":
subset(ms, !nested(.)) # dot represents the ms table object
#> Global model call: lm(formula = y ~ X1 + X2 + X3 + X4, data = Cement, na.action = na.fail)
#> ---
#> Model selection table
#> (Intrc) X1 X2 X3 X4 df logLik AICc delta weight
#> 4 52.58 1.468 0.6623 4 -28.156 69.3 0.00 0.831
#> 10 103.10 1.440 -0.6140 4 -29.817 72.6 3.32 0.158
#> 15 203.60 -0.9234 -1.448 -1.5570 5 -29.734 78.0 8.73 0.011
#> 13 131.30 -1.200 -0.7246 4 -35.372 83.7 14.43 0.001
#> 7 72.07 0.7313 -1.008 4 -40.965 94.9 25.62 0.000
#> 9 117.60 -0.7382 3 -45.872 100.4 31.10 0.000
#> 3 57.42 0.7891 3 -46.035 100.7 31.42 0.000
#> 2 81.48 1.869 3 -48.206 105.1 35.77 0.000
#> 5 110.20 -1.256 3 -50.980 110.6 41.31 0.000
#> 1 95.42 2 -53.168 111.5 42.22 0.000
#> Models ranked by AICc(x)
# print model "4" and all models nested within it
nst <- nested(ms, indices = "row")
ms[c("4", nst[["4"]])]
#> Global model call: lm(formula = y ~ X1 + X2 + X3 + X4, data = Cement, na.action = na.fail)
#> ---
#> Model selection table
#> (Intrc) X1 X2 df logLik AICc delta weight
#> 4 52.58 1.468 0.6623 4 -28.156 69.3 0.00 1
#> 3 57.42 0.7891 3 -46.035 100.7 31.42 0
#> 2 81.48 1.869 3 -48.206 105.1 35.77 0
#> 1 95.42 2 -53.168 111.5 42.22 0
#> Models ranked by AICc(x)
ms$nested <- sapply(nst, paste, collapse = ",")
ms
#> Global model call: lm(formula = y ~ X1 + X2 + X3 + X4, data = Cement, na.action = na.fail)
#> ---
#> Model selection table
#> (Intrc) X1 X2 X3 X4 df logLik AICc delta weight
#> 4 52.58 1.468 0.6623 4 -28.156 69.3 0.00 0.566
#> 12 71.65 1.452 0.4161 -0.2365 5 -26.933 72.4 3.13 0.119
#> 8 48.19 1.696 0.6569 0.2500 5 -26.952 72.5 3.16 0.116
#> 10 103.10 1.440 -0.6140 4 -29.817 72.6 3.32 0.107
#> 14 111.70 1.052 -0.4100 -0.6428 5 -27.310 73.2 3.88 0.081
#> 15 203.60 -0.9234 -1.4480 -1.5570 5 -29.734 78.0 8.73 0.007
#> 16 62.41 1.551 0.5102 0.1019 -0.1441 6 -26.918 79.8 10.52 0.003
#> 13 131.30 -1.2000 -0.7246 4 -35.372 83.7 14.43 0.000
#> 7 72.07 0.7313 -1.0080 4 -40.965 94.9 25.62 0.000
#> 9 117.60 -0.7382 3 -45.872 100.4 31.10 0.000
#> 3 57.42 0.7891 3 -46.035 100.7 31.42 0.000
#> 11 94.16 0.3109 -0.4569 4 -45.761 104.5 35.21 0.000
#> 2 81.48 1.869 3 -48.206 105.1 35.77 0.000
#> 6 72.35 2.312 0.4945 4 -48.005 109.0 39.70 0.000
#> 5 110.20 -1.2560 3 -50.980 110.6 41.31 0.000
#> 1 95.42 2 -53.168 111.5 42.22 0.000
#> nested
#> 4 3,2,1
#> 12 4,10,9,3,11,2,1
#> 8 4,7,3,2,6,5,1
#> 10 9,2,1
#> 14 10,13,9,2,6,5,1
#> 15 13,7,9,3,11,5,1
#> 16 4,12,8,10,14,15,13,7,9,3,11,2,6,5,1
#> 13 9,5,1
#> 7 3,5,1
#> 9 1
#> 3 1
#> 11 9,3,1
#> 2 1
#> 6 2,5,1
#> 5 1
#> 1
#> Models ranked by AICc(x)