Extract model residuals from objects of class "gtReg" returned by gtReg.

# S3 method for class 'gtReg'
residuals(object, type = c("deviance", "pearson", "response"), ...)

Arguments

object

An object of class "gtReg", created by gtReg, from which the model residuals are to be extracted.

type

The type of residuals which should be returned. Options include "deviance" (default), "pearson", and "response".

...

currently not used.

Value

Residuals of group responses extracted from the object object.

Author

This function was originally written by Boan Zhang as the residuals.gt function for the binGroup package.

Examples

data(hivsurv)
fit1 <- gtReg(formula = groupres ~ AGE * EDUC.,
              data = hivsurv, groupn = gnum,
              linkf = "probit")
residuals(object = fit1, type = "pearson")
#>          1          2          3          4          5          6          7 
#> -0.9055885 -0.6817337  1.0994452 -0.5926129 -0.9006457  0.8774835  1.1276576 
#>          8          9         10         11         12         13         14 
#> -0.6482013 -0.7618318 -0.7357126  1.3661232  1.3541500  1.7884858 -0.7328576 
#>         15         16         17         18         19         20         21 
#>  1.1157537  1.2634651  1.2844443 -0.6671900 -0.7178230 -0.7267928  1.3694189 
#>         22         23         24         25         26         27         28 
#> -0.6870413 -0.8456798 -0.8384433  1.1369704 -0.9417096 -0.7795163 -0.6209909 
#>         29         30         31         32         33         34         35 
#>  1.5214576  0.8789021 -1.0731765 -0.8810245 -0.6495203 -0.5918557 -0.6366881 
#>         36         37         38         39         40         41         42 
#>  0.8984665 -0.9218154 -0.5680544  1.1559158  1.6681266 -0.7010634 -0.7003694 
#>         43         44         45         46         47         48         49 
#> -0.6015539  1.4664130 -0.8279346 -0.8089442 -0.6028382  1.1730439 -0.8100753 
#>         50         51         52         53         54         55         56 
#>  1.4778378  1.0178694 -1.0440292  1.2268466 -0.7154452  1.3840737 -0.6508478 
#>         57         58         59         60         61         62         63 
#> -0.6385867 -0.7399243  1.3886819 -0.7003915 -0.6960409 -0.8384864 -0.5396091 
#>         64         65         66         67         68         69         70 
#> -0.7426180  1.2081364  1.3562852 -0.5801237 -0.8297057 -1.0657841 -0.5839336 
#>         71         72         73         74         75         76         77 
#> -0.5961649 -0.6379928 -0.8441386 -1.0441698 -0.6695771  1.2162844 -0.6066662 
#>         78         79         80         81         82         83         84 
#> -0.8610128  1.2729283  1.6970807 -0.6220974  1.7439897 -0.5727264  1.3236869 
#>         85         86 
#>  1.3304640 -0.5694523 
residuals(object = fit1, type = "deviance")
#>          1          2          3          4          5          6          7 
#> -1.0944279 -0.8737184  1.2589203 -0.7758681 -1.0899257  1.0686129  1.2810071 
#>          8          9         10         11         12         13         14 
#> -0.8375835 -0.9567343 -0.9301706  1.4512198  1.4433234  1.6939720 -0.9272375 
#>         15         16         17         18         19         20         21 
#>  1.2717420  1.3813793  1.3960538 -0.8581467 -0.9116946 -0.9209872  1.4533822 
#>         22         23         24         25         26         27         28 
#> -0.8793628 -1.0387634 -1.0318759  1.2882010 -1.1268463 -0.9744442 -0.8076567 
#>         29         30         31         32         33         34         35 
#>  1.5481649  1.0699285 -1.2379514 -1.0718942 -0.8390204 -0.7750120 -0.8249871 
#>         36         37         38         39         40         41         42 
#>  1.0879356 -1.1090961 -0.7478828  1.3026900  1.6312105 -0.8941762 -0.8934464 
#>         43         44         45         46         47         48         49 
#> -0.7859473  1.5149383 -1.0218100 -1.0034269 -0.7873903  1.3156229 -1.0045288 
#>         50         51         52         53         54         55         56 
#>  1.5219328  1.1924895 -1.2142179  1.3552488 -0.9092215  1.4629397 -0.8404652 
#>         57         58         59         60         61         62         63 
#> -0.8270710 -0.9344870  1.4659257 -0.8934696 -0.8888867 -1.0319169 -0.7149196 
#>         64         65         66         67         68         69         70 
#> -0.9372409  1.3416379  1.4447362 -0.7616913 -1.0235117 -1.2319790 -0.7660281 
#>         71         72         73         74         75         76         77 
#> -0.7798794 -0.8264194 -1.0372995 -1.2143337 -0.8607132  1.3475871 -0.7916842 
#>         78         79         80         81         82         83         84 
#> -1.0532395  1.3880249  1.6467280 -0.8088843  1.6712964 -0.7532407  1.4229415 
#>         85         86 
#>  1.4275125 -0.7494876