% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrapper.R
\name{surv.bart}
\alias{surv.bart}
\title{Wrapper for BART (Bayesian Additive Regression Trees)}
\usage{
surv.bart(
  time,
  event,
  X,
  newdata = NULL,
  new.times,
  obsWeights = NULL,
  id = NULL,
  ntree = 10,
  ndpost = 30,
  nskip = 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 predicted survivals.}

\item{obsWeights}{Observation weights (Note: BART does not natively support weights).}

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

\item{ntree}{Number of trees (default: 50).}

\item{ndpost}{Number of posterior draws (default: 1000).}

\item{nskip}{Number of burn-in draws (default: 250).}

\item{...}{Additional arguments passed to \code{\link[BART]{mc.surv.bart}}.}
}
\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 BART (Tunable & Robust).
Uses the \code{\link[BART]{mc.surv.bart}} function.
Automatically reshapes the flat output vector into a survival matrix
and interpolates the predictions to the requested new.times.
}
\examples{
\dontrun{
if (.Platform$OS.type != "windows" &&
  requireNamespace("BART", quietly = TRUE)) {
  data("metabric", package = "SuperSurv")
  dat <- metabric[1:20, ]
  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.bart(
    time = dat$duration,
    event = dat$event,
    X = X,
    newdata = newX,
    new.times = times,
    ntree = 3,
    ndpost = 5,
    nskip = 5
  )

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