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.
Source:R/stratified_uni_reg.R
stratified_uni_reg.Rd
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.
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).
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
N
OR
95% CI
p-value
N
OR
95% CI
p-value
Abbreviations: CI = Confidence Interval, OR = Odds Ratio