Add harm bound to AHR designs#640
Conversation
This reverts commit 9b59c45.
The helper-support-as_rtf.R is auto-sourced by testit, so the explicit source() call failed during R CMD check. Also update as_gt and as_rtf snapshots to reflect the new bound ordering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Run roxygenize to sync Rd files with code (fixes WARNING) - Remove test-independent-as_rtf.R (the .md snapshot is sufficient) - Replace all() with bare logical vector in test assertions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…alone Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Note on snapshot test changesThe This means every analysis section in both The other visible change in |
|
Correction on the alignment change: the |
|
Thank you @yihui for helping with the |
| #' | ||
| #' # Example 8 ---- | ||
| #' # Design with an additional harm bound | ||
| #' \donttest{ |
There was a problem hiding this comment.
Note to self: we use \donttest{} here to avoid long-running example code
xref: #147
| } | ||
| \fontsize{12.0pt}{14.0pt}\selectfont | ||
| \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} | ||
| \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}crrrrr} |
There was a problem hiding this comment.
In the future, I think it would be cleaner if we fixed snapshot test churn in a separate PR
There was a problem hiding this comment.
Yes, that's a good idea.
Previously we skipped these tests on CRAN (via skip_on_cran()) so we have been passively accepting upstream {gt} changes, which I find quite annoying. Now these tests run unconditionally, so we have at least one vote in our hands to restrict {gt}---if they make such changes again, they will have to rethink and inform us in advance, otherwise they will break our tests.
| if (nrow(row_bound) == 0) return(rep(NA_real_, length(columns))) | ||
| as.numeric(unlist(row_bound[1, columns], use.names = FALSE)) | ||
| } | ||
|
|
There was a problem hiding this comment.
This refactoring looks good
| harm_bound <- x |> dplyr::filter(bound == "harm") |> dplyr::pull(z) | ||
| futility_bound <- x |> dplyr::filter(bound == "lower") |> dplyr::pull(z) | ||
| (harm_bound <= futility_bound) | ||
| }) |
There was a problem hiding this comment.
Please instruct the AI to write unit tests for every function that it edits
|
|
||
| # One-sided design should not include Futility column | ||
| if (all(is.na(out[["Futility"]]))) out[["Futility"]] <- NULL | ||
| if (all(is.na(out[["Harm"]]))) out[["Harm"]] <- NULL |
There was a problem hiding this comment.
Changes look good when I tested locally, but this needs some unit tests for long-term maintenance. For example, confirm that a one-sided design does not return the column Harm
| #' single value of `TRUE` (default) indicates all analyses; | ||
| #' single value of `FALSE` indicates no harm bound; otherwise, | ||
| #' a logical vector of the same length as `info` should | ||
| #' indicate which analyses will have a harm bound. |
There was a problem hiding this comment.
What is the relationship between test_harm and test_lower? Is it theoretically possible to have a harm bound but not a futility bound?
From my local testing, it appears that a harm bound is only included if both test_harm and test_lower are TRUE for a given analysis. If this is the expected behavior, please document this. If it does not make sense to have a harm bound when there is no futility bound, then we should also consider throwing an error if test_harm is TRUE and test_lower is FALSE.
| upper = gs_b, upar = -qnorm(0.025), test_upper = TRUE, | ||
| lower = gs_b, lpar = -1, test_lower = TRUE, | ||
| harm = gs_b, hpar = -2, test_harm = TRUE | ||
| ) |
There was a problem hiding this comment.
Does it make sense to compute and return a futility or harm bound when there is only a single analysis?
If I run this with test_harm = FALSE, it only returns an efficacy bound for the single analysis. But with test_harm = TRUE, it returns all 3 bounds (efficacy, futility, harm).
To solve issue #618.
@jdblischak: In addition to "Efficacy" and "Futility" bound, I added "Harm" bound, which sequentially leads to some changes in
gs_bound_summary(). The changes ings_bound_summary()is suggested by GPT5.5. Could you please review if these AI-suggested changes looks good to you?