Skip to contents

Plot observed vs predicted distribution of a fitted model

Usage

observed_vs_theoretical(model)

Arguments

model

A statistical model.

Value

A ggplot2 plot.

Details

Has been tested with stats::lm() and stats::glm() models. It may work with other types of models, but without any warranty.

Examples

# a linear model
mod <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris)
mod |> observed_vs_theoretical()


# a logistic regression
mod <- glm(
  as.factor(Survived) ~ Class + Sex,
  data = titanic,
  family = binomial()
)
mod |> observed_vs_theoretical()