This function creates a summary table in Kaplan-Meier format from simulated individual patient data, calculating number at risk and cumulative censoring at specified time points.
Value
List containing:
- n_risk
Numeric vector of number at risk at each time point
- n_censored_cumulative
Numeric vector of cumulative censored by each time point
Details
The function processes individual patient data to create aggregate summaries that mimic published Kaplan-Meier tables. Number at risk represents patients who have not yet experienced the event or been censored before each time point.
Examples
# First simulate data
time_points <- c(0, 6, 12, 18, 24)
hazard_rates <- c(0.05, 0.08, 0.12, 0.15)
sim_data <- simPE(
n = 200,
time_points = time_points,
hazard_rates = hazard_rates,
max_time = 24,
seed = 456 # For reproducible results
)
# Create KM table
km_summary <- summaryKM(sim_data, time_points)
print(km_summary$n_risk)
#> [1] 200 134 78 33 16
print(km_summary$n_censored_cumulative)
#> [1] 0 5 8 8 9