View source: R/find_k_inter_main.R
| find_quantile_for_proportion | R Documentation |
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
)
data |
A data.frame containing the variable of interest |
var_name |
Character string specifying the variable name to analyze |
target_prop |
Numeric value between 0 and 1 specifying the target proportion of observations to be included in the subgroup |
direction |
Character string: "less" for values <= cutpoint (default), "greater" for values > cutpoint |
tol |
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.
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)
generate_aft_dgm_flex
## Not run:
gbsg <- survival::gbsg
# Find ER cutpoint for 12.5% subgroup
result <- find_quantile_for_proportion(
data = gbsg,
var_name = "er",
target_prop = 0.125,
direction = "less"
)
print(result)
# Use in subgroup definition
subgroup_cuts = list(
er = list(type = "quantile", value = result$quantile)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.