Currently three tests are performed - for outliers in residuals - for autocorrelation in target variable or in residuals - for trend in residuals as a function of target variable (detection of bias)

check_residuals(model, ...)

Arguments

model

An object of class `modelAudit`

...

other parameters that will be passed to further functions

Value

list with statistics for particualr checks

Examples

library(car)
#> Loading required package: carData
lm_model <- lm(prestige ~ education + women + income, data = Prestige) lm_au <- audit(lm_model, data = Prestige, y = Prestige$prestige) check_residuals(lm_au)
#> ----------------------------------------------- #> Checks for autocorrelation #> ----------------------------------------------- #> Model name: lm #> Autocorrelation in target: +0.69 *** #> Autocorrelation in residuals: +0.15 . #> ----------------------------------------------- #> Checks for outliers #> ----------------------------------------------- #> Model name: lm #> Shift > 1: 0 ( 0 %) #> Shift > 2: 0 ( 0 %) #> Top lowest standardised residuals: #> -2.5649 (53), -2.1354 (46), -1.8837 (54), -1.8557 (41), -1.7617 (61) #> Top highest standardised residuals: #> 2.2648 (67), 2.1225 (82), 2.0597 (29), 1.8916 (31), 1.8274 (27) #> ----------------------------------------------- #> Checks for trend in residuals #> ----------------------------------------------- #> Model name: lm #> Standardised loess fit: +7.32 .
library("DALEX2")
#> Welcome to DALEX2 (version: 0.9).
dragons <- DALEX2::dragons library("ranger")
#> #> Attaching package: ‘ranger’
#> The following object is masked from ‘package:randomForest’: #> #> importance
rf_model <- ranger(life_length ~ ., data = dragons) predict_function <- function(m,x,...) predict(m, x, ...)$predictions rf_au <- audit(rf_model, data = dragons, y = dragons$life_length, predict.function = predict_function) check_residuals(rf_au)
#> ----------------------------------------------- #> Checks for autocorrelation #> ----------------------------------------------- #> Model name: ranger #> Autocorrelation in target: +0.01 #> Autocorrelation in residuals: +0.01 #> ----------------------------------------------- #> Checks for outliers #> ----------------------------------------------- #> Model name: ranger #> Shift > 1: 21 ( 1.1 %) #> Shift > 2: 15 ( 0.8 %) #> Top lowest standardised residuals: #> -2.7543 (1829), -2.4407 (920), -2.4364 (1180), -2.3054 (267), -2.2904 (395) #> Top highest standardised residuals: #> 14.944 (1914), 10.77 (1745), 9.664 (1111), 9.154 (1532), 8.1756 (1737) #> ----------------------------------------------- #> Checks for trend in residuals #> ----------------------------------------------- #> Model name: ranger #> Standardised loess fit: +58.71 ***