Skip to contents

Plot values (in black) and their corresponding fitted values (in red), according to model.

Usage

plot_data_vs_fitted(model, ...)

Arguments

model

A fitted model for which to plot its data vs its fitted values. Needs to be broom::augment()-able.

...

Params passed to ggplot2::aes(). Should be the variables to plot, e.g. something like x = var1, y = var2.

Value

A ggplot2::ggplot() with two layers (points jittered in x-direction, representing original values (in black) and fitted values (in red))

Examples

plot_data_vs_fitted(lm(mpg ~ disp, data = mtcars), x = disp, y = mpg)

plot_data_vs_fitted(lm(mpg ~ disp + cyl + hp + wt, data = mtcars), x = wt, y = mpg)