% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/surv_model_compare.R
\name{surv_model_compare}
\alias{surv_model_compare}
\title{Compare parametric survival model distributions}
\usage{
surv_model_compare(
  data,
  time,
  event,
  exposures,
  adjust_for = NULL,
  distributions = c("weibull", "exponential", "lognormal", "loglogistic"),
  digits = 2,
  format = c("flextable", "gt", "tibble"),
  theme = c("minimal")
)
}
\arguments{
\item{data}{A \code{data.frame} containing survival time, event status, and
predictor variables.}

\item{time}{Survival follow-up time. Quoted and bare names are accepted.}

\item{event}{Event indicator. Quoted and bare names are accepted. Numeric
\code{0/1}, numeric \code{1/2}, logical, character, and factor variables
are accepted. For two-level character or factor variables, the second level
is treated as the event.}

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

\item{adjust_for}{Optional character vector of adjustment variables. These
variables are included in every candidate model.}

\item{distributions}{Parametric survival distributions to compare. Defaults
to \code{c("weibull", "exponential", "lognormal", "loglogistic")}.
Quoted and bare values are accepted. Common spellings such as
\code{"log-normal"} and \code{"log-logistic"} are also accepted.}

\item{digits}{Number of digits for displayed model statistics.}

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

\item{theme}{Table styling preset.}
}
\value{
A list of class \code{c("gtregression","surv_model_compare", ...)}
with elements:
\describe{
  \item{\code{table}}{A \code{flextable}, \code{gt_tbl}, or \code{NULL}
  when \code{format = "tibble"}.}
  \item{\code{table_body}}{Tibble with model-fit statistics.}
  \item{\code{table_display}}{Display data frame used to render the table.}
  \item{\code{models}}{Named list of fitted \code{survreg} models.}
  \item{\code{time,event,exposures,adjust_for,distributions,format,source}}{Metadata fields.}
}
}
\description{
Fit the same parametric survival regression model using multiple
distributions and compare model-fit statistics such as AIC and BIC.
}
\details{
The same model formula is fitted for each candidate distribution using
\code{survival::survreg()}. Lower AIC or BIC values indicate better relative
model fit among the compared distributions. These statistics should be used
with clinical judgment and visual checks; they do not prove that a
distribution is scientifically correct.
}
\examples{
lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
                        labels = c("Standard", "Test"))
lung_data$prior <- factor(lung_data$prior, levels = c(0, 10),
                          labels = c("No", "Yes"))

surv_model_compare(
  data = lung_data,
  time = time,
  event = status,
  exposures = c("trt", "celltype", "prior"),
  adjust_for = c("age", "karno")
)

surv_model_compare(
  data = lung_data,
  time = "time",
  event = "status",
  exposures = c(trt, prior),
  distributions = c(weibull, "log-logistic"),
  format = tibble
)

}
