Determines the quantile cutpoint that achieves a target proportion of observations in a subgroup. Useful for calibrating subgroup sizes.
find_quantile_for_proportion(
data,
var_name,
target_prop,
direction = "less",
tol = 1e-04
)A list containing:
The quantile value (between 0 and 1) that achieves the target proportion
The actual data value corresponding to this quantile
The achieved proportion (should equal target_prop within tolerance)
A data.frame containing the variable of interest
Character string specifying the variable name to analyze
Numeric value between 0 and 1 specifying the target proportion of observations to be included in the subgroup
Character string: "less" for values <= cutpoint (default), "greater" for values > cutpoint
Numeric tolerance for root finding algorithm. Default is 0.0001
This function uses root finding (uniroot) to determine the quantile
that results in exactly the target proportion of observations being classified
into the subgroup. This is particularly useful when you want to ensure a
specific subgroup size regardless of the data distribution.
generate_aft_dgm_flex