diff --git a/R/gs_design_ahr.R b/R/gs_design_ahr.R index 84633c09..d67cab8b 100644 --- a/R/gs_design_ahr.R +++ b/R/gs_design_ahr.R @@ -360,6 +360,7 @@ gs_design_ahr <- function( enroll_rate = enroll_rate, fail_rate = fail_rate, alpha = alpha, beta = beta, ratio = ratio, info_frac = info_frac, analysis_time = analysis_time, + info_scale = info_scale, upper = upper, upar = upar, lower = lower, lpar = lpar, test_upper = test_upper, test_lower = test_lower, diff --git a/R/gs_power_ahr.R b/R/gs_power_ahr.R index 85fd8f8f..09d0aa61 100644 --- a/R/gs_power_ahr.R +++ b/R/gs_power_ahr.R @@ -261,6 +261,7 @@ gs_power_ahr <- function( input <- list( enroll_rate = enroll_rate, fail_rate = fail_rate, event = event, analysis_time = analysis_time, + info_scale = info_scale, upper = upper, upar = upar, lower = lower, lpar = lpar, test_lower = test_lower, test_upper = test_upper, diff --git a/R/gs_update_ahr.R b/R/gs_update_ahr.R index 7ddee8af..2f4dd728 100644 --- a/R/gs_update_ahr.R +++ b/R/gs_update_ahr.R @@ -296,8 +296,16 @@ gs_update_ahr <- function( x_updated_h0 <- gs_power_npe(theta = 0, theta0 = 0, theta1 = x$analysis$theta, + # statistical information at all analyses for input `theta` info = x$analysis$info0, - info_scale = "h0_info", + # statistical information under null hypothesis, + # impacts null hypothesis bound calculation. + info0 = x$analysis$info0, + # statistical information under hypothesis used for + # futility bound calculation if different from `info` + # impacts futility hypothesis bound calculation. + info1 = x$analysis$info, + info_scale = x$input$info_scale, upper = x$input$upper, upar = upar_update, test_upper = x$input$test_upper, lower = x$input$lower, lpar = x$input$lpar, @@ -308,9 +316,16 @@ gs_update_ahr <- function( x_updated_h1 <- gs_power_npe(theta = x$analysis$theta, theta0 = 0, theta1 = x$analysis$theta, + # statistical information under null hypothesis, + # impacts null hypothesis bound calculation. info0 = x$analysis$info0, + # statistical information at all analyses for input `theta` info = x$analysis$info, - info_scale = "h0_info", + # statistical information under hypothesis used for + # futility bound calculation if different from `info` + # impacts futility hypothesis bound calculation. + info1 = NULL, + info_scale = x$input$info_scale, upper = x$input$upper, upar = upar_update, test_upper = x$input$test_upper, lower = x$input$lower, lpar = x$input$lpar, diff --git a/tests/testthat/_snaps/independent_as_gt.md b/tests/testthat/_snaps/independent_as_gt.md index 958c91f9..5cbb049c 100644 --- a/tests/testthat/_snaps/independent_as_gt.md +++ b/tests/testthat/_snaps/independent_as_gt.md @@ -1,73 +1,69 @@ # Snapshot test for fixed_design summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrrr} + \begin{table}[!t] \caption*{ {\large Fixed Design under AHR Method\textsuperscript{\textit{1}}} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrrr} \toprule Design & N & Events & Time & Bound & alpha & Power \\ \midrule\addlinespace[2.5pt] Average hazard ratio & 463.078 & 324.7077 & 36 & 1.959964 & 0.025 & 0.9 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}Power computed with average hazard ratio method.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for fixed_design summary as_gt with custom title and footnote - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrrr} + \begin{table}[!t] \caption*{ {\large Custom Title\textsuperscript{\textit{1}}} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrrr} \toprule Design & N & Events & Time & Bound & alpha & Power \\ \midrule\addlinespace[2.5pt] Average hazard ratio & 463.078 & 324.7077 & 36 & 1.959964 & 0.025 & 0.9 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}Custom footnote.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for fixed_design_fh summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrrr} + \begin{table}[!t] \caption*{ {\large Fixed Design under Fleming-Harrington Method\textsuperscript{\textit{1}}} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrrr} \toprule Design & N & Events & Time & Bound & alpha & Power \\ \midrule\addlinespace[2.5pt] Fleming-Harrington FH(0, 0) (logrank) & 458.3509 & 321.3931 & 36 & 1.959964 & 0.025 & 0.9 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}Power for Fleming-Harrington test FH(0, 0) (logrank) using method of Yung and Liu.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_design_ahr summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for AHR design} \\ {\small AHR approximations of \textasciitilde{}HR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){5-6} @@ -77,23 +73,22 @@ \midrule\addlinespace[2.5pt] Efficacy & 1.96 & 0.025 & 0.795 & 0.9 & 0.025 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}Approximate hazard ratio to cross bound.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_ahr summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for AHR design} \\ {\small AHR approximations of \textasciitilde{}HR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){5-6} @@ -114,23 +109,22 @@ Futility & -0.23 & 0.5897 & 1.0670 & 0.1008 & 0.4303 \\ Efficacy & 2.03 & 0.0211 & 0.5595 & 0.2070 & 0.0250 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}Approximate hazard ratio to cross bound.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_design_wlr summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for WLR design} \\ {\small WLR approximation of \textasciitilde{}wHR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){5-6} @@ -140,24 +134,23 @@ \midrule\addlinespace[2.5pt] Efficacy & 1.96 & 0.025 & 0.7941 & 0.9 & 0.025 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}Approximate hazard ratio to cross bound.\\ \textsuperscript{\textit{3}}wAHR is the weighted AHR.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_wlr summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for WLR design\textsuperscript{\textit{1}}} \\ {\small WLR approximation of \textasciitilde{}wHR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability\textsuperscript{\textit{2}}} \\ \cmidrule(lr){5-6} @@ -178,25 +171,24 @@ Futility & -0.22 & 0.5881 & 1.0650 & 0.1002 & 0.4319 \\ Efficacy & 2.03 & 0.0212 & 0.5631 & 0.2071 & 0.0250 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}this table is generated by gs\_power\_wlr.\\ \textsuperscript{\textit{2}}the crossing probability.\\ \textsuperscript{\textit{3}}approximate weighted hazard ratio to cross bound.\\ \textsuperscript{\textit{4}}wAHR is the weighted AHR.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_combo summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for MaxCombo design} \\ {\small MaxCombo approximation} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrr} \toprule & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){4-5} @@ -217,23 +209,22 @@ Futility & 1 & 0.1587 & 0.0326 & 0.0000 \\ Efficacy & 1 & 0.1587 & 0.9674 & 0.1956 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}EF is event fraction. AHR is under regular weighted log rank test.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_design_rd summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary of Binary Endpoint} \\ {\small measured by risk difference} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){5-6} @@ -243,22 +234,21 @@ \midrule\addlinespace[2.5pt] Efficacy & 1.96 & 0.025 & 0.0302 & 0.9 & 0.025 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_rd summary as_gt - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary of Binary Endpoint} \\ {\small measured by risk difference} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){5-6} @@ -277,23 +267,22 @@ \midrule\addlinespace[2.5pt] Efficacy & 1.99 & 0.0231 & 0.1951 & 0.0705 & 0.0238\textsuperscript{\textit{2}} \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}Cumulative alpha for final analysis (0.0238) is less than the full alpha (0.025) when the futility bound is non-binding. The smaller value subtracts the probability of crossing a futility bound before crossing an efficacy bound at a later analysis (0.025 - 0.0012 = 0.0238) under the null hypothesis.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_wlr summary as_gt with custom title and subtitle - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound Summary} \\ {\small from gs\_power\_wlr} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){5-6} @@ -314,24 +303,23 @@ Futility & -0.22 & 0.5881 & 1.0650 & 0.1002 & 0.4319 \\ Efficacy & 2.03 & 0.0212 & 0.5631 & 0.2071 & 0.0250 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}Approximate hazard ratio to cross bound.\\ \textsuperscript{\textit{3}}wAHR is the weighted AHR.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_wlr summary as_gt with colname_spanner and colname_spannersub - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for WLR design} \\ {\small WLR approximation of \textasciitilde{}wHR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative probability to cross boundaries} \\ \cmidrule(lr){5-6} @@ -352,25 +340,24 @@ Futility & -0.22 & 0.5881 & 1.0650 & 0.1002 & 0.4319 \\ Efficacy & 2.03 & 0.0212 & 0.5631 & 0.2071 & 0.0250\textsuperscript{\textit{4}} \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}Approximate hazard ratio to cross bound.\\ \textsuperscript{\textit{3}}wAHR is the weighted AHR.\\ \textsuperscript{\textit{4}}Cumulative alpha for final analysis (-Inf) is less than the full alpha (0.025) when the futility bound is non-binding. The smaller value subtracts the probability of crossing a futility bound before crossing an efficacy bound at a later analysis (0.025 - Inf = -Inf) under the null hypothesis.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_wlr summary as_gt with custom footnotes - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for WLR design\textsuperscript{\textit{1}}} \\ {\small WLR approximation of \textasciitilde{}wHR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability\textsuperscript{\textit{2}}} \\ \cmidrule(lr){5-6} @@ -391,25 +378,24 @@ Futility & -0.22 & 0.5881 & 1.0650 & 0.1002 & 0.4319 \\ Efficacy & 2.03 & 0.0212 & 0.5631 & 0.2071 & 0.0250 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}this table is generated by gs\_power\_wlr.\\ \textsuperscript{\textit{2}}the crossing probability.\\ \textsuperscript{\textit{3}}approximate weighted hazard ratio to cross bound.\\ \textsuperscript{\textit{4}}wAHR is the weighted AHR.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_wlr summary as_gt with display_bound - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for WLR design} \\ {\small WLR approximation of \textasciitilde{}wHR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrrr} \toprule & & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){5-6} @@ -427,24 +413,23 @@ \midrule\addlinespace[2.5pt] Efficacy & 2.03 & 0.0212 & 0.5631 & 0.2071 & 0.0250 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}Approximate hazard ratio to cross bound.\\ \textsuperscript{\textit{3}}wAHR is the weighted AHR.\\ \end{minipage} - \endgroup + \end{table} # Snapshot test for gs_power_wlr summary as_gt with display_columns - \begingroup - \fontsize{12.0pt}{14.4pt}\selectfont - \setlength{\LTpost}{0mm} - \begin{longtable}{lrrrr} + \begin{table}[!t] \caption*{ {\large Bound summary for WLR design} \\ {\small WLR approximation of \textasciitilde{}wHR at bound} - } \\ + } + \fontsize{12.0pt}{14.4pt}\selectfont + \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lrrrr} \toprule & & & \multicolumn{2}{c}{Cumulative boundary crossing probability} \\ \cmidrule(lr){4-5} @@ -465,10 +450,10 @@ Futility & 0.5881 & -0.22 & 0.1002 & 0.4319 \\ Efficacy & 0.0212 & 2.03 & 0.2071 & 0.0250 \\ \bottomrule - \end{longtable} + \end{tabular*} \begin{minipage}{\linewidth} \textsuperscript{\textit{1}}One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.\\ \textsuperscript{\textit{2}}wAHR is the weighted AHR.\\ \end{minipage} - \endgroup + \end{table}