Learn R Programming

olsrr (version 0.4.0)

ols_cooksd_barplot: Cooks' D Bar Plot

Description

Bar Plot of cook's distance to detect observations that strongly influence fitted values of the model.

Usage

ols_cooksd_barplot(model)

Arguments

model

an object of class lm

Value

ols_cooksd_barplot returns a list containing the following components:

outliers

a tibble with observation number and cooks distance that exceed threshold

threshold

threshold for classifying an observation as an outlier

Details

Cook's distance was introduced by American statistician R Dennis Cook in 1977. It is used to identify influential data points. It depends on both the residual and leverage i.e it takes it account both the x value and y value of the observation.

Steps to compute Cook's distance:

  • Delete observations one at a time.

  • Refit the regression model on remaining \(n - 1\) observations

  • examine how much all of the fitted values change when the ith observation is deleted.

A data point having a large cook's d indicates that the data point strongly influences the fitted values.

Examples

Run this code
# NOT RUN {
model <- lm(mpg ~ disp + hp + wt, data = mtcars)
ols_cooksd_barplot(model)
# }

Run the code above in your browser using DataLab