% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stratified_uni_reg.R
\name{stratified_uni_reg}
\alias{stratified_uni_reg}
\title{Stratified univariable regression}
\usage{
stratified_uni_reg(
  data,
  outcome,
  exposures,
  stratifier,
  approach = "logit",
  format = c("flextable", "gt"),
  theme = c("minimal"),
  show_ref = TRUE
)
}
\arguments{
\item{data}{A data frame containing the variables.}

\item{outcome}{Character scalar; name of the outcome variable. Quoted and
bare names are accepted.}

\item{exposures}{Character vector of exposure variables to model. Quoted
names are recommended in scripts, and bare names are also accepted.}

\item{stratifier}{Character scalar; name of the stratifying variable. Quoted
and bare names are accepted.}

\item{approach}{Modeling approach. One of \code{"logit"}, \code{"firth"},
\code{"logbinomial"}, \code{"poisson"}, \code{"robpoisson"},
\code{"linear"}, or \code{"negbin"}.}

\item{format}{Output table format; one of \code{"flextable"} (default) or
\code{"gt"}.}

\item{theme}{Table styling preset or theme primitives.}

\item{show_ref}{Logical; if \code{TRUE} (default), display reference-category
rows as \code{"Ref."}. If \code{FALSE}, hide reference rows; a message
reminds users to use \code{show_ref = TRUE} when reference rows are needed.}
}
\value{
A list of class
  \code{c("gtregression", "stratified_uni_reg", ...)} with elements:
\describe{
  \item{\code{table}}{A rendered \code{gt_tbl} or \code{flextable}.}
  \item{\code{table_display}}{Display-ready wide stratified results.}
  \item{\code{per_stratum}}{List of complete \code{uni_reg()} results by
  stratum.}
  \item{\code{models}}{List of fitted model objects by stratum.}
  \item{\code{model_summaries}}{List of model summaries by stratum.}
  \item{\code{variable_labels}}{Named character vector of display labels used
  for exposure variables.}
  \item{\code{reg_check}}{Regression diagnostics by stratum.}
  \item{\code{by}}{The stratifier variable.}
  \item{\code{levels}}{Strata included in the analysis.}
  \item{\code{approach}}{The regression approach used.}
  \item{\code{format}}{The output format used.}
  \item{\code{source}}{Function identifier
  (\code{"stratified_uni_reg"}).}
}
}
\description{
Fit univariable regression models within each level of a stratifier and
combine the results into a stratified table rendered with
\pkg{gt} or \pkg{flextable}.
}
\details{
If exposure variables have a \code{"label"} attribute, for example from
\code{labelled::var_label()}, those labels are used automatically in the
displayed table. Internal matching still uses the original column names.
}
\section{Accessors}{

\describe{
  \item{\code{$table}}{Rendered stratified regression table.}
  \item{\code{$table_display}}{Wide display data used to build the table.}
  \item{\code{$per_stratum}}{Full \code{uni_reg()} result objects by
  stratum.}
  \item{\code{$models}}{List of fitted model objects for each stratum.}
  \item{\code{$model_summaries}}{List of model summaries.}
  \item{\code{$reg_check}}{Diagnostic check results (when applicable).}
}
}

\examples{
birthwt_data <- data_birthwt |>
  transform(
    race = factor(race, levels = c(1, 2, 3),
                  labels = c("White", "Black", "Other")),
    smoke = factor(smoke, levels = c(0, 1), labels = c("No", "Yes")),
    low = factor(low, levels = c(0, 1),
                 labels = c("Normal BW", "Low BW"))
  )

stratified_uni <- stratified_uni_reg(
  data = birthwt_data,
  outcome = "low",
  exposures = c("age", "lwt", "smoke"),
  stratifier = "race",
  approach = "logit",
  format = "gt"
)

stratified_uni$table

}
\seealso{
[multi_reg()], [plot_reg()], [identify_confounder()]
}
