Skip to contents

Calculates the average value of the response variable, and places this on the link scale. Plotting these against a predictor (by dividing the dataset into bins) can help assess the choice of link function.

Usage

empirical_link(response, family, na.rm = FALSE)

Arguments

response

Vector of response variable values.

family

Family object representing the response distribution and link function. Only the link function will be used.

na.rm

Should NA values of the response be stripped? Passed to mean() when calculating the mean of the response.

Value

Mean response value, on the link scale.

Examples

suppressMessages(library(dplyr))
suppressMessages(library(ggplot2))

mtcars |>
  bin_by_interval(disp, breaks = 5) |>
  summarize(
    mean_disp = mean(disp),
    link = empirical_link(am, binomial())
  ) |>
  ggplot(aes(x = mean_disp, y = link)) +
  geom_point()