get_residuals {insight} | R Documentation |
Extract model residuals
Description
Returns the residuals from regression models.
Usage
get_residuals(x, ...)
## Default S3 method:
get_residuals(x, weighted = FALSE, verbose = TRUE, ...)
Arguments
x |
A model. |
... |
Passed down to |
weighted |
Logical, if |
verbose |
Toggle warnings and messages. |
Value
The residuals, or NULL
if this information could not be
accessed.
Note
This function returns the default type of residuals, i.e. for the
response from linear models, the deviance residuals for models of class
glm
etc. To access different types, pass down the type
argument (see
'Examples').
This function is a robust alternative to residuals()
, as it works for
some special model objects that otherwise do not respond properly to calling
residuals()
.
Examples
data(mtcars)
m <- lm(mpg ~ wt + cyl + vs, data = mtcars)
get_residuals(m)
m <- glm(vs ~ wt + cyl + mpg, data = mtcars, family = binomial())
get_residuals(m) # type = "deviance" by default
get_residuals(m, type = "response")
[Package insight version 0.20.2 Index]