Skip to contents

Performs univariate regression for each exposure on a binary, count, or continuous outcome, stratified by a specified variable. Produces a stacked `gtsummary` table with one column per stratum, along with underlying models and diagnostics.

Usage

stratified_uni_reg(data, outcome, exposures, stratifier, approach = "logit")

Arguments

data

A data frame containing the variables.

outcome

name of the outcome variable.

exposures

A vector specifying the predictor (exposure) variables.

stratifier

A character string specifying the stratifier

approach

Modeling approach to use. One of: `"logit"` (Odds Ratios), `"log-binomial"` (Risk Ratios), `"poisson"` (Incidence Rate Ratios), `"robpoisson"` (Robust RR), `"linear"` (Beta coefficients), `"negbin"` (Incidence Rate Ratios),.

Value

An object of class `stratified_uni_reg`, which includes: - `table`: A `gtsummary::tbl_stack` object with stratified results, - `models`: A list of fitted models for each stratum, - `model_summaries`: A tidy list of model summaries, - `reg_check`: A tibble of regression diagnostics (when available).

Accessors

$table

Stacked stratified regression table.

$models

List of fitted model objects for each stratum.

$model_summaries

List of tidy model summaries.

$reg_check

Diagnostic check results (when applicable).

See also

[multi_reg()], [plot_reg()], [identify_confounder()]

Examples

if (requireNamespace("mlbench", quietly = TRUE) &&
  requireNamespace("dplyr", quietly = TRUE)) {
  data(PimaIndiansDiabetes2, package = "mlbench")
  pima <- dplyr::mutate(
    PimaIndiansDiabetes2,
    diabetes = ifelse(diabetes == "pos", 1, 0),
    glucose_cat = dplyr::case_when(
      glucose < 140 ~ "Normal",
      glucose >= 140 ~ "High"
    )
  )
  stratified_uni <- stratified_uni_reg(
    data = pima,
    outcome = "diabetes",
    exposures = c("age", "mass"),
    stratifier = "glucose_cat",
    approach = "logit"
  )
  stratified_uni$table
}
#> Running stratified univariate regression by: glucose_cat
#>   > Stratum: glucose_cat = High
#>   > Stratum: glucose_cat = Normal
Characteristic
glucose_cat = High
glucose_cat = Normal
N OR 95% CI p-value N OR 95% CI p-value
age 197 1.01 0.99, 1.04 0.3 566 1.04 1.02, 1.06 <0.001
mass 197 1.07 1.02, 1.12 0.010 555 1.10 1.07, 1.14 <0.001
Abbreviations: CI = Confidence Interval, OR = Odds Ratio