The residuals for the linear model represented by object are extracted.

# S3 method for class 'gls'
residuals(object, type, ...)

Arguments

object

an object inheriting from class "gls", representing a generalized least squares fitted linear model, or from class gnls, representing a generalized nonlinear least squares fitted linear model.

type

an optional character string specifying the type of residuals to be used. If "response", the "raw" residuals (observed - fitted) are used; else, if "pearson", the standardized residuals (raw residuals divided by the corresponding standard errors) are used; else, if "normalized", the normalized residuals (standardized residuals pre-multiplied by the inverse square-root factor of the estimated error correlation matrix) are used. Partial matching of arguments is used, so only the first character needs to be provided. Defaults to "response".

...

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

Value

a vector with the residuals for the linear model represented by object.

Author

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

See also

Examples

fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
           correlation = corAR1(form = ~ 1 | Mare))
residuals(fm1)
#>            1            2            3            4            5            6 
#>   6.27573063   2.04027463   6.86503938   4.68320654   2.42849305   0.04052024 
#>            7            8            9           10           11           12 
#>   2.46970493   4.68127816   3.65809863  10.40204413  11.93385973   4.29147301 
#>           13           14           15           16           17           18 
#>   6.52692900   4.70216334   0.88399710   4.13871134  -0.47331660   1.09749871 
#>           19           20           21           22           23           24 
#>   1.88592548   2.90910501   3.16515951   2.63334391   0.27573063  -0.95972537 
#>           25           26           27           28           29           30 
#>  -0.13495971   2.68320654  -0.57150013   1.04051908   6.46970779  -7.93241312 
#>           31           32           33           34           35           36 
#>  -7.11953759  -4.21825648  -4.31679346   5.49660997   0.14233223   3.55716553 
#>           37           38           39           40           41           42 
#>  -0.29949692  -2.44168598  -3.85548321  -2.50038324  -3.31325878  -6.21453989 
#>           43           44           45           46           47           48 
#>  -5.11600290  -6.92940633  -5.57512859  -8.98996189 -11.13329944  -9.99111038 
#>           49           50           51           52           53           54 
#>  -6.57731315  -2.93241312  -0.11953759  -2.21825648  -5.31679346  -3.50339003 
#>           55           56           57           58           59           60 
#>  -3.85766777  -4.44283447  -1.04725655  -2.21074789  -2.26648413  -5.31679346 
#>           61           62           63           64           65           66 
#>  -2.46458894  -3.80221972  -0.40146518  -0.30575152   0.47454816  -2.03675818 
#>           67           68           69           70           71           72 
#>   3.21573748   1.31304069   1.35296935   2.43956375   5.67180565   6.13289361 
#>           73           74           75           76           77           78 
#>   9.88122735   7.94407788   4.31463513   7.95274345   2.78925211   8.73351551 
#>           79           80           81           82           83           84 
#>   7.68320654   9.53541722   7.19777823  14.59853627  -4.72426937  -3.95972537 
#>           85           86           87           88           89           90 
#>  -5.13496062  -5.31679346  -3.57150695  -3.95947976  -8.53029507  -8.31872184 
#>           91           92           93           94           95           96 
#>  -8.34190137  -4.59795587  -4.06614027  -7.70852699  -6.47307100  -9.29783666 
#>           97           98           99          100          101          102 
#>  -7.11600290  -5.86128866  -8.47331660  -9.90250129  -9.11407452  -7.09089499 
#>          103          104          105          106          107          108 
#>  -3.83484049  -0.36665609  -5.72426937  -3.95972537  -2.13495971  -4.31679346 
#>          109          110          111          112          113          114 
#>  -3.57150013  -3.95948092   1.46970779  -3.72426937  -0.95972537  -0.13496062 
#>          115          116          117          118          119          120 
#>   5.68320654  -1.57150695   0.04052024  -6.53029507   2.68127816   3.65809863 
#>          121          122          123          124          125          126 
#>  -0.59795587  -6.06614027  -3.70852699  -7.47307100  -0.29783666   0.88399710 
#>          127          128          129          130          131          132 
#>  -1.86128866   0.52668340   2.09749871  -0.11407452  -2.09089499   3.16515951 
#>          133          134          135          136          137          138 
#>   4.63334391  -0.72426937  -3.95972537  -0.13495971  -3.31679346  -0.57150013 
#>          139          140          141          142          143          144 
#>  -4.95948092   4.46970779   2.27573063   4.04027463   0.86503938   5.68320654 
#>          145          146          147          148          149          150 
#>   4.42849305  -0.95947976  -1.53029507  -4.31872184  -0.34190137  -1.59795587 
#>          151          152          153          154          155          156 
#>  -2.06614027   2.29147301   2.52692900   0.70216334   0.88399710   0.13871134 
#>          157          158          159          160          161          162 
#>  -3.47331660   2.09749871   5.88592548   5.90910501   6.16515951   5.63334391 
#>          163          164          165          166          167          168 
#>   3.27573063   5.04027463   9.86504029  -1.31679346   0.42849987   1.04051908 
#>          169          170          171          172          173          174 
#>   2.46970779   4.06758688  -0.11953759   1.78174352   0.68320654   0.49660997 
#>          175          176          177          178          179          180 
#>  -1.85766777  -4.44283447  -1.29949692   0.55831402   1.14451679  -0.50038324 
#>          181          182          183          184          185          186 
#>   0.68674122  -2.21453989  -4.11600290  -1.92940633  -0.57512859   1.01003811 
#>          187          188          189          190          191          192 
#>  -2.13329944  -3.99111038  -1.57731315  -0.93241312  -2.11953759  -1.21825648 
#>          193          194          195          196          197          198 
#>  -3.31679346   3.49660997  -5.85766777  -2.44283447  -0.54229940  -3.82467368 
#>          199          200          201          202          203          204 
#>   2.93440483   3.68320654   1.37070166  -2.04996158   0.38173623  -3.36362444 
#>          205          206          207          208          209          210 
#>  -0.30339714  -1.44168598   0.23093283  -4.26322883  -2.89049697   1.39187678 
#>          211          212          213          214          215          216 
#>  -0.36720064  -1.11600290   1.19650152   6.61716559  10.18546741   5.93082808 
#>          217          218          219          220          221          222 
#>   5.87060078   9.00888962   5.33627081   5.83043247   4.45770060   7.17532686 
#>          223          224          225          226          227          228 
#>   7.93440428   7.68320654   1.37070674  -3.04996563  -1.61826377  -4.16956753 
#>          229          230          231          232          233          234 
#>   0.68918858  -0.32005381  -1.31679346  -3.42203874   2.25628953   0.63637556 
#>          235          236          237          238          239          240 
#>  -1.32762532   0.35994499   4.73677117   3.87801506  -0.11274182   5.88399710 
#>          241          242          243          244          245          246 
#>   0.98924180   1.31091411  -0.06917192   1.89482896  -0.79274136   1.83043247 
#>          247          248          249          250          251          252 
#>   1.68918858  -1.32005454  -1.31679346  -3.42203238  -5.74371145  -1.36362330 
#>          253          254          255          256          257          258 
#>  -2.72426937   3.04027463   2.86503938   0.68320654   0.42849305  -3.95947976 
#>          259          260          261          262          263          264 
#>   1.46970493   2.68127816   1.65809863   6.40204413   4.93385973   0.29147301 
#>          265          266          267          268          269          270 
#>  -4.47307100   1.70216334   6.88399710   8.13871134   8.52668340   6.09749871 
#>          271          272          273          274          275          276 
#>   5.88592548   7.90910501   7.16515951   7.63334391   3.27573063   4.04027463 
#>          277          278          279          280          281          282 
#>   4.86504029   5.68320654   3.42849987   2.04051908   1.46970779  -4.93241312 
#>          283          284          285          286          287          288 
#>  -5.11953759  -4.21825648  -3.31679346  -2.50339003  -3.85766777  -2.44283447 
#>          289          290          291          292          293          294 
#>  -1.29949692   0.55831402   0.14451679   3.49961676   1.68674122  -4.21453989 
#>          295          296          297          298          299          300 
#>  -5.11600290  -5.92940633  -5.57512859   1.01003811  -3.13329944  -4.99111038 
#>          301          302          303          304          305          306 
#>  -2.57731315  -1.93241312  -4.11953759  -6.21825648  -2.31679346  -3.50339003 
#>          307          308 
#>  -4.85766777  -4.44283447 
#> attr(,"std")
#>   [1] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>   [9] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [17] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [25] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [33] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [41] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [49] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [57] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [65] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [73] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [81] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [89] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#>  [97] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [105] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [113] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [121] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [129] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [137] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [145] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [153] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [161] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [169] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [177] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [185] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [193] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [201] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [209] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [217] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [225] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [233] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [241] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [249] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [257] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [265] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [273] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [281] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [289] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [297] 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172 4.616172
#> [305] 4.616172 4.616172 4.616172 4.616172
#> attr(,"label")
#> [1] "Residuals"