Learn R Programming

regressinator (version 0.2.0)

empirical_link: Empirically estimate response values on the link scale

Description

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)

Value

Mean response value, on the link scale.

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.

Examples

Run this code
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()

Run the code above in your browser using DataLab