plot_residuals: Plot several residuals plots for diagnostics.

View source: R/plot_residuals.R

plot_residualsR Documentation

Plot several residuals plots for diagnostics.

Description

Plot several residuals plots for diagnostics.

Usage

plot_residuals(x, y, fit)

Arguments

x

A length one character vector with the main covariate name (i.e., right-hand side), as defined in fit.

y

A length one character vector with the variable name to be explained (i.e., left-hand side), as defined in fit.

fit

A model object from a statistical model such as from a call time_model() or egg_model().

Value

A patchwork ggplot2 object.

Examples

library(ggplot2)
library(patchwork)
library(eggla)
data("bmigrowth")
res <- egg_model(
  formula = log(bmi) ~ age,
  data = bmigrowth[bmigrowth[["sex"]] == 0, ],
  id_var = "ID",
  random_complexity = 1
)
plot_residuals(
  x = "age",
  y = "log(bmi)",
  fit = res
) +
  plot_annotation(
    title = "Cubic Splines (Random Linear Splines) - BMI - Female",
    tag_levels = "A"
  )

mcanouil/eggla documentation built on April 5, 2025, 3:06 a.m.