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

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

\item{exposures}{Character vector; exposure column names. Quoted names are
recommended in scripts, and bare names are also accepted.}

\item{approach}{Regression approach. One of \code{"logit"}, \code{"firth"},
\code{"logbinomial"}, \code{"poisson"}, \code{"robpoisson"},
\code{"linear"}, or \code{"negbin"}. Use \code{"firth"} for Firth
penalized logistic regression, especially with sparse cells or separation.}

\item{format}{One of \code{"flextable"} (default) or \code{"gt"}.}

\item{theme}{Preset name (e.g. \code{"minimal"}, \code{"striped"}, \code{"clinical"},
\code{"shaded"}, \code{"jama"}) or primitives
\code{c("plain","zebra","lines","labels_bold","compact","header_shaded")}}

\item{model_stats}{Logical; if \code{TRUE}, extract model-fit statistics
such as AIC, BIC, log-likelihood, deviance, pseudo R-squared for
non-linear models, and R-squared for linear models. Statistics are stored
in the returned object's \code{model_stats} element and are not added to
the publication table.}

\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","uni_reg", ...)} with elements:
\describe{
  \item{table}{A \code{flextable} (when \code{format="flextable"}) or
  \code{gt_tbl} (when \code{format="gt"}).}
  \item{table_body}{Data frame of numeric estimates and CIs.}
  \item{table_display}{Data frame for display (headers + levels).}
  \item{models}{List of fitted univariate models.}
  \item{model_summaries}{Per-model \code{summary()} results.}
  \item{model_stats}{Model-fit statistics when \code{model_stats = TRUE};
  otherwise \code{NULL}.}
  \item{variable_labels}{Named character vector of display labels used for
  exposure variables.}
  \item{reg_check}{Diagnostics for linear models. Printing this element
  renders a publication-ready table; individual diagnostic rows remain
  available for programmatic use. Other approaches return a message.}
  \item{approach, format, source}{Metadata fields.}
}
}
\description{
Fit one model per exposure and return a clean regression table in
\pkg{flextable} or \pkg{gt} format.
}
\details{
Use this when you want a quick crude association table before building an
adjusted model. The fitted models are kept in the returned object, so the
formatted table does not hide the underlying analysis.

If exposure variables have a \code{"label"} attribute, for example from
\code{labelled::var_label()}, those labels are used automatically in the
displayed table and plots. Internal matching still uses the original column
names.
}
\examples{
d <- mtcars
if (requireNamespace("gt", quietly = TRUE)) {
  uni_reg(d, "am", c("mpg","cyl"), approach = "logit", format = "gt")$table
}
if (requireNamespace("flextable", quietly = TRUE)) {
  ft <- uni_reg(d, "am", c("mpg","cyl"), approach = "logit", format = "flextable")
  class(ft$table)
}

endometrial_data <- data_endometrial
endometrial_data$HG <- factor(endometrial_data$HG, levels = c(0, 1))
endometrial_data$NV <- factor(endometrial_data$NV, levels = c(0, 1))
uni_reg(endometrial_data, HG, c(NV, PI, EH), approach = firth, format = gt)$table

}
