% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrapper.R
\name{surv.gbm}
\alias{surv.gbm}
\title{Wrapper function for Gradient Boosting (GBM) prediction algorithm}
\usage{
surv.gbm(
  time,
  event,
  X,
  newdata,
  new.times,
  obsWeights,
  id,
  n.trees = 1000,
  interaction.depth = 2,
  shrinkage = 0.01,
  cv.folds = 5,
  n.minobsinnode = 10,
  ...
)
}
\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 the predicted survivals.}

\item{obsWeights}{Observation weights.}

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

\item{n.trees}{Integer specifying the total number of trees to fit (default: 1000).}

\item{interaction.depth}{Maximum depth of variable interactions (default: 2).}

\item{shrinkage}{A shrinkage parameter applied to each tree (default: 0.01).}

\item{cv.folds}{Number of cross-validation folds to perform internally for optimal tree selection (default: 5).}

\item{n.minobsinnode}{Minimum number of observations in the trees terminal nodes (default: 10).}

\item{...}{Additional arguments passed to \code{\link[gbm]{gbm}}.}
}
\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 GBM (Tunable & Robust).
Estimates a Cox proportional hazards model via gradient boosting.
Uses the Breslow estimator with a step-function approach for the baseline hazard.
Includes internal safeguards against C++ crashes and small cross-validation folds.
}
\examples{
if (requireNamespace("gbm", 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.gbm(
    time = dat$duration,
    event = dat$event,
    X = X,
    newdata = newX,
    new.times = times,
    obsWeights = rep(1, nrow(dat)),
    id = NULL,
    n.trees = 20,
    interaction.depth = 1,
    shrinkage = 0.05,
    cv.folds = 0,
    n.minobsinnode = 3
  )

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