breakDown (version 0.1.6)

broken.lm: Breaking Down of Model Predictions for lm models

Description

Breaking Down of Model Predictions for lm models

Usage

# S3 method for 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

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataCamp Workspace