Create Summary Tables from forestsearch_KfoldOut Results
Source:R/cv_summary_tables.R
cv_summary_tables.RdFormats the detailed output from forestsearch_KfoldOut(outall=TRUE)
into publication-ready gt tables. This includes ITT estimates, original subgroup
estimates, and K-fold subgroup estimates.
Usage
cv_summary_tables(
kfold_out,
title = "Cross-Validation Summary",
subtitle = NULL,
show_metrics = TRUE,
digits = 3,
font_size = 12,
use_gt = TRUE
)Arguments
- kfold_out
List. Result from
forestsearch_KfoldOut(res, outall = TRUE). Must containitt_tab,SG_tab_original,SG_tab_Kfold, and optionallytab_all.- title
Character. Main title for combined table. Default: "Cross-Validation Summary".
- subtitle
Character. Subtitle for table. Default: NULL (auto-generated).
- show_metrics
Logical. Include agreement and finding metrics in output. Default: TRUE.
- digits
Integer. Decimal places for numeric formatting. Default: 3.
- font_size
Integer. Font size in pixels. Default: 12.
- use_gt
Logical. Return gt table if TRUE, data.frame if FALSE. Default: TRUE.
Value
If use_gt = TRUE, returns a list with gt table objects:
combined_table: Combined ITT and subgroup estimatesitt_table: ITT estimates onlyoriginal_table: Original full-data subgroup estimateskfold_table: K-fold subgroup estimatesmetrics_table: Agreement and finding metrics (ifshow_metrics = TRUE)
If use_gt = FALSE, returns equivalent data.frames.
Details
The estimate tables are those of kfold_out, formatted without
recomputation. For GLM outcomes forestsearch_KfoldOut
builds their effect column with the fit's orientation (the fit's stored
adverse_outcome or, when none is stored,
forestsearch's rule: TRUE for binary and count
outcomes, FALSE otherwise), while, for a fit with the default
est.scale = "hr", the arm columns (Rate(C) or
Mean(C), Rate(T) or Mean(T)) and their raw
difference Diff (treated minus control) are the raw outcome. So
for an unadjusted fit where a lower outcome is adverse
(adverse_outcome = FALSE, the default for continuous outcomes)
the effect and Diff have opposite signs. Count outcomes and the
rate measures (IRR, IRD) are not reoriented. See
sg_tables for the details.
See also
cv_metrics_tables for formatting forestsearch_tenfold() results
Examples
if (FALSE) { # \dontrun{
# Run K-fold CV
cv_results <- forestsearch_Kfold(fs.est = fs_result, Kfolds = 10)
# Get detailed output
kfold_out <- forestsearch_KfoldOut(cv_results, outall = TRUE)
# Create summary tables
cv_tables <- cv_summary_tables(kfold_out)
cv_tables$combined_table
cv_tables$metrics_table
} # }