Stratified Multivariable Regression (Adjusted OR, RR, IRR, or Beta)
Source:R/stratified_multi_reg.R
stratified_multi_reg.Rd
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.
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).
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
}
#> Running stratified multivariable regression by: glucose_cat
#> > Stratum: glucose_cat = High
#> > Stratum: glucose_cat = Normal
Adjusted OR
95% CI
p-value
Adjusted OR
95% CI
p-value
Abbreviations: CI = Confidence Interval, OR = Odds Ratio
glucose_cat = High: N = 197 complete cases included per stratum
glucose_cat = Normal: N = 555 complete cases included per stratum