Runs bootstrap analysis for ForestSearch, fitting Cox models and computing bias-corrected estimates and valid CIs (see vignette for references)
bootstrap_results(
fs.est,
df_boot_analysis,
cox.formula.boot,
nb_boots,
show_three,
H_obs,
Hc_obs,
seed = 8316951L
)Data.table with one row per bootstrap iteration and columns:
Integer. Bootstrap iteration number (1 to nb_boots)
Bias-corrected estimate for H using method 1:
H_obs - (Hstar_star - Hstar_obs)
Bias-corrected estimate for H using method 2:
2*H_obs - (H_star + Hstar_star - Hstar_obs)
Bias-corrected estimate for H^c using method 1
Bias-corrected estimate for H^c using method 2
Numeric. Maximum subgroup hazard ratio found
Integer. Number of candidate factors evaluated
Integer. Maximum number of factor combinations
Integer. Number of events in control arm of original subgroup H on bootstrap sample
Integer. Number of events in treatment arm of original subgroup H on bootstrap sample
Integer. Number of events in control arm of original subgroup H^c on bootstrap sample
Integer. Number of events in treatment arm of original subgroup H^c on bootstrap sample
Integer. Number of events in control arm of new subgroup H* on original data
Integer. Number of events in treatment arm of new subgroup H* on original data
Integer. Number of events in control arm of new subgroup H^c* on original data
Integer. Number of events in treatment arm of new subgroup H^c* on original data
Numeric. Minutes spent on subgroup search in this iteration
Numeric. Total minutes for this bootstrap iteration
Numeric. Consistency p-value for top subgroup
Numeric. Hazard ratio for top subgroup
Integer. Sample size of top subgroup
Integer. Number of events in top subgroup
Integer. Number of factors defining top subgroup
Numeric. Subgroup group ID
Numeric. Subgroup index
Character. First factor label
Character. Second factor label
Character. Third factor label
Character. Fourth factor label
Character. Fifth factor label
Character. Sixth factor label
Character. Seventh factor label
Rows where no valid subgroup was found will have NA for bias corrections.
The returned object has a "timing" attribute with summary statistics.
List. ForestSearch results object from forestsearch.
Must contain:
df.est: Data frame with analysis data including treat.recommend
confounders.candidate: Character vector of confounder names
args_call_all: List of original forestsearch call arguments
Data frame. Bootstrap analysis data with same structure
as fs.est$df.est. Must contain columns for outcome, event, treatment,
and the treat.recommend flag.
Formula. Cox model formula for bootstrap, typically
created by build_cox_formula. Should be of form
Surv(outcome, event) ~ treatment.
Integer. Number of bootstrap samples to generate (e.g., 500-1000). More iterations provide better bias correction but increase computation time.
Logical. If TRUE, prints detailed progress for the
first three bootstrap iterations for debugging purposes. Default: FALSE.
Numeric. Observed log hazard ratio for subgroup H (harm/questionable group,
treat.recommend == 0) from original sample. Used as reference for
bias correction.
Numeric. Observed log hazard ratio for subgroup H^c (complement/recommend,
treat.recommend == 1) from original sample. Used as reference for
bias correction.
Integer. Random seed for reproducibility. Default 8316951L.
Must match the seed used in bootstrap_ystar to ensure
bootstrap index alignment.
Two bias correction approaches are implemented:
Method 1 (Simple Optimism): $$H_{adj1} = H_{obs} - (H^*_{*} - H^*_{obs})$$ where \(H^*_{*}\) is the new subgroup HR on bootstrap data and \(H^*_{obs}\) is the new subgroup HR on original data.
Method 2 (Double Bootstrap): $$H_{adj2} = 2 \times H_{obs} - (H_{*} + H^*_{*} - H^*_{obs})$$ where \(H_{*}\) is the original subgroup HR on bootstrap data.
where:
H_obs: Original subgroup HR on original data
H_star: Original subgroup HR on bootstrap data
Hstar_obs: New subgroup (found in bootstrap) HR on original data
Hstar_star: New subgroup (found in bootstrap) HR on bootstrap data
Uses doFuture backend for parallel execution (configured externally)
Sets reproducible seeds: 8316951 + boot * 100 for each iteration
Each bootstrap iteration runs full ForestSearch pipeline including variable selection, subgroup search, and consistency evaluation
Sequential execution within each bootstrap prevents nested parallelization
Failed bootstrap iterations generate warnings but don't stop execution
Confounders are removed from bootstrap data to force fresh variable selection
Each bootstrap iteration modifies ForestSearch arguments to:
Suppress output: details, showten_subgroups,
plot.sg, plot.grf all set to FALSE
Force re-selection: grf_res and grf_cuts set to NULL
Prevent nested parallel: parallel_args$plan = "sequential",
workers = 1
Typical runtime: 1-5 seconds per bootstrap iteration
For 1000 bootstraps with 6 workers: ~3-10 minutes total
Memory usage scales with dataset size and number of workers
Consider reducing nb_boots for initial testing (e.g., 100)
The function gracefully handles three failure modes:
Bootstrap sample creation fails: Returns row with all NA
ForestSearch fails to run: Warns and returns row with all NA
ForestSearch runs but finds no subgroup: Returns row with all NA
All three cases ensure the foreach loop can still combine results via rbind.
forestsearch_bootstrap_dofuture for the wrapper function that
sets up parallelization and calls this function
build_cox_formula for creating the Cox formula
fit_cox_models for initial Cox model fitting
get_Cox_sg for Cox model fitting on subgroups
get_dfRes for processing bootstrap results into confidence intervals
bootstrap_ystar for generating the Ystar matrix