Skip to contents

Treats each row of OTIS b01 as one observed placement with duration NumberConsecutiveDays_Segregation and no censoring (all durations are observed end-to-end within the fiscal year). Returns the median duration and the requested-quantile survival probabilities by stratum.

Usage

mrm_otis_seg_duration_km(
  data,
  duration_col = "NumberConsecutiveDays_Segregation",
  group_cols = NULL,
  probs = c(0.5, 0.25, 0.1, 0.05, 0.01),
  mandela_threshold = 15L
)

Arguments

data

A data.frame containing duration_col and optional stratifying columns (group_cols).

duration_col

Column name of segregation duration in days (default "NumberConsecutiveDays_Segregation").

group_cols

Optional character vector of stratifying-column names. NULL pools all rows.

probs

Quantiles of the survival function to report (default c(0.5, 0.25, 0.10, 0.05, 0.01)).

mandela_threshold

Day cutoff (default 15L) for Mandela- prolonged placement. Reports the fraction of placements above the cutoff and the median duration among those.

Value

A data.frame with one row per stratum (or one pooled row), columns stratum, n, mean_days, median_days, q25_days, pct_above_mandela, median_among_above_mandela.

Details

This replaces the misreading of UniqueIndividual_ID = YYYY-XXXXX-SG as a persistent person identifier (which produces a spurious ~210-day cross-year TTR artifact). The valid quantity here is the distribution of how long a placement lasts, not how long until the next placement.

Examples

if (FALSE) {
  b01 <- read.csv("b01_segregation_detailed_dataset.csv")
  mrm_otis_seg_duration_km(b01)
  mrm_otis_seg_duration_km(b01, group_cols = "MentalHealth_Alert")
}