% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/weibull_helpers.R
\name{lgspline_weibull}
\alias{lgspline_weibull}
\title{Fit Weibull Accelerated Failure Time Model via lgspline}
\usage{
lgspline_weibull(formula, data, status, ...)
}
\arguments{
\item{formula}{Formula specifying the model. The response should be
survival time; \code{status} is passed separately.}

\item{data}{Data frame.}

\item{status}{Integer vector of event indicators (1 = event,
0 = censored), same length as the number of rows in \code{data}.}

\item{...}{Additional arguments passed to \code{lgspline}.}
}
\value{
An object of class \code{"lgspline"}.
}
\description{
Convenience wrapper that calls \code{lgspline} with the correct
family, weight, dispersion, score, and unconstrained-fit functions for
Weibull accelerated failure time regression. All standard lgspline
arguments (knots, penalties, constraints, parallel, etc.) are passed
through.
}
\details{
Internally sets:
\itemize{
  \item \code{family = weibull_family()}
  \item \code{unconstrained_fit_fxn = unconstrained_fit_weibull}
  \item \code{glm_weight_function = weibull_glm_weight_function}
  \item \code{qp_score_function = weibull_qp_score_function}
  \item \code{dispersion_function = weibull_dispersion_function}
  \item \code{schur_correction_function = weibull_schur_correction}
  \item \code{need_dispersion_for_estimation = TRUE}
  \item \code{estimate_dispersion = TRUE}
  \item \code{standardize_response = FALSE}
}

A formula interface is needed, e.g. \code{lgspline_weibull(t, y, ...)} won't work,
unlike for ordinary \code{\link{lgspline}}.
}
\examples{

## Weibull AFT with a nonlinear age effect on lung cancer survival
if(requireNamespace("survival", quietly = TRUE)) {
  library(survival)
  set.seed(1234)
  lung <- na.omit(lung[, c("time", "status", "age")])
  lung$age_std <- std(lung$age)

  ## survival codes status as 1 = censored, 2 = dead
  event <- as.integer(lung$status == 2)

  ## Spline on age
  fit <- lgspline_weibull(
    time ~ spl(age_std),
    data = lung,
    status = event,
    K = 1,
    opt = FALSE,
    wiggle_penalty = 1e-4,
    flat_ridge_penalty = 1
  )
  print(summary(fit))
  plot(fit,
       show_formulas = TRUE,
       custom_response_lab = 'Survival Time',
       custom_predictor_lab = 'Standardized Age')
}

}
\seealso{
\code{\link{lgspline_cox}} for Cox proportional hazards,
  \code{\link{weibull_family}}, \code{\link{unconstrained_fit_weibull}}
}
