% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/phreg.R
\name{resmean_phreg}
\alias{resmean_phreg}
\alias{rmst_phreg}
\title{Restricted Mean for Stratified Kaplan-Meier or Cox Model}
\usage{
resmean_phreg(x, times = NULL, covs = NULL, ...)
}
\arguments{
\item{x}{Object of class \code{"phreg"}.}

\item{times}{Possible times for which to report restricted mean. If \code{NULL}, reports for all event times.}

\item{covs}{Possible covariates for Cox model adjustment.}

\item{...}{Additional arguments passed to lower-level functions.}
}
\value{
An object of class \code{"resmean_phreg"} containing:
\item{rmst}{Matrix of restricted mean survival times.}
\item{se.rmst}{Standard errors for RMST.}
\item{intkmtimes}{Restricted mean at specified times.}
\item{years.lost}{Years lost (if applicable).}
}
\description{
Computes the Restricted Mean Survival Time (RMST) for stratified Kaplan-Meier or
stratified Cox models with martingale standard errors.
}
\details{
The standard error is computed using linear interpolation between standard errors at jump-times.
This allows plotting the restricted mean as a function of time.

Years lost can be computed based on this and decomposed into years lost for different causes
using the \code{cif_yearslost} function.
}
\examples{
data(bmt)
bmt$time <- bmt$time + runif(408) * 0.001
out1 <- phreg(Surv(time, cause != 0) ~ strata(tcell, platelet), data = bmt)

rm1 <- resmean_phreg(out1, times = 10 * (1:6))
summary(rm1)
e1 <- estimate(rm1)
par(mfrow = c(1, 2))
plot(rm1, se = 1)
plot(rm1, years.lost = TRUE, se = 1)

## Comparing populations
rm1 <- resmean_phreg(out1, times = 40)
e1 <- estimate(rm1)
estimate(e1, rbind(c(1, -1, 0, 0)))
}
\author{
Thomas Scheike
}
