Skip to content

Develop gs_cp_ahr following gsDesign::gsCP#550

Merged
LittleBeannie merged 41 commits into
mainfrom
547-develop-gs_cp-following-gsdesigngscp
May 7, 2026
Merged

Develop gs_cp_ahr following gsDesign::gsCP#550
LittleBeannie merged 41 commits into
mainfrom
547-develop-gs_cp-following-gsdesigngscp

Conversation

@LittleBeannie
Copy link
Copy Markdown
Collaborator

@LittleBeannie LittleBeannie commented May 23, 2025

To solve issue #547.

@LittleBeannie LittleBeannie requested a review from keaven May 28, 2025 15:07
LittleBeannie and others added 5 commits October 15, 2025 14:33
2. clean up the comments
3. fixed the details braces issue
4. update the beta the last upper bound, which should be the futility bound from a, not b
Copy link
Copy Markdown
Collaborator

@jdblischak jdblischak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few suggestions for improvements. Overall this looks good. I like the developer tests.

Also, with 28 commits made over multiple months, this PR is a good candidate for the "Squash and Merge" feature. Having a single commit for the implementation of gs_cp_npe2() makes future troubleshooting easier

Comment thread R/gs_cp_npe2.R Outdated
info = NULL,
a = NULL,
b = NULL,
c = NULL){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variable names are very short for a function that is exposed to end users. Are these single letters easily recognizable to practitioners, eg from a well-known formula?

If not, I would recommend giving them more informative names. You can always re-assign them to shorter names inside the function if this aids the readability of the code.

Comment thread R/gs_cp_npe2.R Outdated
prob_alpha_plus <- rep(0, n_future_analysis)
prob_beta <- rep(0, n_future_analysis)

for(x in 1:n_future_analysis){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using seq_len() here as you do below

Comment thread R/gs_cp_npe2.R Outdated
# vector of length x
# ------------------------------ #

mu <- sapply(seq_len(x), function(k){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vapply() is safer to use inside of a function

Connecting with my comment above about the variable names. If you converted this anonymous function to a named function, you could name its argument as t and then pass the longer variable name to it.

Comment thread R/gs_update_ahr.R
# ----------------------------------- #
ans <- list()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this unnecessary whitespace

\begin{table}[t]
\caption*{
{\large Fixed Design under AHR Method\textsuperscript{\textit{1}}}
{\fontsize{20}{25}\selectfont Fixed Design under AHR Method\textsuperscript{\textit{1}}\fontsize{12}{15}\selectfont }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes to the snapshot test still needed now that #589 was merged?

Comment thread R/gs_cp.R Outdated
#' \deqn{P(\{Z_j \leq b_j\} \& \{\cap_{m=i+1}^{j-1} a_m \leq Z_m < b_m\} \mid Z_i = z_i)}.
#'
#' @param x An object of type gsDesign2.
#' @param theta Optional numeric vector with length \eqn{j-i+1}, which specifies the natural parameter for treatment effect of interim analysis \eqn{i} through analysis \eqn{j}.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indicate the default value of theta, i.e., we impute the default theta = NULL as the planned treatment effect.

Comment thread R/gs_cp.R Outdated
#' @param theta Optional numeric vector with length \eqn{j-i+1}, which specifies the natural parameter for treatment effect of interim analysis \eqn{i} through analysis \eqn{j}.
#' @param i Index of current analysis, with default of 1.
#' @param zi Numeric scalar z-value observed at analysis \eqn{i}.
#' @return A list of conditional powers: prob_alpha is a numeric vector of (\eqn{alpha_i,i+1, ..., alpha_i,j-1, alpha_i,j}), where alpha_i,j = \eqn{P(\{Z_j \geq b_j\} \& \{\cap_{m=i+1}^{j-1} a_m \leq Z_m < b_m\} \mid Z_i = z_i)}.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prob_alpha --> prob_alpha
prob_alpha --> prob_alpha_plus
prob_beta --> prob_beta

Comment thread R/gs_cp.R Outdated
#' gs_cp(x = x, i = 1, zi = -gsDesign::hrn2z(hr = 0.8, n = 150+180, ratio = 1))
#'
#' # case 2: currently at IA1, compute conditional power at IA2, IA3 and FA, with user-input theta
#' gs_cp(x = x, i = 1, zi = -gsDesign::hrn2z(hr = 0.8, n = 150+180, ratio = 1))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the case 2 is the same as case 1. Could you please check on your end?

Comment thread R/gs_cp_simple.R Outdated
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#' Conditional power computation with non-constant effect size
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditional power computation with non-constant effect size
-->
Simple conditional power computation with non-constant effect size

Comment thread R/gs_cp_npe1.R Outdated
@@ -19,38 +19,34 @@
#' Conditional power computation with non-constant effect size
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this gs_cp_npe1 function a general calculator of simple coditional power? If so, coule you please indicate it in the title at line 19?

@LittleBeannie LittleBeannie merged commit 8d25b8c into main May 7, 2026
7 checks passed
@LittleBeannie LittleBeannie deleted the 547-develop-gs_cp-following-gsdesigngscp branch May 7, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Develop gs_cp for general CP and gs_cp_simple for simple CP

3 participants