Rev 33627 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{anova.lm}\title{ANOVA for Linear Model Fits}\usage{\method{anova}{lm}(object, \dots)anova.lmlist(object, \dots, scale = 0, test = "F")}\alias{anova.lm}%\alias{anova.lm.null}\alias{anova.lmlist}\description{Compute an analysis of variance table for one or more linear model fits.}\arguments{\item{object, \dots}{objects of class \code{lm}, usually, a result of acall to \code{\link{lm}}.}\item{test}{a character string specifying the test statistic to beused. Can be one of \code{"F"}, \code{"Chisq"} or \code{"Cp"},with partial matching allowed, or \code{NULL} for no test.}\item{scale}{numeric. An estimate of the noise variance\eqn{\sigma^2}{sigma^2}. If zero this will be estimated from thelargest model considered.}}\details{Specifying a single object gives a sequential analysis of variancetable for that fit. That is, the reductions in the residual sum ofsquares as each term of the formula is added in turn are given in asthe rows of a table, plus the residual sum of squares.The table will contain F statistics (and P values) comparing themean square for the row to the residual mean square.If more than one object is specified, the table has a row for theresidual degrees of freedom and sum of squares for each model.For all but the first model, the change in degrees of freedom and sumof squares is also given. (This only make statistical sense if themodels are nested.) It is conventional to list the models fromsmallest to largest, but this is up to the user.Optionally the table can include test statistics. Normally theF statistic is most appropriate, which compares the mean square for arow to the residual sum of squares for the largest model considered.If \code{scale} is specified chi-squared tests can be used. Mallows'\eqn{C_p}{Cp} statistic is the residual sum of squares plus twice theestimate of \eqn{\sigma^2}{sigma^2} times the residual degrees of freedom.}\value{An object of class \code{"anova"} inheriting from class \code{"data.frame"}.}\note{Versions of \R prior to 1.2.0 based F tests on pairwise comparisons,and this behaviour can still be obtained by a direct call to\code{anovalist.lm}.}\section{Warning}{The comparison between two or more models will only be valid if theyare fitted to the same dataset. This may be a problem if there aremissing values and \R's default of \code{na.action = na.omit} is used,and \code{anova.lmlist} will detect this with an error.}\references{Chambers, J. M. (1992)\emph{Linear models.}Chapter 4 of \emph{Statistical Models in S}eds J. M. Chambers and T. J. Hastie, Wadsworth \& Brooks/Cole.}\seealso{The model fitting function \code{\link{lm}}, \code{\link{anova}}.\code{\link{drop1}} forso-called \sQuote{type II} anova where each term is dropped one at atime respecting their hierarchy.}\examples{## sequential tablefit <- lm(sr ~ ., data = LifeCycleSavings)anova(fit)## same effect via separate modelsfit0 <- lm(sr ~ 1, data = LifeCycleSavings)fit1 <- update(fit0, . ~ . + pop15)fit2 <- update(fit1, . ~ . + pop75)fit3 <- update(fit2, . ~ . + dpi)fit4 <- update(fit3, . ~ . + ddpi)anova(fit0, fit1, fit2, fit3, fit4, test="F")anova(fit4, fit2, fit0, test="F") # unconventional order}\keyword{regression}\keyword{models}