\Header{add1}{Add or Drop All Possible Single Terms to a Model}
\alias{add1.default}{add1}
\alias{add1.lm}{add1}
\alias{add1.glm}{add1}
\alias{add1.mlm}{add1}
\alias{drop1}{add1}
\alias{drop1.default}{add1}
\alias{drop1.lm}{add1}
\alias{drop1.glm}{add1}
\alias{drop1.mlm}{add1}
\keyword{models}{add1}
\begin{Usage}
\begin{verbatim}
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, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{object}] a fitted models object.
\item[\texttt{scope}] a formula giving the terms to be considered for adding or
dropping.
\item[\texttt{scale}] an estimate of the residual mean square to be used in
computing Cp. Ignored if \texttt{0} or \texttt{NULL}.
\item[\texttt{test}] should the results include a test statistic relative to the
original model?  The F test is only appropriate for \texttt{\Link{lm}} and
\texttt{\Link{aov}} models. The \eqn{\chi^2}{Chisq} test can be an exact test
(\texttt{lm} models with known scale) or a likelihood-ratio test depending
on the method.
\item[\texttt{k}] the penalty constant in AIC/Cp.
\item[\texttt{trace}] if \texttt{TRUE}, print out progress reports.
\item[\texttt{x}] a model matrix containing columns for the fitted model and all
terms in the upper scope.  Useful if \texttt{add1} is to be called
repeatedly.
\item[\texttt{all.cols}] (Provided for compatibility with S.) Logical to specify
whether all columns of the design matrix should be used. If
\texttt{FALSE} then non-estimable columns are dropped, but the result
is not usually statistically meaningful.
\end{ldescription}
\end{Arguments}
\begin{Description}
Compute all the single terms in the \texttt{scope} argument that can be
added to or dropped from the model, fit those models and compute a
table of the changes in fit.\end{Description}
\begin{Details}
For \texttt{drop} methods, a missing \texttt{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 \texttt{\Link{lm}} and \texttt{\Link{glm}} are more
efficient in that they do not recompute the model matrix and call the
\texttt{fit} methods directly.

The default output table gives AIC, defined as minus twice log
likelihood plus \eqn{2p}{} where \eqn{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,
\eqn{RSS/scale + 2p - n}{}.  Where Cp is used, the column is labelled as
Cp rather than AIC.\end{Details}
\begin{Value}
An object of class \texttt{"anova"} summarizing the differences in fit
between the models.\end{Value}
\begin{Note}
These are not fully equivalent to the functions in S.  There is no
\texttt{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.\end{Note}
\begin{Author}
B.D. Ripley\end{Author}
\begin{SeeAlso}
\texttt{\Link{step}}, \texttt{\Link{aov}}, \texttt{\Link{lm}},
\texttt{\Link{extractAIC}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
example(step)#-> swiss
(alm1 <- add1(lm1, ~ I(Education^2) + .^2))
\end{ExampleCode}
\end{Examples}

