Skip to contents

Map continuous probabilities to discrete intervention tiers. A tier definition is an ordered list (highest risk first) of list(name =, top_fraction =), where top_fraction is the CUMULATIVE share of the reference population in that tier or above; the last tier takes the rest. list(list(name = "high", top_fraction = 0.10), list(name = "standard")) means "the riskiest 10% get the nurse transition call". Freeze the cut-points from a reference set (e.g. validation-period scores): re-fitting on each batch would hide drift. Mirror of Python omop_etl.risk_tiers.

Usage

fit_capacity_thresholds(reference_prob, tiers)

map_risk_tiers(prob, thresholds, as_category = FALSE)

tier_load(prob, thresholds, capacity = NULL, periods = 1)

Arguments

reference_prob

Reference probabilities in [0, 1].

tiers

Ordered list of list(name =, top_fraction =), the last without top_fraction.

prob

Probabilities in [0, 1].

thresholds

list(list(name =, min =), ...) in any order (from fit_capacity_thresholds() or a bundle's risk_tiers). Tiers are [min, next_min) and the lowest must start at 0.

as_category

Return an ordered factor (lowest tier first) instead of a character vector.

capacity

Optional named numeric: cases per period each tier's team can handle.

periods

Number of days/weeks covered by prob.

Value

fit_capacity_thresholds(): a list of list(name =, min =, fraction =).

map_risk_tiers(): tier names (a string for a single probability).

tier_load(): a data.frame with tier, n, share, per_period and, with capacity, capacity and over_capacity.

Details

fit_capacity_thresholds() returns cut-points lowest risk first as list(name =, min =, fraction =) (the shape write_model_bundle(risk_tiers = ) stores; the realised fraction of the reference set is extra). Tied probabilities cannot be split, so a tier can be slightly larger than requested.