# Build comparison data frame
comparison_df <- data.frame(
Property = c(
"Formal name",
"Notation",
"Formula (subgroup S)",
"Averaging scale",
"Depends on epsilon_i",
"Reproducible across seeds",
"Accounts for covariate heterogeneity",
"Sensitive to outlier hazard contributions",
"Standard estimation method",
"Primary ForestSearch use",
"Key package variable(s)",
"Key package function(s)",
"Interpretation"
),
Marginal_HR = c(
"Marginal (causal) hazard ratio",
"HR_marg(S), theta-dagger",
"exp(beta_Cox) from stacked PO Cox model",
"Hazard ratio (Cox partial likelihood)",
"Yes",
"No (Monte Carlo variability)",
"Averaged out (population-level)",
"No (rank-based)",
"Cox PH on stacked potential outcomes",
"Estimation rows in build_estimation_table(); DGM validation",
"hr_causal, hr_H_true, hr_Hc_true, hr.H.hat, hr.Hc.hat",
"calculate_hazard_ratios(), setup_gbsg_dgm(), build_estimation_table()",
"Population-average HR as estimated by Cox regression on potential outcomes"
),
AHR = c(
"Average hazard ratio",
"AHR(S)",
"exp( mean(loghr_po_i) ) for i in S",
"Log-hazard (then exponentiated)",
"No",
"Yes (deterministic)",
"Geometric mean preserves individual effects",
"Moderate (log scale dampens extremes)",
"Arithmetic mean of individual log HRs",
"Estimation row in build_estimation_table(); primary subgroup characterization",
"loghr_po, ahr.H.hat, ahr.Hc.hat, ahr_H, ahr_Hc",
"cox_ahr_cde_analysis(), build_estimation_table()",
"Geometric mean of individual causal hazard ratios across subjects"
),
CDE = c(
"Controlled direct effect (hazard ratio)",
"CDE(S), theta-ddagger",
"mean(exp(theta_1_i)) / mean(exp(theta_0_i))",
"Hazard (natural scale ratio)",
"No",
"Yes (deterministic)",
"Ratio of mean hazards preserves scale",
"Yes (exponential scale amplifies large values)",
"Ratio of average exponentiated log-hazards",
"Estimation row in build_estimation_table(); biomarker-threshold analysis",
"theta_0, theta_1, cde.H.hat, cde.Hc.hat, cde_H, cde_Hc",
"cox_ahr_cde_analysis(), compute_dgm_cde(), build_estimation_table()",
"Ratio of average hazard contributions under treatment vs. control"
),
stringsAsFactors = FALSE
)
# Create publication-quality gt table
gt(comparison_df) |>
cols_label(
Property = "",
Marginal_HR = md("**Marginal HR**"),
AHR = md("**AHR**"),
CDE = md("**CDE**")
) |>
cols_width(
Property ~ px(260),
Marginal_HR ~ px(280),
AHR ~ px(280),
CDE ~ px(280)
) |>
tab_header(
title = md("**Comparison of Treatment Effect Definitions**"),
subtitle = md(
"Marginal HR, Average Hazard Ratio, and Controlled Direct Effect"
)
) |>
tab_source_note(
source_note = md(
paste0(
"Based on the potential outcomes framework within the ",
"ForestSearch AFT data-generating mechanism. ",
"See Le\u00f3n et al. (2024), *Statistics in Medicine*."
)
)
) |>
tab_row_group(
label = md("**Definition**"),
rows = 1:3
) |>
tab_row_group(
label = md("**Statistical Properties**"),
rows = 4:8
) |>
tab_row_group(
label = md("**Computation**"),
rows = 9:11
) |>
tab_row_group(
label = md("**Interpretation & Use**"),
rows = 12:13
) |>
row_group_order(
groups = c("**Definition**", "**Statistical Properties**",
"**Computation**", "**Interpretation & Use**")
) |>
tab_style(
style = list(
cell_fill(color = "#F0F4F8"),
cell_text(weight = "bold", size = "small")
),
locations = cells_row_groups()
) |>
tab_style(
style = cell_text(weight = "bold", size = "small"),
locations = cells_body(columns = Property)
) |>
tab_style(
style = cell_text(size = "small"),
locations = cells_body(columns = c(Marginal_HR, AHR, CDE))
) |>
tab_style(
style = list(
cell_fill(color = "#E8F4E8")
),
locations = cells_body(
columns = c(Marginal_HR, AHR, CDE),
rows = c(5, 6)
)
) |>
tab_style(
style = cell_borders(
sides = "bottom",
color = "#B0BEC5",
weight = px(1)
),
locations = cells_body(rows = c(3, 8, 11))
) |>
tab_options(
table.font.size = px(13),
heading.title.font.size = px(16),
heading.subtitle.font.size = px(13),
column_labels.font.weight = "bold",
table.border.top.color = "#2C3E50",
table.border.bottom.color = "#2C3E50",
row_group.border.top.color = "#B0BEC5",
row_group.border.bottom.color = "#B0BEC5",
source_notes.font.size = px(11)
) |>
tab_style(
style = list(
cell_fill(color = "#2C3E50"),
cell_text(color = "white", weight = "bold")
),
locations = cells_column_labels()
)