% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrapper.R
\name{surv.gam}
\alias{surv.gam}
\title{Wrapper for Generalized Additive Cox Regression (GAM)}
\usage{
surv.gam(time, event, X, newdata, new.times, obsWeights, id, cts.num = 5, ...)
}
\arguments{
\item{time}{Observed follow-up time.}

\item{event}{Observed event indicator.}

\item{X}{Training covariate data.frame.}

\item{newdata}{Test covariate data.frame to use for prediction.}

\item{new.times}{Times at which to obtain predicted survivals.}

\item{obsWeights}{Observation weights (Note: Ignored, as mgcv uses weights for the event indicator).}

\item{id}{Optional cluster/individual ID indicator.}

\item{cts.num}{Cutoff of unique values at which a numeric covariate receives a smooth term (s).}

\item{...}{Additional arguments passed to \code{\link[mgcv]{gam}}.}
}
\value{
A list containing:
\itemize{
\item \code{fit}: The fitted model object (e.g., the raw \code{coxph} or \code{xgb.Booster} object).
If the model fails to fit, this may be an object of class \code{try-error}.
\item \code{pred}: A numeric matrix of cross-validated survival predictions
evaluated at the specified \code{new.times} grid.
}
}
\description{
Final Production Wrapper for GAM (Tunable & Robust).
Uses \code{\link[mgcv]{gam}} to fit an additive combination of smooth
and linear functions.
}
\examples{
if (requireNamespace("mgcv", quietly = TRUE)) {
  data("metabric", package = "SuperSurv")
  dat <- metabric[1:30, ]
  x_cols <- grep("^x", names(dat))[1:3]
  X <- dat[, x_cols, drop = FALSE]
  newX <- X[1:5, , drop = FALSE]
  times <- seq(50, 150, by = 50)

  fit <- surv.gam(
    time = dat$duration,
    event = dat$event,
    X = X,
    newdata = newX,
    new.times = times,
    obsWeights = rep(1, nrow(dat)),
    id = NULL,
    cts.num = 5
  )

  dim(fit[["pred"]])
}
}
