Anova {car}R Documentation

Anova Tables for Various Statistical Models

Description

Calculates type-II or type-III analysis-of-variance tables for model objects produced by lm, glm, multinom (in the nnet package), and polr (in the MASS package). For linear models, F-tests are calculated; for generalized linear models, likelihood-ratio chisquare, Wald chisquare, or F-tests are calculated; for multinomial logit and proportional-odds logit models, likelihood-ratio tests are calculated.

Usage

Anova(mod, ...)

## S3 method for class 'lm':
Anova(mod, error, type=c("II", "III"), ...)

## S3 method for class 'aov':
Anova(mod, ...)

## S3 method for class 'glm':
Anova(mod, type=c("II", "III"), test.statistic=c("LR", "Wald", "F"), 
    error, error.estimate=c("pearson", "dispersion", "deviance"), ...)
    
## S3 method for class 'multinom':
Anova(mod, type = c("II", "III"), ...)

## S3 method for class 'polr':
Anova(mod, type = c("II", "III"), ...)

Arguments

mod lm, aov, glm, multinom, or polr model object.
error for a linear model, an lm model object from which the error sum of squares and degrees of freedom are to be calculated. For F-tests for a generalized linear model, a glm object from which the dispersion is to be estimated. If not specified, mod is used.
type type of test, "II" or "III".
test.statistic for a generalized linear model, whether to calculate "LR" (likelihood-ratio), "Wald", or "F" tests.
error.estimate for F-tests for a generalized linear model, base the dispersion estimate on the Pearson residuals (pearson, the default); use the dispersion estimate in the model object (dispersion), which, e.g., is fixed to 1 for binomial and Poisson models; or base the dispersion estimate on the residual deviance (deviance).
... arguments to be passed to linear.hypothesis; only use white.adjust for a linear model.

Details

The designations "type-II" and "type-III" are borrowed from SAS, but the definitions used here do not correspond precisely to those employed by SAS. Type-II tests are calculated according to the principle of marginality, testing each term after all others, except ignoring the term's higher-order relatives; so-called type-III tests violate marginality, testing each term in the model after all of the others. This definition of Type-II tests corresponds to the tests produced by SAS for analysis-of-variance models, where all of the predictors are factors, but not more generally (i.e., when there are quantitative predictors). Be very careful in formulating the model for type-III tests, or the hypotheses tested will not make sense.

As implemented here, type-II Wald tests for generalized linear models are actually differences of Wald statistics.

For tests for linear models, and Wald tests for generalized linear models, Anova finds the test statistics without refitting the model.

The standard R anova function calculates sequential ("type-I") tests. These rarely test interesting hypotheses.

Value

An object of class anova, usually printed.

Warning

Be careful of type-III tests.

Author(s)

John Fox jfox@mcmaster.ca

References

Fox, J. (1997) Applied Regression, Linear Models, and Related Methods. Sage.

See Also

linear.hypothesis, anova

Examples

mod<-lm(conformity~fcategory*partner.status, data=Moore, 
  contrasts=list(fcategory=contr.sum, partner.status=contr.sum))
Anova(mod)
## Anova Table (Type II tests)
##
## Response: conformity
##                         Sum Sq Df F value   Pr(>F)
## fcategory                 11.61  2  0.2770 0.759564
## partner.status           212.21  1 10.1207 0.002874
## fcategory:partner.status 175.49  2  4.1846 0.022572
## Residuals                817.76 39                 
Anova(mod, type="III")
## Anova Table (Type III tests)
##
## Response: conformity
##                          Sum Sq Df  F value    Pr(>F)
## (Intercept)              5752.8  1 274.3592 < 2.2e-16
## fcategory                  36.0  2   0.8589  0.431492
## partner.status            239.6  1  11.4250  0.001657
## fcategory:partner.status  175.5  2   4.1846  0.022572
## Residuals                 817.8 39                   

[Package car version 1.1-0 Index]