

   add1 {base}                                  R Documentation

   AAdddd oorr DDrroopp AAllll PPoossssiibbllee SSiinnggllee TTeerrmmss ttoo aa MMooddeell

   DDeessccrriippttiioonn::

        Compute all the single terms in the `scope' argument
        that can be added to or dropped from the model, fit
        those models and compute a table of the changes in fit.

   UUssaaggee::

        add1(object, scope, ...)
        add1.default(object, scope, scale = 0, test=c("none", "Chisq"),
                     k = 2, trace = FALSE, ...)
        add1.lm(object, scope, scale = 0, test=c("none", "Chisq", "F"),
                x = NULL, k = 2, ...)
        add1.glm(object, scope, scale = 0, x = NULL, test=c("none", "Chisq"),
                 k = 2, ...)

        drop1(object, scope, ...)
        drop1.default(object, scope, scale = 0, test=c("none", "Chisq"),
                      k = 2, trace = FALSE, ...)
        drop1.lm(object, scope, scale = 0, all.cols = TRUE,
                 test=c("none", "Chisq", "F"),k = 2, ...)
        drop1.glm(object, scope, scale = 0, test=c("none", "Chisq"),
                  k = 2, ...)

   AArrgguummeennttss::

     object: a fitted models object.

      scope: a formula giving the terms to be considered for
             adding or dropping.

      scale: an estimate of the residual mean square to be used
             in computing Cp. Ignored if `0' or `NULL'.

       test: should the results include a test statistic rela-
             tive to the original model?  The F test is only
             appropriate for `lm' and `aov' 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 penalty constant in AIC/Cp.

      trace: if `TRUE', print out progress reports.

          x: a model matrix containing columns for the fitted
             model and all terms in the upper scope.  Useful if
             `add1' is to be called repeatedly.

   all.cols: (Provided for compatibility with S.) Logical to
             specify whether all columns of the design matrix
             should be used. If `FALSE' then non-estimable
             columns are dropped, but the result is not usually
             statistically meaningful.

   DDeettaaiillss::

        For `drop' methods, a missing `scope' is taken to be
        all terms in the model. The hierarchy is respected when
        considering terms to be added or dropped: all main
        effects contained in a second-order interaction must
        remain, and so on.

        The methods for `lm' and `glm' are more efficient in
        that they do not recompute the model matrix and call
        the `fit' methods directly.

        The default output table gives AIC, defined as minus
        twice log likeliihood plus 2p where p is the rank of
        the model (the number of effective parameters).  This
        is only defined up to an additive constant (like log-
        likelhoods).  For linear Gaussian models with fixed
        scale, the constant is chosen to give Mallows' Cp,
        RSS/scale + 2p - n.  Where Cp is used, the column is
        labelled as Cp rather than AIC.

   VVaalluuee::

        An object of class `"anova"' summarizing the differ-
        ences in fit between the models.

   NNoottee::

        These are not fully equivalent to the functions in S.
        There is no `keep' argument, and the methods used are
        not quite so computationally efficient.

        Their authors' definitions of Mallows' Cp and Akaike's
        AIC are used, not those of the authors of the models
        chapter of S.

   AAuutthhoorr((ss))::

        B.D. Ripley

   SSeeee AAllssoo::

        `step', `aov', `lm', `extractAIC'.

   EExxaammpplleess::

        example(step)#-> swiss
        (alm1 <- add1(lm1, ~ I(Education^2) + .^2))

