Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

broken.lm

Breaking Down of Model Predictions for lm models


Description

Breaking Down of Model Predictions for lm models

Usage

## S3 method for class 'lm'
broken(
  model,
  new_observation,
  ...,
  baseline = 0,
  predict.function = stats::predict.lm
)

Arguments

model

a lm model

new_observation

a new observation with columns that corresponds to variables used in the model

...

other parameters

baseline

the orgin/baseline for the breakDown plots, where the rectangles start. It may be a number or a character "Intercept". In the latter case the orgin will be set to model intercept.

predict.function

function that will calculate predictions out of model (typically predict or betas)

Value

an object of the broken class

Examples

model <- lm(Sepal.Length~., data=iris)
new_observation <- iris[1,]
br <- broken(model, new_observation)
plot(br)

# works for interactions as well
model <- lm(Sepal.Length ~ Petal.Width*Species, data = iris)
summary(model)

new_observation <- iris[1,]
br <- broken(model, new_observation)
br
plot(br)

br2 <- broken(model, new_observation, predict.function = betas)
br2
plot(br2)

breakDown

Model Agnostic Explainers for Individual Predictions

v0.2.1
GPL-2
Authors
Przemyslaw Biecek [aut, cre], Aleksandra Grudziaz [ctb]
Initial release
2021-01-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.