stratified_multi_reg: Stratified Multivariable Regression (Adjusted OR, RR, IRR, or...

View source: R/stratified_multi_reg.R

stratified_multi_regR Documentation

Stratified Multivariable Regression (Adjusted OR, RR, IRR, or Beta)

Description

Performs multivariable regression with multiple exposures on a binary, count, or continuous outcome, stratified by a specified variable. NA values in the stratifier are excluded from analysis.

Usage

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

Arguments

data

A data frame containing the variables.

outcome

name of the outcome variable.

exposures

vector specifying the predictor (exposure) variables.

stratifier

A character string specifying the stratifying variable.

approach

Modeling approach to use. One of: '"logit"' (Adjusted Odds Ratios), '"log-binomial"' (Adjusted Risk Ratios), '"poisson"' (Adjusted IRRs), '"robpoisson"' (Adjusted RRs), or '"linear"' (Beta coefficients), '"negbin"' (Adjusted IRRs).

Value

An object of class 'stratified_multi_reg', which includes: - 'table': A 'gtsummary::tbl_stack' object of regression tables by stratum, - 'models': A named list of model objects for each stratum, - 'model_summaries': A list of tidy model summaries, - 'reg_check': Diagnostics results (if available for the model type).

Accessors

$table

Stacked table of stratified regression outputs.

$models

Named list of fitted models per stratum.

$model_summaries

Tidy summaries for each model.

$reg_check

Regression diagnostic checks (when applicable).

See Also

[multi_reg()], [stratified_uni_reg()], [plot_reg()]

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_multi <- stratified_multi_reg(
    data = pima,
    outcome = "diabetes",
    exposures = c("age", "mass"),
    stratifier = "glucose_cat",
    approach = "logit"
  )
  stratified_multi$table
}


gtregression documentation built on Aug. 18, 2025, 5:23 p.m.