plotD3_cooksdistance: Influence of observations Plot in D3 with r2d3 package.

View source: R/plotD3_cooksdistance.R

plotD3_cooksdistanceR Documentation

Influence of observations Plot in D3 with r2d3 package.

Description

Plot of Cook’s distances used for estimate the influence of an single observation.

Usage

plotD3_cooksdistance(
  object,
  ...,
  nlabel = 3,
  single_plot = FALSE,
  scale_plot = FALSE,
  background = FALSE
)

plotD3CooksDistance(
  object,
  ...,
  nlabel = 3,
  single_plot = FALSE,
  scale_plot = FALSE,
  background = FALSE
)

Arguments

object

An object of class 'auditor_model_cooksdistance' created with model_cooksdistance function.

...

Other objects of class 'auditor_model_cooksdistance'.

nlabel

Number of observations with the biggest Cook's distances to be labeled.

single_plot

Logical, indicates whenever single or facets should be plotted. By default it's FALSE.

scale_plot

Logical, indicates whenever the plot should scale with height. By default it's FALSE.

background

Logical, available only if single_plot = FALSE. Indicates whenever background plots should be plotted. By default it's FALSE.

Details

Cook’s distance is a tool for identifying observations that may negatively affect the model. They may be also used for indicating regions of the design space where it would be good to obtain more observations. Data points indicated by Cook’s distances are worth checking for validity.

Cook’s Distances are calculated by removing the i-th observation from the data and recalculating the model. It shows how much all the values in the model change when the i-th observation is removed.

For model classes other than lm and glm the distances are computed directly from the definition.

Value

a r2d3 object

References

Cook, R. Dennis (1977). "Detection of Influential Observations in Linear Regression". doi:10.2307/1268249.

See Also

plot_cooksdistance

Examples


dragons <- DALEX::dragons[1:100, ]

# fit a model
model_lm <- lm(life_length ~ ., data = dragons)

lm_audit <- audit(model_lm, data = dragons, y = dragons$life_length)

# validate a model with auditor
cd_lm <- model_cooksdistance(lm_audit)

# plot results
plotD3_cooksdistance(cd_lm, nlabel = 5)


auditor documentation built on Nov. 2, 2023, 6:13 p.m.