@@ -29,8 +29,8 @@ knitr::opts_chunk$set(
2929 fig.height = 6
3030)
3131
32- nsims_alt <- 20L
33- nsims_null <- 20L
32+ nsims_alt <- 10L
33+ nsims_null <- 10L
3434
3535# Bootstrap 5 code-folding hook for pkgdown compatibility
3636# Usage: add `echo=FALSE, code_fold=TRUE` to any chunk header
@@ -460,51 +460,29 @@ cat("Overall HR:", round(dgm_calibrated_cox$hazard_ratios$overall,
460460timings$calibrate_cox <- proc.time()[3] - t0
461461```
462462
463- ### Calibrate to AHR
463+ ### Cox HR and AHR at Calibrated k_inter
464464
465- ``` {r calibrate-k-inter-ahr}
466- t0 <- proc.time()[3]
465+ ` find_k_inter_for_target_hr() ` calibrates to Cox-based HR in the harm subgroup.
466+ Once the optimal ` k_inter ` is found, both the Cox HR and the AHR (average hazard
467+ ratio via ` loghr_po ` ) can be read from the resulting DGM. These two metrics
468+ diverge slightly due to Jensen's inequality.
467469
468- # Same call, different target metric: AHR instead of Cox HR.
469- # Achieve AHR(H) = 2.0 by searching over k_inter with uniroot.
470- # (AHR and Cox-HR diverge slightly due to Jensen's inequality.)
471- cal_ahr <- find_k_inter_for_target_hr(
472- target_hr_harm = 2.0,
473- data = gbsg_data,
474- continuous_vars = dgm_cont_vars,
475- factor_vars = dgm_factor_vars,
476- outcome_var = "y",
477- event_var = "event",
478- treatment_var = "treat",
479- subgroup_vars = dgm_subgroup_vars,
480- subgroup_cuts = dgm_subgroup_cuts,
481- k_treat = 1.0,
482- verbose = TRUE
483- )
484-
485- dgm_calibrated_ahr <- cal_ahr$dgm
486- dgm_calibrated_ahr <- compute_dgm_cde(dgm_calibrated_ahr)
487-
488- cat("\nVerification (AHR-based):\n")
489- cat("Achieved AHR(H):", round(dgm_calibrated_ahr$hazard_ratios$AHR_harm, 3), "\n")
490- cat("AHR(Hc):", round(dgm_calibrated_ahr$hazard_ratios$AHR_no_harm, 3), "\n")
491- cat("Overall AHR:", round(dgm_calibrated_ahr$hazard_ratios$AHR, 3), "\n")
470+ ``` {r calibrate-k-inter-ahr}
471+ # The calibrated DGM already contains both Cox HR and AHR.
472+ # No separate AHR-targeted calibration is needed; just read both metrics
473+ # from dgm_calibrated_cox.
492474
493- timings$calibrate_ahr <- proc.time()[3] - t0
494- ```
475+ dgm_calibrated <- dgm_calibrated_cox
495476
496- ### Compare Cox HR vs AHR Calibration
497-
498- ``` {r compare-calibration}
499- cat("Comparison of calibration methods:\n")
500- cat(sprintf("%-20s %-12s %-12s\n", "Metric", "Cox-calib", "AHR-calib"))
501- cat(sprintf("%-20s %-12.4f %-12.4f\n", "k_inter", cal_cox$k_inter, cal_ahr$k_inter))
502- cat(sprintf("%-20s %-12.4f %-12.4f\n", "HR(H)",
503- dgm_calibrated_cox$hazard_ratios$harm_subgroup,
504- dgm_calibrated_ahr$hazard_ratios$harm_subgroup))
505- cat(sprintf("%-20s %-12.4f %-12.4f\n", "AHR(H)",
506- dgm_calibrated_cox$hazard_ratios$AHR_harm,
507- dgm_calibrated_ahr$hazard_ratios$AHR_harm))
477+ cat("Cox HR and AHR metrics at calibrated k_inter:\n")
478+ cat(sprintf(" k_inter (calibrated): %.4f\n", cal_cox$k_inter))
479+ cat(sprintf(" Cox HR(H): %.4f\n", dgm_calibrated$hazard_ratios$harm_subgroup))
480+ cat(sprintf(" Cox HR(Hc): %.4f\n", dgm_calibrated$hazard_ratios$no_harm_subgroup))
481+ cat(sprintf(" AHR(H): %.4f\n", dgm_calibrated$hazard_ratios$AHR_harm))
482+ cat(sprintf(" AHR(Hc): %.4f\n", dgm_calibrated$hazard_ratios$AHR_no_harm))
483+ cat(sprintf(" AHR(overall): %.4f\n", dgm_calibrated$hazard_ratios$AHR))
484+ cat(sprintf(" Note: Cox HR(H) ~ %.3f (target); AHR(H) differs due to Jensen's inequality\n",
485+ cal_cox$target_hr_harm))
508486```
509487
510488## Validating k_inter Effect on Heterogeneity
@@ -1680,7 +1658,6 @@ performance through simulation:
16801658** New aligned features:**
16811659
16821660- ** AHR metrics** : Alternative to Cox-based HR (from ` loghr_po ` )
1683- - ** ` use_ahr ` calibration** : Calibrate to AHR instead of Cox HR
16841661- ** ` use_twostage ` ** : Faster two-stage search algorithm option
16851662- ** Individual effects** : Access ` theta_0 ` , ` theta_1 ` , ` loghr_po ` per subject
16861663
0 commit comments