% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrapper.R
\name{surv.km}
\alias{surv.km}
\title{Kaplan-Meier Prediction Algorithm}
\usage{
surv.km(time, event, X, newdata, new.times, obsWeights, id, ...)
}
\arguments{
\item{time}{Numeric vector of observed follow-up times.}

\item{event}{Numeric vector of event indicators (1 = event, 0 = censored).}

\item{X}{Training covariate data.frame (Ignored by KM).}

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

\item{new.times}{Numeric vector of times at which to predict survival.}

\item{obsWeights}{Numeric vector of observation weights.}

\item{id}{Optional vector indicating subject/cluster identities.}

\item{...}{Additional ignored arguments.}
}
\value{
A list containing:
\itemize{
\item \code{fit}: A list containing the fitted \code{\link[survival]{survfit}} object.
\item \code{pred}: A numeric matrix of cross-validated survival predictions
evaluated at \code{new.times}.
}
}
\description{
This prediction algorithm ignores all covariates and computes the marginal
Kaplan-Meier survival estimator using the \code{\link[survival]{survfit}} function.
}
\examples{
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.km(
  time = dat$duration,
  event = dat$event,
  X = X,
  newdata = newX,
  new.times = times,
  obsWeights = rep(1, nrow(dat)),
  id = NULL
)

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