\HeaderA{anova.gam}{Hypothesis tests related to  GAM fits}{anova.gam}
\aliasA{print.anova.gam}{anova.gam}{print.anova.gam}
\keyword{models}{anova.gam}
\keyword{smooth}{anova.gam}
\keyword{regression}{anova.gam}
\begin{Description}\relax
Performs hypothesis tests relating to one or more fitted
\code{gam} objects. For a single fitted \code{gam} object, Wald tests of
the significance of each parametric and smooth term are performed. Otherwise
the fitted models are compared using an analysis of deviance table. The tests
are usually approximate, unless the models are un-penalized. Simulation evidence 
suggests that best p-value performance results from using ML estimated smoothing parameters.
\end{Description}
\begin{Usage}
\begin{verbatim}
## S3 method for class 'gam':
anova(object, ..., dispersion = NULL, test = NULL,
                    alpha = 0, freq = FALSE)
## S3 method for class 'anova.gam':
print(x, digits = max(3, getOption("digits") - 3),...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object,...}] fitted model objects of class \code{gam} as produced by \code{gam()}.
\item[\code{x}] an \code{anova.gam} object produced by a single model call to \code{anova.gam()}.
\item[\code{dispersion}] a value for the dispersion parameter: not normally used.
\item[\code{test}] what sort of test to perform for a multi-model call. One of
\code{"Chisq"}, \code{"F"} or \code{"Cp"}. 
\item[\code{alpha}] adjustment to degrees of freedom per estimated smoothing parameter for a 
term when called with a single model object. See \code{\LinkA{summary.gam}{summary.gam}} for details.
\item[\code{freq}] whether to use frequentist or Bayesian approximations for single smooth term 
p-values. See \code{\LinkA{summary.gam}{summary.gam}} for details.
\item[\code{digits}] number of digits to use when printing output.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If more than one fitted model is provided than \code{anova.glm} is
used. If only one model is provided then the significance of each model term
is assessed using Wald tests: see \code{\LinkA{summary.gam}{summary.gam}} for details of the
actual computations.
In the latter case \code{print.anova.gam} is used as the
printing method.  Note that the p-values for smooth terms are approximate only:
simulation evidence suggests that they work best with REML or ML smoothness selection.
\end{Details}
\begin{Value}
In the multi-model case \code{anova.gam} produces output identical to
\code{\LinkA{anova.glm}{anova.glm}}, which it in fact uses.

In the single model case an object of class \code{anova.gam} is produced,
which is in fact an object returned from \code{\LinkA{summary.gam}{summary.gam}}.

\code{print.anova.gam} simply produces tabulated output.
\end{Value}
\begin{Section}{WARNING}
P-values for smooth terms are only approximate.
\end{Section}
\begin{Author}\relax
Simon N. Wood \email{simon.wood@r-project.org} with substantial
improvements by Henric Nilsson.
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{gam}{gam}}, \code{\LinkA{predict.gam}{predict.gam}},
\code{\LinkA{gam.check}{gam.check}}, \code{\LinkA{summary.gam}{summary.gam}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
library(mgcv)
set.seed(0)
dat <- gamSim(5,n=200,scale=2)

b<-gam(y ~ x0 + s(x1) + s(x2) + s(x3),data=dat)
anova(b)
b1<-gam(y ~ x0 + s(x1) + s(x2),data=dat)
anova(b,b1,test="F")
\end{ExampleCode}
\end{Examples}

