A thick average partial-dependence line over thin per-observation ICE curves. Map group to the observation id to draw the ICE spaghetti.

geom_partial_dependence(
  mapping = NULL,
  data = NULL,
  color = NULL,
  ice = TRUE,
  ice_alpha = 0.25,
  linewidth = NULL
)

Arguments

mapping, data

Standard layer overrides. Map the feature to x and the prediction to y; map group for ICE curves.

color

Curve color.

ice

Draw the individual ICE curves under the average.

ice_alpha

Opacity of the ICE curves.

linewidth

Width of the average line.

Value

A Layer to add with +.

Examples

d <- data.frame(
  x = rep(1:10, 5), id = rep(1:5, each = 10),
  pred = as.vector(sapply(1:5, function(i) (1:10) * 0.1 * i + rnorm(10, 0, .1)))
)
ggnext(d, aes(x, pred, group = id)) + geom_partial_dependence()
#> <ggnext plot>
#>   data:  50 x 3
#>   aes:   x = x, y = pred, group = id
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static