Add tbl_ancova() for ANCOVA tables with treatment-vs-control contrasts#232
Add tbl_ancova() for ANCOVA tables with treatment-vs-control contrasts#232Melkiades wants to merge 21 commits into
tbl_ancova() for ANCOVA tables with treatment-vs-control contrasts#232Conversation
16d7fc0 to
6f345f9
Compare
Unit Tests Summary 1 files 242 suites 3m 20s ⏱️ Results for commit d30fab6. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit 3ab224b ♻️ This comment has been updated with latest results. |
Code Coverage SummaryDiff against mainResults for commit: d30fab6 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
|
✅ All contributors have signed the CLA |
|
Fixed a column-swap bug in Root cause: Fix (commit a86b83e): The denominator header logic now reads the actual column-to-group mapping from |
a86b83e to
ec43a1c
Compare
Default is adjust = "none" (unadjusted, matching tern behavior). Users can specify "dunnett", "bonferroni", etc.
- remove ADaM BDS terminology (crane is open-source) - change `@examplesIf` to `@examples`, remove `theme_gtsummary_roche()` - add denominator and Dunnett examples - add descriptive comments on `.build_ancova_ard` and `.escape_regex` - add example values in contrast label parsing comment - simplify `map2` to `map` in `fmt_fun` - store by, adjust, method attributes on returned object - use `expect_snapshot` for error test - add header N verification in denominator test - add attribute and label checks in Dunnett and no-covariates tests
…add package attr
- replace purrr::map() with standalone map() in tbl_ancova - wrap strata/by in all_of() in tbl_mmrm to fix tidyselect deprecation - add ANCOVA, Dunnett's, modelling to WORDLIST - regenerate tbl_ancova.Rd, add test snapshots - apply styler formatting
…ygen2 8.0.0 - wrap arm/visit in all_of() in second process_selectors call in tbl_mmrm - regenerate Rd files with roxygen2 8.0.0 (fixes construct_model xref) - fix snapshot non-breaking space encoding
…le name Shows 'Change from Baseline' instead of 'CHG' in the table header row. Falls back to the variable name if no label attribute exists.
Defaults to the response variable's label attribute. When used inside tbl_strata(strata = PARAM), pass label = unique(.x$PARAM) so each sub-table shows the parameter name instead of the variable name.
tbl_ard_summary() assigns stat columns alphabetically by group level, but the denominator header logic ordered by factor levels (ref first). When the reference group was not alphabetically first (e.g. 'B: Placebo' vs 'A: Drug X'), headers were assigned to the wrong columns, making values appear under incorrect treatment arms. Fix reads the actual column-to-group mapping from the table styling instead of assuming factor level order.
2ba6ec2 to
fc1ce0f
Compare
|
recheck |
|
Review compared with camis and user sas Statistical method validationThe approach is correct and matches SAS. I verified against the CAMIS ANCOVA comparison page:
CAMIS summary: "The R ANCOVA analysis is comparable to SAS. Comparison between SAS and R show identical results." Issues1. Contrast label parsing breaks with hyphenated group names (bug)
# Reproducer:
df <- data.frame(y = rnorm(30), arm = factor(rep(c("Drug-X", "Drug-Y", "Placebo"), each = 10)))
# ... tbl_ancova will silently drop the contrast rows for Drug-X and Drug-Y |
What changes are proposed in this pull request?
tbl_ancova()builds ANCOVA tables with adjusted means and treatment-vs-control contrasts usingemmeans. (Newtbl_*()for LS means/ANCOVA #6, @garolind)The function fits a model via
cardx::construct_model(), computes LS means withemmeans::emmeans(), and obtains contrasts withemmeans::contrast(method = "trt.vs.ctrl"). Each non-reference group is compared to the reference group only (not all pairwise). The output is a gtsummary table showing n, adjusted mean, difference in adjusted means, CI, and p-value per treatment group.Key design decisions:
trt.vs.ctrlinstead ofpairwisecontrasts to match the standard ANCOVA table layout where each treatment is compared to a single control group.ref_groupargument to specify the control arm.denominatorargument for header Ns from a subject-level dataset.conf.levelfor configurable CI width (default 95%).method,method.args,packagefor flexible model specification.Reference GitHub issue associated with pull request. closes #6
Pre-review Checklist (if item does not apply, mark is as complete)
usethis::pr_merge_main()devtools::test_coverage()