The residuals are extracted from each lm component of object and arranged into a list with as many components as object, or combined into a single vector.

# S3 method for class 'lmList'
residuals(object, type, subset, asList, ...)

Arguments

object

an object inheriting from class "lmList", representing a list of lm objects with a common model.

subset

an optional character or integer vector naming the lm components of object from which the residuals are to be extracted. Default is NULL, in which case all components are used.

type

an optional character string specifying the type of residuals to be extracted. Options include "response" for the "raw" residuals (observed - fitted), "pearson" for the standardized residuals (raw residuals divided by the estimated residual standard error) using different standard errors for each lm fit, and "pooled.pearson" for the standardized residuals using a pooled estimate of the residual standard error. Partial matching of arguments is used, so only the first character needs to be provided. Defaults to "response".

asList

an optional logical value. If TRUE, the returned object is a list with the residuals split by groups; else the returned value is a vector. Defaults to FALSE.

...

some methods for this generic require additional arguments. None are used in this method.

Value

a list with components given by the residuals of each lm component of object, or a vector with the residuals for all lm components of object.

Author

José Pinheiro and Douglas Bates bates@stat.wisc.edu

See also

Examples

fm1 <- lmList(distance ~ age | Subject, Orthodont)
residuals(fm1)
#>           M01           M01           M01           M01           M02 
#>  1.100000e+00 -1.800000e+00  3.000000e-01  4.000000e-01  4.500000e-01 
#>           M02           M02           M02           M03           M03 
#> -1.000000e-01 -1.150000e+00  8.000000e-01  1.000000e+00 -1.000000e+00 
#>           M03           M03           M04           M04           M04 
#> -1.000000e+00  1.000000e+00 -6.000000e-01  1.050000e+00 -3.000000e-01 
#>           M04           M05           M05           M05           M05 
#> -1.500000e-01 -4.500000e-01  1.350000e+00 -1.350000e+00  4.500000e-01 
#>           M06           M06           M06           M06           M07 
#>  1.500000e-01 -2.000000e-01 -5.000000e-02  1.000000e-01  6.500000e-01 
#>           M07           M07           M07           M08           M08 
#> -9.500000e-01 -5.000000e-02  3.500000e-01  1.250000e+00 -2.000000e+00 
#>           M08           M08           M09           M09           M09 
#>  2.500000e-01  5.000000e-01  8.000000e-01 -3.650000e+00  4.900000e+00 
#>           M09           M10           M10           M10           M10 
#> -2.050000e+00  2.500000e-01 -7.500000e-01  7.500000e-01 -2.500000e-01 
#>           M11           M11           M11           M11           M12 
#>  3.500000e-01 -3.000000e-01 -4.500000e-01  4.000000e-01  2.500000e-01 
#>           M12           M12           M12           M13           M13 
#>  2.500000e-01 -1.250000e+00  7.500000e-01 -1.400000e+00  2.200000e+00 
#>           M13           M13           M14           M14           M14 
#> -2.000000e-01 -6.000000e-01 -8.000000e-01  1.150000e+00  1.000000e-01 
#>           M14           M15           M15           M15           M15 
#> -4.500000e-01  5.000000e-01 -2.500000e-01 -1.000000e+00  7.500000e-01 
#>           M16           M16           M16           M16           F01 
#>  6.500000e-01 -9.500000e-01 -5.000000e-02  3.500000e-01  7.500000e-01 
#>           F01           F01           F01           F02           F02 
#> -1.000000e+00 -2.500000e-01  5.000000e-01  4.000000e-01 -7.000000e-01 
#>           F02           F02           F03           F03           F03 
#>  2.000000e-01  1.000000e-01 -7.000000e-01  1.100000e+00 -1.000000e-01 
#>           F03           F04           F04           F04           F04 
#> -3.000000e-01  5.000000e-02  1.000000e-01 -3.500000e-01  2.000000e-01 
#>           F05           F05           F05           F05           F06 
#> -3.000000e-01  6.500000e-01 -4.000000e-01  5.000000e-02  5.551115e-17 
#>           F06           F06           F06           F07           F07 
#>  2.500000e-01 -5.000000e-01  2.500000e-01  1.500000e-01  5.000000e-02 
#>           F07           F07           F08           F08           F08 
#> -5.500000e-01  3.500000e-01  1.500000e-01 -2.000000e-01 -5.000000e-02 
#>           F08           F09           F09           F09           F09 
#>  1.000000e-01 -3.000000e-01  1.500000e-01  6.000000e-01 -4.500000e-01 
#>           F10           F10           F10           F10           F11 
#> -6.500000e-01  9.500000e-01  5.000000e-02 -3.500000e-01  1.500000e-01 
#>           F11           F11           F11 
#> -7.000000e-01  9.500000e-01 -4.000000e-01 
#> attr(,"label")
#> [1] "Residuals (mm)"