| mcf | R Documentation |
Computes the non-parametric Mean Cumulative Function (MCF) for recurrent event data from one or more repairable systems, using the Nelson-Aalen estimator. The MCF estimates the expected cumulative number of events per system as a function of time, properly accounting for system exposure (observation windows).
mcf(
id = NULL,
time = NULL,
event = NULL,
end_time = NULL,
data = NULL,
conf_level = 0.95
)
id |
A vector of system/unit identifiers. Each unique value represents
a distinct system. Ignored if |
time |
A numeric vector of event or censoring times. Must be positive
and finite. Ignored if |
event |
An optional numeric vector of event indicators: 1 for an event,
0 for censoring (end of observation). If |
end_time |
An optional named numeric vector of end-of-observation times
per system, where names correspond to system identifiers. This defines
the actual exposure window for each system. When provided, a system
remains in the risk set until its |
data |
An optional data frame containing columns named |
conf_level |
Confidence level for bounds (default 0.95). |
The MCF at time t is estimated as:
\hat{M}(t) = \sum_{t_j \le t} \frac{d_j}{n_j}
where d_j is the number of events at time t_j and n_j is
the number of systems still under observation at t_j. Variance is
estimated as \hat{V}(t) = \sum_{t_j \le t} d_j / n_j^2.
The risk set n_j is determined by each system's exposure window.
A system is considered at risk at time t_j if its end-of-observation
time (from end_time, censoring records, or last event) is
\ge t_j. Specifying end_time is important when systems were
observed beyond their last event – without it, the MCF may overestimate
the true recurrence rate because systems with no late events are assumed to
have left observation at their last event time.
An object of class mcf containing:
time |
Unique event times. |
mcf |
MCF values at each event time. |
variance |
Variance estimates at each event time. |
lower_bounds |
Lower confidence bounds. |
upper_bounds |
Upper confidence bounds. |
conf_level |
Confidence level used. |
n_systems |
Number of distinct systems. |
n_events |
Total number of events. |
end_times |
Named vector of end-of-observation times per system. |
Other Repairable Systems Analysis:
exposure(),
nhpp(),
overlay_nhpp(),
plot.exposure(),
plot.mcf(),
plot.nhpp(),
plot.nhpp_predict(),
predict_nhpp(),
print.exposure(),
print.mcf(),
print.nhpp(),
print.nhpp_predict()
# Basic usage (end of observation inferred from last event)
id <- c(1, 1, 1, 2, 2, 3, 3, 3, 3)
time <- c(100, 300, 500, 150, 400, 50, 200, 350, 600)
result <- mcf(id, time)
print(result)
plot(result, main = "Mean Cumulative Function")
# With explicit end-of-observation times (exposure-adjusted)
end_time <- c("1" = 800, "2" = 800, "3" = 800)
result2 <- mcf(id, time, end_time = end_time)
print(result2)
df <- data.frame(id = id, time = time)
result3 <- mcf(data = df)
print(result3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.