% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/anova.ergm.R, R/anova.ergmlist.R
\name{anova.ergm}
\alias{anova.ergm}
\alias{anova.ergmlist}
\title{ANOVA for ERGM Fits}
\usage{
\method{anova}{ergm}(object, ..., eval.loglik = FALSE)

\method{anova}{ergmlist}(object, ..., eval.loglik = FALSE)
}
\arguments{
\item{object, ...}{objects of class \code{\link{ergm}}, usually, a result of a
call to \code{\link{ergm}}.}

\item{eval.loglik}{a logical specifying whether the log-likelihood will be
evaluated if missing.}
}
\value{
An object of class \code{"anova"} inheriting from class
\code{"data.frame"}.
}
\description{
Compute an analysis of variance table for one or more ERGM fits.
}
\details{
Specifying a single object gives a sequential analysis of variance table for
that fit.  That is, the reductions in the residual sum of squares as each
term of the formula is added in turn are given in the rows of a table, plus
the residual sum of squares.

The table will contain F statistics (and P values) comparing the mean square
for the row to the residual mean square.

If more than one object is specified, the table has a row for the residual
degrees of freedom and sum of squares for each model.  For all but the first
model, the change in degrees of freedom and sum of squares is also given.
(This only make statistical sense if the models are nested.)  It is
conventional to list the models from smallest to largest, but this is up to
the user.

If any of the objects do not have estimated log-likelihoods, produces an
error, unless \code{eval.loglik=TRUE}.
}
\section{Warning}{
 The comparison between two or more models will only be
valid if they are fitted to the same dataset. This may be a problem if there
are missing values and 's default of \code{na.action = na.omit} is used, and
\code{\link{anova.ergmlist}} will detect this with an error.
}

\examples{

data(molecule)
molecule \%v\% "atomic type" <- c(1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3)
fit0 <- ergm(molecule ~ edges)
anova(fit0)
fit1 <- ergm(molecule ~ edges + nodefactor("atomic type"))
anova(fit1)

fit2 <- ergm(molecule ~ edges + nodefactor("atomic type") +  gwesp(0.5,
  fixed=TRUE), eval.loglik=TRUE) # Note the eval.loglik argument.
anova(fit0, fit1)
anova(fit0, fit1, fit2)

}
\seealso{
The model fitting function \code{\link{ergm}}, \code{\link{anova}},
\code{\link{logLik.ergm}} for adding the log-likelihood to an existing
\code{\link[=ergm.object]{ergm}} object.
}
\keyword{models}
\keyword{regression}
