View source: R/stratified_multi_reg.R
stratified_multi_reg | R Documentation |
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.
stratified_multi_reg(data, outcome, exposures, stratifier, approach = "logit")
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). |
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).
$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).
[multi_reg()], [stratified_uni_reg()], [plot_reg()]
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
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.