get_r2: Estimate R2 or Pseudo-R2 from regression models

View source: R/display_functions.R

get_r2R Documentation

Estimate R2 or Pseudo-R2 from regression models

Description

get_r2 is a is a wrap function that calls r2 from package performance. Calculates the R2 or pseudo-R2 value for different regression model objects, returning a character object for easy printing in tables of coefficients.

Usage

get_r2(model, ...)

Arguments

model

A statistical regression model.

...

Additional arguments passed to r2.

Details

The main purpose of get_r2 is to allow easy printing of R2 value in tables of coefficients (see examples).

See Also

r2.

Examples

require(dplyr, quietly = TRUE)
require(sjlabelled, quietly = TRUE)

data(birthwt, package = "MASS")
birthwt <- birthwt |>
  mutate(
    smoke = factor(smoke, labels = c("Non-smoker", "Smoker")),
    race = factor(race, labels = c("White", "African American", "Other"))
  ) |>
  var_labels(
    bwt = "Birth weight (g)",
    smoke = "Smoking status",
    race = "Race"
  )

model_norm <- lm(bwt ~ smoke + race, data = birthwt)

get_r2(model_norm)

pubh documentation built on Oct. 8, 2024, 9:08 a.m.