Compute an analysis of robust Wald-type or deviance-type test tables for one or more linear regression models fitted by lmrob.

# S3 method for class 'lmrob'
anova(object, ..., test = c("Wald", "Deviance"),
      verbose = getOption("verbose"))

Arguments

object, ...

objects of class "lmrob", typically the result of a call to lmrob. ... arguments may also be symbolic descriptions of the reduced models (cf. argument formula in lm).

test

a character string specifying the test statistic to be used. Can be one of "Wald" or "Deviance", with partial matching allowed, for specifying a "Wald"-type test or "Deviance"-type test.

verbose

logical; if true some informative messages are printed.

Details

Specifying a single object gives a sequential analysis of a robust quasi-deviance table for that fit. That is, the reductions in the robust residual deviance as each term of the formula is added in turn are given in as the rows of a table. (Currently not yet implemented.)

If more than one object is specified, the table has a row for the residual quasi-degrees of freedom (however, this information is never used in the asymptotic tests). For all but the first model, the change in degrees of freedom and robust deviance is also given. (This only makes statistical sense if the models are nested.) As opposed to the convention, the models are forced to be listed from largest to smallest due to computational reasons.

In addition, the table will contain test statistics and P values comparing the reduction in robust deviances for the model on the row to that on top of it. There are two different robust tests available: The "Wald"-type test (test = "Wald") and the Deviance-type test (test = "Deviance"). When using formula description of the nested models in the dot arguments and test = "Deviance", you may be urged to supply a lmrob fit for these models by an error message. This happens when the coefficients of the largest model reduced to the nested models result in invalid initial estimates for the nested models (indicated by robustness weights which are all 0).

The comparison between two or more models by anova.lmrob will only be valid if they are fitted to the same dataset.

Value

Basically, an object of class anova inheriting from class data.frame.

Author

Andreas Ruckstuhl

See also

Examples

data(salinity)
summary(m0.sali  <- lmrob(Y ~ . , data = salinity))
#> Error in eval(predvars, data, env): object 'Y' not found
anova(m0.sali, Y ~ X1 + X3)
#> Error: object 'm0.sali' not found
## -> X2 is not needed
(m1.sali  <- lmrob(Y ~ X1 + X3, data = salinity))
#> Error in eval(predvars, data, env): object 'Y' not found
anova(m0.sali, m1.sali) # the same as before
#> Error: object 'm0.sali' not found
anova(m0.sali, m1.sali, test = "Deviance")
#> Error: object 'm0.sali' not found
## whereas 'X3' is highly significant:
m2 <- update(m0.sali, ~ . -X3)
#> Error: object 'm0.sali' not found
anova(m0.sali, m2)
#> Error: object 'm0.sali' not found
anova(m0.sali, m2,  test = "Deviance")
#> Error: object 'm0.sali' not found
## Global test [often not interesting]:
anova(m0.sali, update(m0.sali, . ~ 1), test = "Wald")
#> Error: object 'm0.sali' not found
anova(m0.sali, update(m0.sali, . ~ 1), test = "Deviance")
#> Error: object 'm0.sali' not found

if(require("MPV")) { ## Montgomery, Peck & Vining  datasets
  Jet <- table.b13
  Jet.rflm1 <- lmrob(y ~ ., data=Jet,
                     control = lmrob.control(max.it = 500))
  summary(Jet.rflm1)

  anova(Jet.rflm1, y ~ x1 + x5 + x6, test="Wald")

  try( anova(Jet.rflm1, y ~ x1 + x5 + x6, test="Deviance") )
  ## -> Error in anovaLm....  Please fit the nested models by lmrob

  ## {{ since  all robustness weights become 0 in the nested model ! }}

  ## Ok: Do as the error message told us:
  ##    test by comparing the two *fitted* models:

  Jet.rflm2 <- lmrob(y ~ x1 + x5 + x6, data=Jet,
                     control=lmrob.control(max.it=100))
  anova(Jet.rflm1, Jet.rflm2, test="Deviance")

} # end{"MPV" data}
#> Loading required package: MPV
#> Loading required package: lattice
#> 
#> Attaching package: ‘lattice’
#> The following object is masked from ‘package:boot’:
#> 
#>     melanoma
#> Loading required package: KernSmooth
#> KernSmooth 2.23 loaded
#> Copyright M. P. Wand 1997-2009
#> 
#> Attaching package: ‘MPV’
#> The following object is masked from ‘package:boot’:
#> 
#>     motor
#> Error in anovaLmrobPair(obj0, modform[[k - 1]], initCoef[[k - 1]], test = test) : 
#>   Please fit the nested models by lmrob
#> Robust Deviance Table
#> 
#> Model 1: y ~ x1 + x2 + x3 + x4 + x5 + x6
#> Model 2: y ~ x1 + x5 + x6
#> Largest model fitted by lmrob(), i.e. SM
#> 
#>   pseudoDf Test.Stat Df Pr(>chisq)
#> 1       33                        
#> 2       36     5.544  3      0.136