Skip to contents

Core Algorithm

Main forestsearch function, subgroup selection, and consistency evaluation.

forestsearch()
ForestSearch: Exploratory Subgroup Identification
print(<forestsearch>)
Print Method for forestsearch Objects
summary(<forestsearch>)
Summary Method for forestsearch Objects
plot(<forestsearch>)
Plot ForestSearch Results
select_best_subgroup()
Select best subgroup based on criterion
subgroup.consistency()
Evaluate Subgroup Consistency

Bootstrap Bias Correction

Bootstrap methods for bias-corrected hazard ratio estimation using infinitesimal jackknife variance estimation (Leon et al., 2024).

forestsearch_bootstrap_dofuture()
ForestSearch Bootstrap with doFuture Parallelization
summarize_bootstrap_results()
Enhanced Bootstrap Results Summary
summarize_bootstrap_events()
Summarize Bootstrap Event Counts

Cross-Validation

K-fold and repeated cross-validation for assessing subgroup identification stability and agreement metrics.

forestsearch_Kfold()
ForestSearch K-Fold Cross-Validation
forestsearch_tenfold()
ForestSearch Repeated K-Fold Cross-Validation
forestsearch_KfoldOut()
ForestSearch K-Fold Cross-Validation Output Summary
cv_summary_tables()
Create Summary Tables from forestsearch_KfoldOut Results
cv_metrics_tables()
Create Metrics Tables for Cross-Validation Results
print(<fs_kfold>)
Print Method for K-Fold CV Results
print(<fs_tenfold>)
Print Method for Repeated K-Fold CV Results

GRF Integration

Generalized Random Forest methods for heterogeneous treatment effect estimation and variable importance screening.

grf.subg.harm.survival()
GRF Subgroup Identification for Survival Data

Cox Model Utilities

Cox proportional hazards model wrappers with robust standard errors, spline fitting, and average hazard ratio calculations.

cox_summary()
Cox model summary for subgroup (OPTIMIZED)
cox_ahr_cde_analysis()
Comprehensive Wrapper for Cox Spline Analysis with AHR and CDE Plotting
print(<cox_ahr_cde>)
Print method for cox_ahr_cde objects
summary(<cox_ahr_cde>)
Summary method for cox_ahr_cde objects
cox_cs_fit()
Fit Cox Model with Cubic Spline for Treatment Effect Heterogeneity

Subgroup Tables & Estimates

Formatted tables of subgroup estimates.

sg_tables()
Enhanced Subgroup Summary Tables (gt output)
create_summary_table()
Create Enhanced Summary Table for Baseline Characteristics

Visualization

Publication-ready plotting functions for forest plots, survival curves, subgroup characteristics, and detection probability curves.

gg_forest()
ggplot2 / patchwork forest plot
plot_subgroup_results_forestplot()
Plot Subgroup Results Forest Plot
render_forestplot()
Render ForestSearch Forest Plot
create_forest_theme()
Create Forest Plot Theme with Size Controls
plot_km_band_forestsearch()
Plot Kaplan-Meier Survival Difference Bands for ForestSearch Subgroups
plot_sg_weighted_km()
Plot Weighted Kaplan-Meier Curves for ForestSearch Subgroups
figure_note()
Generate Figure Note for Quarto/RMarkdown
plot_spline_treatment_effect()
Plot Spline Treatment Effect Function
plot_detection_curve()
Plot Detection Probability Curve

Data Generating Mechanisms

Functions for creating data generating mechanisms (DGMs) for simulation studies with configurable treatment effect heterogeneity.

generate_aft_dgm_flex()
Generate Synthetic Survival Data using AFT Model with Flexible Subgroups
setup_gbsg_dgm()
Set Up a GBSG-Based AFT Data Generating Mechanism
print(<gbsg_dgm>)
Print Method for gbsg_dgm Objects
compute_dgm_cde()
Compute and Attach CDE Values to a DGM Object
simulate_from_dgm()
Simulate Survival Data from AFT Data Generating Mechanism
calibrate_cens_adjust()
Calibrate Censoring Adjustment to Match DGM Reference Distribution
check_censoring_dgm()
Diagnose Censoring Consistency Between DGM Source Data and Simulated Data
calibrate_k_inter()
Calibrate k_inter for Target Subgroup Hazard Ratio
validate_k_inter_effect()
Validate k_inter Effect on HR Heterogeneity

Simulation Studies

Running and summarizing simulation studies for operating characteristics.

run_simulation_analysis()
Run One Simulation Replicate
summarize_simulation_results()
Summarize Simulation Results
format_oc_results()
Format Operating Characteristics Results as GT Table
build_classification_table()
Build Classification Rate Table from Simulation Results
build_estimation_table()
Build Estimation Properties Table from Simulation Results
interpret_estimation_table()
Generate Narrative Interpretation of Estimation Properties
render_reference_table()
Render Reference Simulation Table as gt
compute_detection_probability()
Compute Probability of Detecting True Subgroup
generate_detection_curve()
Generate Detection Probability Curve

Multi-Regional Clinical Trials

Specialized functions for multi-regional clinical trial (MRCT) subgroup analysis with regional consistency evaluation.

mrct_region_sims()
MRCT Regional Subgroup Simulation
create_dgm_for_mrct()
Create Data Generating Mechanism for MRCT Simulations

Internal

Internal implementation details. These functions are not intended to be called directly by users.

CV_sgs()
Cross-Validation Subgroup Match Summary
FS_labels()
Convert Factor Code to Label
SG_tab_estimates()
Subgroup summary table estimates
SGplot_estimates()
Violin/Boxplot Visualization of HR Estimates
acm.disjctif()
Disjunctive (dummy) coding for factor columns
add_id_column()
Add ID Column to Data Frame
add_unprocessed_vars()
Add Unprocessed Variables from Original Data
analyze_subgroup()
Analyze subgroup for summary table (OPTIMIZED)
apply_spline_constraint()
Apply Spline Constraint to Treatment Effect Coefficients
assemble_results()
Assemble Final Results Object
assign_subgroup_membership()
Assign data to subgroups based on selected node
bootstrap_results()
Bootstrap Results for ForestSearch with Bias Correction
bootstrap_ystar()
Bootstrap Ystar Matrix
build_cox_formula()
Build Cox Model Formula
calc_cov()
Calculate Covariance for Bootstrap Estimates
calculate_counts()
Calculate counts for subgroup summary
calculate_event_counts()
Calculate Event Counts by Treatment Arm
calculate_hazard_ratios()
Calculate Hazard Ratios from Potential Outcomes
calculate_linear_predictors()
Calculate Linear Predictors for Potential Outcomes
calculate_max_combinations()
Calculate Maximum Combinations
calculate_potential_hr()
Calculate potential outcome hazard ratio
calculate_skewness()
Calculate Skewness
ci_est()
Confidence Interval for Estimate
compare_detection_curves()
Compare Detection Curves Across Sample Sizes
compare_multiple_survreg()
Compare Multiple Survival Regression Models
compute_ahr()
Compute AHR from loghr_po
compute_cde()
Compute CDE from theta_0 and theta_1
compute_detection_probability_single()
Compute Detection Probability for Single Theta (Internal)
compute_node_metrics()
Compute node metrics for a policy tree
compute_sg_hr()
Compute Hazard Ratio for a Single Subgroup
compute_sg_hr_estimates()
Compute Hazard Ratio Estimates for Subgroups
compute_sg_summary()
Compute Summary Statistics for Subgroups
count_boot_id()
Count ID Occurrences in Bootstrap Sample
cox_summary_batch()
Batch Cox summaries with caching
cox_summary_vectorized()
Cox model summary for subgroup - vectorized version
create_bootstrap_caption()
Calculate Bootstrap Table Caption
create_bootstrap_diagnostic_plots()
Create Bootstrap Diagnostic Plots
create_factor_summary_tables()
Create Factor Summary Tables from Bootstrap Results
create_fs_subgroup_indicators()
Create Subgroup Indicator Columns from ForestSearch
create_gbsg_dgm()
Create GBSG-Based AFT Data Generating Mechanism
create_grf_config()
Helper Functions for GRF Subgroup Analysis
create_null_result()
Create result object when no subgroup is found
create_reference_subgroup_columns()
Create Reference Subgroup Indicator Columns
create_result_row()
Create Result Row
create_sample_size_table()
Create Sample Size Table for Multiple Scenarios
create_spline_variables()
Create Spline Variables
create_subgroup_indicator()
Create Subgroup Indicator from Factor Definitions
create_subgroup_summary_df()
Create Subgroup Summary Data Frame for Forest Plot
create_success_result()
Create result object for successful subgroup identification
create_summary_table_compact()
Preset: Compact Table
create_summary_table_minimal()
Preset: Minimal Table (No Highlighting, No Alternating)
create_summary_table_presentation()
Preset: Presentation Table (Large Fonts)
create_summary_table_publication()
Preset: Publication-Ready Table
create_timing_summary_table()
Create Timing Summary Table
cut_numeric()
Discretize Continuous Variable into Quantile-Based Categories
cut_size()
Discretize Continuous Variable by Size Categories
cut_var()
Generate cut expressions for a variable
cv_compare_results()
Compare Multiple CV Results
cv_summary_text()
Create Compact CV Summary Text
default_fs_params()
Default ForestSearch Parameters for GBSG Simulations
default_grf_params()
Default GRF Parameters for GBSG Simulations
default_grf_params_gen()
Default GRF parameters (general)
default_sim_params()
Default ForestSearch parameters (general)
define_subgroups()
Define Subgroups with Flexible Cutpoints
density_threshold_both()
Bivariate Density for Split-Sample HR Threshold Detection
density_threshold_integrand()
Vectorized Density for Integration
detect_variable_types()
Automatically Detect Variable Types in a Dataset
dummy_encode()
Dummy-code a data frame (numeric pass-through, factors expanded)
early_stop_decision()
Early Stopping Decision
evaluate_combination_with_status()
Evaluate a Single Factor Combination with Status Tracking
evaluate_comparison()
Evaluate a Comparison Expression Without eval(parse())
evaluate_consistency_twostage()
Evaluate Consistency (Two-Stage Algorithm)
evaluate_cuts_once()
Cache and validate cut expressions efficiently
evaluate_subgroup_consistency()
Evaluate Single Subgroup for Consistency (Fixed-Sample)
extract_all_tree_cuts()
Extract all cuts from fitted trees
extract_fs_estimates()
Extract Estimates from ForestSearch Results
extract_fs_subgroup_definition()
Extract Subgroup Definition from ForestSearch Object
extract_grf_estimates()
Extract Estimates from GRF Results
extract_idx_flagredundancy()
Extract redundancy flag for subgroup combinations
extract_selected_tree_cuts()
Extract cuts from selected tree only
extract_subgroup()
Extract Subgroup Information
extract_tree_cuts()
Extract cut information from a policy tree
filter_by_lassokeep()
Filter a vector by LASSO-selected variables
filter_call_args()
Filter and merge arguments for function calls
find_covariate_any_match()
Find Covariate Any Match
find_k_inter_for_target_hr()
Find k_inter Value to Achieve Target Harm Subgroup Hazard Ratio
find_leaf_split()
Find the split that leads to a specific leaf node
find_quantile_for_proportion()
Find Quantile for Target Subgroup Proportion
find_required_sample_size()
Find Minimum Sample Size for Target Detection Power
fit_aft_model()
Fit AFT Model with Optional Spline Treatment Effect
fit_aft_model_spline()
Fit AFT Model with Spline Treatment Effect
fit_aft_model_standard()
Fit Standard AFT Model (Non-Spline)
fit_causal_forest()
Fit causal survival forest
fit_cox_for_subgroup()
Fit Cox Model for Subgroup
fit_cox_models()
Fit Cox Models for Subgroups
fit_policy_trees()
Fit policy trees up to specified depth
forestsearch-package forestsearch-imports
forestsearch: Exploratory Subgroup Identification in Clinical Trials with Survival Endpoints
format_CI()
Format Confidence Interval for Estimates
format_bootstrap_diagnostics_table()
Format Bootstrap Diagnostics Table with gt
format_bootstrap_table()
Format Bootstrap Results Table with gt
format_bootstrap_timing_table()
Format Bootstrap Timing Table with gt
format_continuous_definition()
Format Continuous Variable Definition for Display
format_fs_details()
Format ForestSearch Details Output for Beamer Two-Column Display
format_results()
Format results for subgroup summary
format_search_results()
Format Search Results
format_subgroup_summary_tables()
Format Subgroup Summary Tables with gt
generate_bootstrap_synthetic()
Generate Synthetic Data using Bootstrap with Perturbation
generate_bootstrap_with_noise()
Generate Bootstrap Sample with Added Noise
generate_combination_indices()
Generate Combination Indices
generate_complement_expression()
Generate Complement Expression
generate_gbsg_bootstrap_general()
Generate Synthetic GBSG Data using Generalized Bootstrap
generate_readable_sg_labels()
Generate Readable Subgroup Labels from ForestSearch Object
generate_super_population()
Generate Super Population and Calculate Linear Predictors
get_Cox_sg()
Fit Cox Model for Subgroup
get_FSdata()
ForestSearch Data Preparation and Feature Selection
get_best_survreg()
Get Best Model from Comparison
get_bootstrap_exports()
Get all exported functions from ForestSearch namespace
get_combinations_info()
Get all combinations of subgroup factors up to maxk
get_conf_force()
Get forced cut expressions for variables
get_covs_in()
Get indicator vector for selected subgroup factors
get_cut_name()
Get variable name from cut expression
get_dfRes()
Bootstrap Confidence Interval and Bias Correction Results
get_dfpred()
Generate Prediction Dataset with Subgroup Treatment Recommendation
get_dgm_hr()
Extract HR from DGM (Backward Compatible)
get_dgm_with_output()
Create DGM with Output File Path
get_param()
Get Parameter with Default Fallback
get_split_hr_fast()
Fast Cox Model HR Estimation
get_subgroup_membership()
Get subgroup membership vector
get_targetEst()
Target Estimate and Standard Error for Bootstrap
grf.subg.eval()
GRF Subgroup Evaluation and Performance Metrics
has_positive_variance()
Check if Matrix Has Positive Variance
hrCI_format()
Format Hazard Ratio and Confidence Interval
is.continuous()
Check if a variable is continuous
is_flag_continuous()
Check if cut expression is for a continuous variable (OPTIMIZED)
is_flag_drop()
Check if cut expression should be dropped
km_summary()
KM median summary for subgroup
lasso_selection()
LASSO selection for Cox model
meets_event_criteria()
Check Event Count Criteria
meets_prevalence_threshold()
Check Prevalence Threshold
n_pcnt()
Calculate n and percent
parse_sg_harm_to_expression()
Parse sg.harm Factor Names to Expression
plot(<fs_forestplot>)
Plot Method for ForestSearch Forest Plot
plot(<fs_sg_plot>)
Plot Method for fs_sg_plot Objects
plot_sg_distribution()
Plot Distribution of Identified Subgroups
plot_sg_forest()
Plot Forest Plot of Hazard Ratios
plot_sg_km()
Plot Kaplan-Meier Survival Curves for Subgroups
plot_sg_results()
Plot ForestSearch Subgroup Results
plot_sg_summary_panel()
Plot Summary Statistics Panel
plot_subgroup()
Plot Subgroup Survival Curves
plot_subgroup_effects()
Plot Subgroup Analysis Results
prepare_censoring_model()
Prepare Censoring Model Parameters
prepare_search_data()
Prepare Data for Subgroup Search
prepare_subgroup_data()
Prepare subgroup data for analysis
prepare_working_dataset()
Prepare Working Dataset with Processed Covariates
print(<fs_forest_theme>)
Print Method for ForestSearch Forest Theme
print(<fs_forestplot>)
Print Method for ForestSearch Forest Plot
print(<fs_sg_plot>)
Print Method for fs_sg_plot Objects
print(<fs_weighted_km>)
Print Method for fs_weighted_km Objects
print(<multi_survreg_comparison>)
Print method for survreg_comparison objects
print_cv_params()
Print CV ForestSearch Parameters
print_grf_details()
Print detailed output for debugging
process_conf_force_expr()
Process forced cut expression for a variable
process_continuous_subgroup()
Process Continuous Variable for Subgroup Definition
process_continuous_vars()
Process Continuous Variables
process_cutpoint()
Process Cutpoint Specification for Subgroup Definition
process_factor_subgroup()
Process Factor Variable for Subgroup Definition
process_factor_vars()
Process Factor Variables with Largest Value as Reference
qhigh()
75th Percentile (Quantile High)
qlow()
25th Percentile (Quantile Low)
quick_km_band_plot()
Quick Plot KM Bands from ForestSearch
remove_near_duplicate_subgroups()
Remove Near-Duplicate Subgroups
remove_redundant_subgroups()
Remove Redundant Subgroups
resolve_bootstrap_parallel_args()
Resolve parallel processing arguments for bootstrap
resolve_cv_parallel_args()
Resolve Parallel Arguments for Cross-Validation
rmst_calculation()
RMST calculation for subgroup
run_forestsearch_analysis()
Run ForestSearch Analysis
run_grf_analysis()
Run GRF Analysis
run_single_consistency_split()
Run Single Consistency Split
safe_eval_expr()
Evaluate an expression string in a data-frame scope
safe_subset()
Subset a data frame using an expression string
save_forestplot()
Save ForestSearch Forest Plot to File
sens_text()
Generate Cross-Validation Sensitivity Text
sensitivity_analysis_k_inter()
Sensitivity Analysis of Hazard Ratios to k_inter
setup_parallel_SGcons()
Set up parallel processing for subgroup consistency
sg_consistency_out()
Output Subgroup Consistency Results
simulate_from_gbsg_dgm()
Simulate Trial Data from GBSG DGM
sort_subgroups()
Sort Subgroups by Focus
sort_subgroups_preview()
Sort Subgroups by Focus at consistency stage (consistency not available at this point)
subgroup.search()
Subgroup Search for Treatment Effect Heterogeneity (Improved, Parallelized)
summarize_bootstrap_subgroups()
Summarize Bootstrap Subgroup Analysis Results
summarize_factor_presence_robust()
Summarize Factor Presence Across Bootstrap Subgroups
summarize_single_analysis()
Summarize Single Analysis Results
summaryout_mrct()
Summary Tables for MRCT Simulation Results
validate_grf_data()
Validate input data for GRF analysis
validate_inputs()
Validate Input Parameters
validate_mrct_data()
Validate Dataset for MRCT Simulations
validate_spline_spec()
Validate Spline Specification
wilson_ci()
Wilson Score Confidence Interval