bias {effectplots} | R Documentation |
Calculates average residuals (= bias) over the values of one or multiple
X
variables.
bias(
X,
resid,
w = NULL,
x_name = "x",
breaks = "Sturges",
right = TRUE,
discrete_m = 5L,
outlier_iqr = 2,
seed = NULL,
...
)
X |
A vector, matrix, or data.frame with variable(s) to be shown on the x axis. |
resid |
A numeric vector of residuals, i.e., y - pred. |
w |
An optional numeric vector of weights. |
x_name |
If |
breaks |
An integer, vector, string or function specifying the bins
of the numeric X variables as in |
right |
Should bins be right-closed? The default is |
discrete_m |
Numeric X variables with up to this number of unique values
should not be binned and treated as a factor (after calculating partial dependence)
The default is 5. Vectorized over |
outlier_iqr |
Outliers of a numeric X are capped via the boxplot rule, i.e.,
outside |
seed |
Optional random seed (an integer) used for capping X based on quantiles calculated from a subsample of 10k observations. |
... |
Currently unused. |
The function is a convenience wrapper around feature_effects()
.
A list (of class "EffectData") with a data.frame of statistics per feature. Use single bracket subsetting to select part of the output.
fit <- lm(Sepal.Length ~ ., data = iris)
M <- bias(iris[2:5], resid = fit$residuals, breaks = 5)
M |> update(sort_by = "resid_mean") |> plot(share_y = "all")