Try fitting all models that differ from the current model by dropping a single term, maintaining marginality.

This function is generic; there exist methods for classes lm and glm and the default method will work for many other classes.

dropterm (object, ...)

# S3 method for default
dropterm(object, scope, scale = 0, test = c("none", "Chisq"),
         k = 2, sorted = FALSE, trace = FALSE, ...)

# S3 method for lm
dropterm(object, scope, scale = 0, test = c("none", "Chisq", "F"),
         k = 2, sorted = FALSE, ...)

# S3 method for glm
dropterm(object, scope, scale = 0, test = c("none", "Chisq", "F"),
         k = 2, sorted = FALSE, trace = FALSE, ...)

Arguments

object

A object fitted by some model-fitting function.

scope

a formula giving terms which might be dropped. By default, the model formula. Only terms that can be dropped and maintain marginality are actually tried.

scale

used in the definition of the AIC statistic for selecting the models, currently only for lm, aov and glm models. Specifying scale asserts that the residual standard error or dispersion is known.

test

should the results include a test statistic relative to the original model? The F test is only appropriate for lm and aov models, and perhaps for some over-dispersed glm models. The Chisq test can be an exact test (lm models with known scale) or a likelihood-ratio test depending on the method.

k

the multiple of the number of degrees of freedom used for the penalty. Only k = 2 gives the genuine AIC: k = log(n) is sometimes referred to as BIC or SBC.

sorted

should the results be sorted on the value of AIC?

trace

if TRUE additional information may be given on the fits as they are tried.

...

arguments passed to or from other methods.

Value

A table of class "anova" containing at least columns for the change in degrees of freedom and AIC (or Cp) for the models. Some methods will give further information, for example sums of squares, deviances, log-likelihoods and test statistics.

Details

The definition of AIC is only up to an additive constant: when appropriate (lm models with specified scale) the constant is taken to be that used in Mallows' Cp statistic and the results are labelled accordingly.

References

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

See also

Examples

quine.hi <- aov(log(Days + 2.5) ~ .^4, quine) quine.nxt <- update(quine.hi, . ~ . - Eth:Sex:Age:Lrn) dropterm(quine.nxt, test= "F")
#> Single term deletions #> #> Model: #> log(Days + 2.5) ~ Eth + Sex + Age + Lrn + Eth:Sex + Eth:Age + #> Eth:Lrn + Sex:Age + Sex:Lrn + Age:Lrn + Eth:Sex:Age + Eth:Sex:Lrn + #> Eth:Age:Lrn + Sex:Age:Lrn #> Df Sum of Sq RSS AIC F Value Pr(F) #> <none> 64.099 -68.184 #> Eth:Sex:Age 3 0.97387 65.073 -71.982 0.60773 0.61125 #> Eth:Sex:Lrn 1 1.57879 65.678 -66.631 2.95567 0.08816 . #> Eth:Age:Lrn 2 2.12841 66.227 -67.415 1.99230 0.14087 #> Sex:Age:Lrn 2 1.46623 65.565 -68.882 1.37247 0.25743 #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
quine.stp <- stepAIC(quine.nxt, scope = list(upper = ~Eth*Sex*Age*Lrn, lower = ~1), trace = FALSE) dropterm(quine.stp, test = "F")
#> Single term deletions #> #> Model: #> log(Days + 2.5) ~ Eth + Sex + Age + Lrn + Eth:Sex + Eth:Age + #> Eth:Lrn + Sex:Age + Sex:Lrn + Age:Lrn + Eth:Sex:Lrn + Eth:Age:Lrn #> Df Sum of Sq RSS AIC F Value Pr(F) #> <none> 66.600 -72.597 #> Sex:Age 3 10.7959 77.396 -56.663 6.7542 0.0002933 *** #> Eth:Sex:Lrn 1 3.0325 69.632 -68.096 5.6916 0.0185476 * #> Eth:Age:Lrn 2 2.0960 68.696 -72.072 1.9670 0.1441822 #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
quine.3 <- update(quine.stp, . ~ . - Eth:Age:Lrn) dropterm(quine.3, test = "F")
#> Single term deletions #> #> Model: #> log(Days + 2.5) ~ Eth + Sex + Age + Lrn + Eth:Sex + Eth:Age + #> Eth:Lrn + Sex:Age + Sex:Lrn + Age:Lrn + Eth:Sex:Lrn #> Df Sum of Sq RSS AIC F Value Pr(F) #> <none> 68.696 -72.072 #> Eth:Age 3 3.0312 71.727 -71.768 1.8679 0.1383323 #> Sex:Age 3 11.4272 80.123 -55.607 7.0419 0.0002037 *** #> Age:Lrn 2 2.8149 71.511 -70.209 2.6020 0.0780701 . #> Eth:Sex:Lrn 1 4.6956 73.391 -64.419 8.6809 0.0038268 ** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
quine.4 <- update(quine.3, . ~ . - Eth:Age) dropterm(quine.4, test = "F")
#> Single term deletions #> #> Model: #> log(Days + 2.5) ~ Eth + Sex + Age + Lrn + Eth:Sex + Eth:Lrn + #> Sex:Age + Sex:Lrn + Age:Lrn + Eth:Sex:Lrn #> Df Sum of Sq RSS AIC F Value Pr(F) #> <none> 71.727 -71.768 #> Sex:Age 3 11.5656 83.292 -55.942 6.9873 0.0002147 *** #> Age:Lrn 2 2.9118 74.639 -69.959 2.6387 0.0752793 . #> Eth:Sex:Lrn 1 6.8181 78.545 -60.511 12.3574 0.0006052 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
quine.5 <- update(quine.4, . ~ . - Age:Lrn) dropterm(quine.5, test = "F")
#> Single term deletions #> #> Model: #> log(Days + 2.5) ~ Eth + Sex + Age + Lrn + Eth:Sex + Eth:Lrn + #> Sex:Age + Sex:Lrn + Eth:Sex:Lrn #> Df Sum of Sq RSS AIC F Value Pr(F) #> <none> 74.639 -69.959 #> Sex:Age 3 9.9002 84.539 -57.774 5.8362 0.0008944 *** #> Eth:Sex:Lrn 1 6.2988 80.937 -60.130 11.1396 0.0010982 ** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
house.glm0 <- glm(Freq ~ Infl*Type*Cont + Sat, family=poisson, data = housing) house.glm1 <- update(house.glm0, . ~ . + Sat*(Infl+Type+Cont)) dropterm(house.glm1, test = "Chisq")
#> Single term deletions #> #> Model: #> Freq ~ Infl + Type + Cont + Sat + Infl:Type + Infl:Cont + Type:Cont + #> Infl:Sat + Type:Sat + Cont:Sat + Infl:Type:Cont #> Df Deviance AIC LRT Pr(Chi) #> <none> 38.662 455.63 #> Infl:Sat 4 147.780 556.75 109.117 < 2.2e-16 *** #> Type:Sat 6 100.889 505.86 62.227 1.586e-11 *** #> Cont:Sat 2 54.722 467.69 16.060 0.0003256 *** #> Infl:Type:Cont 6 43.952 448.92 5.290 0.5072454 #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1