% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/phreg.R
\name{km}
\alias{km}
\title{Kaplan-Meier with Robust Standard Errors}
\usage{
km(formula, data = data, km = TRUE, ...)
}
\arguments{
\item{formula}{Formula with 'Surv' or 'Event' outcome.}

\item{data}{Data frame.}

\item{km}{Logical; if \code{TRUE}, returns Kaplan-Meier estimates; otherwise returns Nelson-Aalen based estimates.}

\item{...}{Additional arguments passed to \code{phreg}.}
}
\value{
An object of class \code{"km"} (extends \code{"predictphreg"}) containing:
\item{surr}{Survival probabilities.}
\item{se.surv}{Standard errors.}
\item{lower, upper}{Confidence intervals.}
}
\description{
Computes Kaplan-Meier estimates with robust standard errors.
Robust variance is the default and is obtained from the \code{predict} call.
}
\examples{
data(sTRACE)
sTRACE$cluster <- sample(1:100, 500, replace = TRUE)
out1 <- km(Surv(time, status == 9) ~ strata(vf, chf), data = sTRACE)
out2 <- km(Surv(time, status == 9) ~ strata(vf, chf) + cluster(cluster), data = sTRACE)

summary(out1, times = 1:3)
summary(out2, times = 1:3)

par(mfrow = c(1, 2))
plot(out1, se = TRUE)
plot(out2, se = TRUE)
}
\author{
Thomas Scheike
}
