% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diagnostics.R
\name{hzr_competing_risks}
\alias{hzr_competing_risks}
\alias{print.hzr_competing_risks}
\title{Competing risks cumulative incidence}
\usage{
hzr_competing_risks(time, event)

\method{print}{hzr_competing_risks}(x, digits = 4, ...)
}
\arguments{
\item{time}{Numeric vector of follow-up times.}

\item{event}{Integer vector of event type indicators:
0 = censored, 1 = event type 1, 2 = event type 2, etc.}

\item{x}{An \code{hzr_competing_risks} object.}

\item{digits}{Number of decimal places for formatting.}

\item{...}{Additional arguments (ignored).}
}
\value{
A data frame with one row per unique event time and columns:
\describe{
\item{time}{Event time.}
\item{n_risk}{Number at risk.}
\item{n_event_1, n_event_2, ...}{Events of each type at this time.}
\item{n_censor}{Number censored at this time.}
\item{surv}{Overall event-free survival (freedom from all events).}
\item{incid_1, incid_2, ...}{Cumulative incidence for each event type.}
\item{se_surv}{Standard error of overall survival.}
\item{se_1, se_2, ...}{Standard error of each cumulative incidence.}
}
}
\description{
Compute cumulative incidence functions for multiple competing event
types using the Aalen-Johansen estimator with Greenwood variance.
This is the R equivalent of the SAS \code{markov.sas} macro.
}
\details{
Unlike the naive 1 - KM estimator (which overestimates incidence when
competing risks exist), this provides the correct marginal cumulative
incidence for each event type.
}
\examples{
data(valves)
valves_cc <- na.omit(valves)
# Combine death and PVE into a competing risks event variable
# 0 = censored, 1 = death, 2 = PVE
event_cr <- ifelse(valves_cc$dead == 1, 1L,
                   ifelse(valves_cc$pve == 1, 2L, 0L))
time_cr <- pmin(valves_cc$int_dead, valves_cc$int_pve)
cr <- hzr_competing_risks(time_cr, event_cr)
head(cr)

}
\seealso{
\code{\link[=hzr_kaplan]{hzr_kaplan()}} for single-event survival estimation.
}
