update.EffectData {effectplots}R Documentation

Update "EffectData" Object

Description

Updates an "EffectData" object by

Except for sort_by, all arguments are vectorized, i.e., you can pass a vector or list of the same length as object.

Usage

## S3 method for class 'EffectData'
update(
  object,
  sort_by = c("no", "pd", "pred_mean", "y_mean", "resid_mean", "ale"),
  collapse_m = 30L,
  collapse_by = c("weight", "N"),
  drop_below_n = 0,
  drop_below_weight = 0,
  na.rm = FALSE,
  ...
)

Arguments

object

Object of class "EffectData".

sort_by

By which statistic ("pd", "pred_mean", "y_mean", "resid_mean", "ale") should the results be sorted? The default is "no" (no sorting). Calculated after all other update steps, e.g., after collapsing or dropping rare levels.

collapse_m

If a categorical X has more than collapse_m levels, rare levels are collapsed into a new level "Other". Standard deviations are collapsed via root of the weighted average variances. The default is 30. Set to Inf for no collapsing.

collapse_by

How to determine "rare" levels in collapse_m? Either "weight" (default) or "N". Only matters in situations with case weights w.

drop_below_n

Drop bins with N below this value. Applied after collapsing.

drop_below_weight

Drop bins with weight below this value. Applied after collapsing.

na.rm

Should missing bin centers be dropped? Default is FALSE.

...

Currently not used.

Value

An object of class "EffectData".

See Also

feature_effects(), average_observed(), average_predicted(), partial_dependence(), ale(), bias(), effect_importance()

Examples

fit <- lm(Sepal.Length ~ ., data = iris)
xvars <- colnames(iris)[-1]
feature_effects(fit, v = xvars, data = iris, y = "Sepal.Length", breaks = 5) |>
  update(sort = "pd", collapse_m = 2) |>
  plot()

[Package effectplots version 0.1.0 Index]