Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings from fixed_design_rd() caused by mismatched column names #296

Closed
jdblischak opened this issue Dec 14, 2023 · 4 comments · Fixed by #303
Closed

Warnings from fixed_design_rd() caused by mismatched column names #296

jdblischak opened this issue Dec 14, 2023 · 4 comments · Fixed by #303
Assignees
Labels
bug Something isn't working

Comments

@jdblischak
Copy link
Collaborator

I noticed the following two warnings

devtools::test(filter = "fixed_design")
ℹ Testing gsDesign2| F W  S  OK | Context|   2      7 | independent-fixed_design [4.1s]

Warning (test-independent-fixed_design.R:130:3): RD
Unknown or uninitialised column: `theta`.
Backtrace:1. └─gsDesign2::fixed_design_rd(...) at test-independent-fixed_design.R:130:3
 2.   └─gsDesign2::gs_design_rd(...) at gsDesign2/R/fixed_design_rd.R:96:5
 3.     ├─x$theta at gsDesign2/R/gs_design_rd.R:207:5
 4.     └─tibble:::`$.tbl_df`(x, theta) at gsDesign2/R/gs_design_rd.R:207:5

Warning (test-independent-fixed_design.R:130:3): RD
Unknown or uninitialised column: `info`.
Backtrace:1. └─gsDesign2::fixed_design_rd(...) at test-independent-fixed_design.R:130:3
 2.   └─gsDesign2::gs_design_rd(...) at gsDesign2/R/fixed_design_rd.R:96:5
 3.     ├─x$info at gsDesign2/R/gs_design_rd.R:208:5
 4.     └─tibble:::`$.tbl_df`(x, info) at gsDesign2/R/gs_design_rd.R:208:5

══ Results 
Duration: 4.6 s

[ FAIL 0 | WARN 2 | SKIP 0 | PASS 7 ]

The two warnings are generated from a single call to gs_design_rd() that defines the argument power:

x <- fixed_design_rd(
alpha = 0.025, power = 0.9,
p_c = .15, p_e = .1, rd0 = 0, ratio = ratio
)

Interestingly, the subsequent call to gs_design_rd() that defines n instead of power does not generate the warnings:

y <- fixed_design_rd(
alpha = 0.025, n = x$analysis$n,
p_c = .15, p_e = .1, rd0 = 0, ratio = ratio
)

When power is defined, fixed_design_rd() calls gs_design_rd():

if (is.null(power)) {
d <- gs_power_rd(
p_c = tibble::tibble(stratum = "All", rate = p_c),
p_e = tibble::tibble(stratum = "All", rate = p_e),
ratio = ratio,
upper = gs_b, upar = qnorm(1 - alpha),
lower = gs_b, lpar = -Inf,
n = tibble::tibble(stratum = "All", n = n, analysis = 1),
rd0 = rd0, weight = "unstratified"
)
} else {
d <- gs_design_rd(
p_c = tibble::tibble(stratum = "All", rate = p_c),
p_e = tibble::tibble(stratum = "All", rate = p_e),
alpha = alpha, beta = 1 - power, ratio = ratio,
upper = gs_b, upar = qnorm(1 - alpha),
lower = gs_b, lpar = -Inf,
rd0 = rd0, weight = "unstratified"
)
}

gs_design_rd() then calls gs_info_rd(), and expects the returned table to contain the columns theta and info:

gsDesign2/R/gs_design_rd.R

Lines 206 to 212 in 50067c4

if (h1_spending) {
theta1 <- x$theta
info1 <- x$info
} else {
theta1 <- 0
info1 <- x$info0
}

However, the result returned by gs_info_rd() does not contains these columns:

select(analysis, n, rd, rd0, theta1, theta0, info1, info0)

Surprisingly the tests continue to pass even though theta1 and info1 are assigned NULL. I thought that maybe the autocomplete feature of $ still returned the correct values, but it can't distinguish between eg theta1 and theta0

x <- data.frame(theta1 = 1, theta0 = 0, info1 = 1, info0 = 0, long_name = 3)
x$theta
## NULL
x$info
## NULL
x$long
## [1] 3
@jdblischak
Copy link
Collaborator Author

I used git bisect to identify the first commit that generated the warnings. It was commit 3c71671 from @LittleBeannie, in which the default value of h1_spending was changed from FALSE to TRUE.

Thus I think my proposed solution in #293 to set h1_spending = FALSE when calling gs_design_rd() would restore the previous behavior.

@nanxstats
Copy link
Collaborator

Keaven suggested that Yujie should weigh in, and using both h0 and h1 might be the best.

So let's revisit this after the holidays.

@LittleBeannie LittleBeannie self-assigned this Jan 2, 2024
@LittleBeannie LittleBeannie added the bug Something isn't working label Jan 2, 2024
@LittleBeannie LittleBeannie linked a pull request Jan 2, 2024 that will close this issue
@LittleBeannie
Copy link
Collaborator

LittleBeannie commented Jan 2, 2024

I used git bisect to identify the first commit that generated the warnings. It was commit 3c71671 from @LittleBeannie, in which the default value of h1_spending was changed from FALSE to TRUE.

Thus I think my proposed solution in #293 to set h1_spending = FALSE when calling gs_design_rd() would restore the previous behavior.

Hi @jdblischak , thanks for tracing back! Since gsDesign2 uses h1_spending = TRUE consistently for consistency with most of the clinical trial practice, I would suggest not to change it back to FALSE.

@LittleBeannie
Copy link
Collaborator

This issue is fixed in the PR of #303. Please take a look and review, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants