% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/surv_predict.R
\name{surv_predict}
\alias{surv_predict}
\title{Predict survival probabilities from a parametric survival model}
\usage{
surv_predict(
  model,
  newdata = NULL,
  times,
  digits = 1,
  format = c("flextable", "gt", "tibble"),
  theme = c("minimal")
)
}
\arguments{
\item{model}{A fitted \code{survreg} model, or a \code{surv_reg()} object
containing exactly one fitted model.}

\item{newdata}{Optional \code{data.frame} of profiles for prediction. If
\code{NULL}, one typical profile is built from the model data using medians
for numeric variables and the most common level for categorical variables.}

\item{times}{Numeric vector of follow-up times at which survival probability
should be predicted.}

\item{digits}{Number of digits for displayed follow-up times and
probabilities.}

\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_predict", ...)}
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 predicted survival probabilities.}
  \item{\code{table_display}}{Display data frame used to render the table.}
  \item{\code{model}}{The fitted \code{survreg} model used for prediction.}
  \item{\code{newdata,times,distribution,format,source}}{Metadata fields.}
}
}
\description{
Estimate model-based survival probabilities at user-specified follow-up
times from a fitted \code{survival::survreg()} model.
}
\details{
\code{surv_predict()} is for parametric survival regression models fitted by
\code{surv_reg()} or \code{survival::survreg()}. It is not a Kaplan-Meier
estimate and it is not a Cox prediction helper.

Supported distributions are \code{"weibull"}, \code{"exponential"},
\code{"lognormal"}, and \code{"loglogistic"}, matching
\code{surv_reg()}. Predictions are conditional on the supplied profile and
the chosen parametric distribution.
}
\examples{
lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
                        labels = c("Standard", "Test"))

fit <- surv_reg(
  data = lung_data,
  time = time,
  event = status,
  exposures = "trt",
  adjust_for = c("age", "karno"),
  distribution = weibull
)

surv_predict(
  model = fit$models$trt,
  newdata = data.frame(
    trt = factor("Test", levels = levels(lung_data$trt)),
    age = 60,
    karno = 70
  ),
  times = c(90, 180, 365)
)

surv_predict(
  model = fit,
  times = c(90, 180),
  format = tibble
)

}
