% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/exposure.R
\name{exposure}
\alias{exposure}
\title{Exposure Analysis for Repairable Systems.}
\usage{
exposure(id = NULL, time = NULL, event = NULL, data = NULL)
}
\arguments{
\item{id}{A vector of system/unit identifiers. Each unique value
represents a distinct system.}

\item{time}{A numeric vector of event or censoring times. Must be
positive and finite.}

\item{event}{An optional numeric vector of event indicators: 1 for an
event, 0 for censoring (end of observation). If \code{NULL} (default),
all observations are treated as events, and the maximum time per system
is treated as the end of observation.}

\item{data}{An optional data frame containing columns named \code{id},
\code{time}, and optionally \code{event}.}
}
\value{
An object of class \code{exposure} containing:
\item{time}{Sorted unique event times (excluding censoring-only times).}
\item{n_at_risk}{Number of systems under observation at each event time.}
\item{cum_exposure}{Cumulative total exposure (system-time) up to each
event time.}
\item{cum_events}{Cumulative number of events up to each event time.}
\item{event_rate}{Cumulative event rate (cum_events / cum_exposure) at
each event time.}
\item{total_exposure}{Total exposure across all systems and the full
observation period.}
\item{total_events}{Total number of events.}
\item{n_systems}{Number of distinct systems.}
\item{end_times}{Named numeric vector of end-of-observation times per
system. Can be passed directly to \code{mcf(end_time = ...)} to ensure
the MCF properly accounts for system exposure.}
}
\description{
Computes exposure (total operating time at risk) across one or more
repairable systems as a function of time. Exposure is defined as the
total accumulated observation time summed across all systems still under
observation. The function also computes the number of systems at risk
and the event rate (events per unit exposure) at each event time.
}
\details{
\strong{Exposure} is the total amount of operating time during which events
can occur. For a fleet of \eqn{k} systems observed up to times
\eqn{T_1, T_2, \ldots, T_k}, the total exposure is
\eqn{E = \sum_{i=1}^{k} T_i}{E = T_1 + T_2 + ... + T_k}.

The \strong{cumulative exposure} at time \eqn{t} is
\eqn{E(t) = \sum_{i=1}^{k} \min(t, T_i)}{E(t) = sum of min(t, T_i)},
i.e., each system contributes time up to the lesser of \eqn{t} or its
observation end.

The \strong{event rate} at time \eqn{t} is the cumulative number of events
divided by the cumulative exposure: \eqn{r(t) = N(t) / E(t)}.
}
\examples{
id   <- c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3)
time <- c(100, 350, 500, 80, 300, 600, 150, 250, 400, 700)
result <- exposure(id, time)
print(result)
plot(result)

# With censoring
id    <- c(1, 1, 1, 2, 2, 2, 3, 3, 3)
time  <- c(100, 350, 500, 80, 300, 400, 150, 250, 700)
event <- c(  1,   1,   0,  1,   1,   0,   1,   1,   1)
result2 <- exposure(id, time, event)
print(result2)
}
\seealso{
Other Repairable Systems Analysis: 
\code{\link{mcf}()},
\code{\link{nhpp}()},
\code{\link{overlay_nhpp}()},
\code{\link{plot.exposure}()},
\code{\link{plot.mcf}()},
\code{\link{plot.nhpp}()},
\code{\link{plot.nhpp_predict}()},
\code{\link{predict_nhpp}()},
\code{\link{print.exposure}()},
\code{\link{print.mcf}()},
\code{\link{print.nhpp}()},
\code{\link{print.nhpp_predict}()}
}
\concept{Repairable Systems Analysis}
