Tidy summary of selected subgroups across a comparison run
Source:R/compare_selection_rules.R
extract_selected_subgroups.RdReduces a forestsearch_comparison object to a tidy
data.frame with one row per combo, summarizing each configuration's
selected subgroup. Intended for post-hoc aggregation across
analyses (e.g.\ side-by-side summary of a continuous-outcome
comparison and a binary-outcome comparison in a single document).
Arguments
- x
A
forestsearch_comparisonobject as returned bycompare_selection_rules.- analysis_label
Optional character scalar identifying the parent analysis (e.g.\
"continuous"or"binary"). When supplied, it appears as the first column. Useful when row-binding tidy summaries from multiple analyses.
Value
A data.frame with columns:
analysisIf
analysis_labelis supplied; otherwise omitted.comboInteger index,
1..n_combos.combo_labelPretty label (e.g.\
"effMaxSG / pareto").sg_focus,selection_ruleThe two comparison axes.
outcome_type,effect_measureRecorded per row from
fs$outcome_type/fs$effect_measure, so mixed-effect-measure runs remain comparable.subgroupSelected subgroup definition –
NA_character_if no subgroup was identified; otherwisepaste(fs$sg.harm, collapse = " & ").N_H,N_HcSample sizes in the harm subgroup H (
treat.recommend == 0) and its complement Hc.effectThe winner's effect estimate on the natural scale (\(\exp\) applied to the stored
hrcolumn for ratio-scale measuresOR/RR/IRR; passed through otherwise).PconsThe winner's consistency probability.
KNumber of factors in the winner's subgroup definition.
n_passedNumber of candidates that passed consistency (=
nrow(out_sg$result)).on_frontierLogical – did the selected subgroup lie on the Pareto frontier?
NAwhen the frontier is unavailable.errorThe error message for failed combos (
NA_character_on success).
Examples
if (FALSE) { # \dontrun{
cmp_cont <- compare_selection_rules(...) # continuous analysis
cmp_bin <- compare_selection_rules(...) # binary analysis
tidy_cont <- extract_selected_subgroups(cmp_cont, analysis_label = "continuous")
tidy_bin <- extract_selected_subgroups(cmp_bin, analysis_label = "binary")
all_selected <- rbind(tidy_cont, tidy_bin)
saveRDS(all_selected, "selected_subgroups_all.rds")
} # }