% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/phreg.R
\name{cif_yearslost}
\alias{cif_yearslost}
\title{Restricted Mean Time Lost for Competing Risks}
\usage{
cif_yearslost(formula, data = data, cens.code = 0, times = NULL, ...)
}
\arguments{
\item{formula}{Formula for \code{phreg} object with \code{strata} to indicate strata, or \code{+1} if no strata.}

\item{data}{Data frame for calculations.}

\item{cens.code}{Censoring code (needed to separate event codes from censorings).}

\item{times}{Possible times for which to report restricted mean. Summary displays estimates for these times.}

\item{...}{Additional arguments passed to \code{phreg}.}
}
\value{
An object of class \code{"resmean_phreg"} containing:
\item{cumhaz}{Matrix of cumulative hazards (years lost).}
\item{se.cumhaz}{Standard errors.}
\item{intF1times}{Years lost at specified times.}
\item{causes}{Vector of cause codes.}
}
\description{
Computes the Restricted Mean Time Lost (RMTL) for competing risks based on the
integrated Aalen-Johansen estimator.
}
\details{
A set of time points can be given to be returned in the summary, but the function
computes years-lost for all event times and can be plotted/viewed.
The RMTL for a specific time-point can also be computed using the \code{rmstIPCW} function.
}
\examples{
data(bmt)
bmt$time <- bmt$time + runif(408) * 0.001

## Years lost decomposed into causes
drm1 <- cif_yearslost(Event(time, cause) ~ strata(tcell, platelet), data = bmt, times = c(40, 50))
par(mfrow = c(1, 2))
plot(drm1, cause = 1, se = 1)
plot(drm1, cause = 2, se = 1)
summary(drm1)
estimate(drm1, cause = 1)
estimate(drm1, cause = 2)

## Comparing populations
drm1 <- cif_yearslost(Event(time, cause) ~ strata(tcell, platelet), data = bmt, times = 40)
summary(drm1, contrast = list(1:4))
e1 <- estimate(drm1)
estimate(e1, rbind(c(1, -1, 0, 0)))
}
\author{
Thomas Scheike
}
