-
Notifications
You must be signed in to change notification settings - Fork 8
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
Enable different tests per cutting for sim_gs_n()
#229
Conversation
Hi @jdblischak , can we give an error message when people implement maxcombo test in |
Unfortunately that is not straightforward since str(test)
List of 3
$ :function (data)
..- attr(*, "srcref")= 'srcref' int [1:8] 380 3 382 3 3 3 380 382
.. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x0000025bb811edb0>
$ :function (data)
..- attr(*, "srcref")= 'srcref' int [1:8] 380 3 382 3 3 3 380 382
.. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x0000025bb811edb0>
$ :function (data)
..- attr(*, "srcref")= 'srcref' int [1:8] 380 3 382 3 3 3 380 382
.. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x0000025bb811edb0> I could try to add some error catching code that notices when the number of columns (or the column names) is different and remind the user that the test functions must return consistent results in order to be combined. But I'd prefer to address that in a future PR.
I agree we should delete the examples that combine maxcombo with other tests, ie the current examples 8 and 9. I'll delete those now. Lines 200 to 201 in 42290ea
Lines 216 to 217 in 42290ea
However, I think we can leave example 7, which applies maxcombo at every cutting. Lines 186 to 187 in 42290ea
|
The CI jobs are failing because the Suggested dependency {bshazard} was archived on Saturday, 2024-04-20. https://cran.r-project.org/package=bshazard The CRAN package check problems appear trivial to fix (documentation related), so I am guessing it is no longer maintained. https://cran-archive.r-project.org/web/checks/2024/2024-04-20_check_results_bshazard.html |
Yeah, I got the same message. Could you please suggest a way to fix it? |
Long term, we should stop using it in the vignette simtrial/vignettes/arbitrary-hazard.Rmd Line 100 in 42290ea
In the short term, if we are hoping the maintainers might fix it, we can install it from the CRAN mirror on GitHub by adding the following to
Note that we won't be able to submit to CRAN using the GitHub-installed version You can read more about the https://r-pkgs.org/dependencies-in-practice.html#sec-dependencies-nonstandard |
Can users install bshazard from anywhere? |
Technically yes, but I don't think that helps us. We need this package to be installed in CI and on CRAN to pass |
31cd5e2
to
d67cf5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this and continously improving sim_gs_n
. After reviewing, I have 1 minor comment, and 1 question.
1 Minor comment
Can we arrange the order of the output? The screenshot below is always the columns order we preferred.
1 Question
It appears that the current version of sim_gs_n
only permits one type of test throughout the analyses. I attempted a similar example, but it did not run successfully (code attached). In this particular case, I aimed to conduct a WLR-FH test at IA1, WLR-MB test at IA2, while performing a milestone test at FA. Is it possible to incorporate this functionality into sim_gs_n
as well?
I have added this example as Example 7 of the help file in sim_gs_n
at my commit 6cb1d39. Can we get this example work?
I talked with Keaven this afternoon, and he suggested to add multiple tests at a single analysis. Examples are provided in the help file in sim_gs_n
at my commit 8173979 (see example 8). Can we also get this example work?
The sole purpose of this PR is to enable different tests per cutting. The caveat is that the tests must return the same results, as discussed in #222. Currently WLR-FH and WLR-MB return incompatible results. The former uses library("simtrial")
x <- sim_pw_surv(n = 200) |> cut_data_by_event(100)
ia1_test <- create_test(wlr, weight = fh(rho = 0, gamma = 0.5))
ia2_test <- create_test(wlr, weight = mb(delay = 6, w_max = Inf))
x |> ia1_test() |> names()
## [1] "method" "parameter" "estimation" "se" "z"
x |> ia2_test() |> names()
## [1] "method" "parameter" "estimate" "se" "z" |
Kind of. Technically I've updated the column order to the following. Is this close enough to what you want? If it's really important, I can move sim_id analysis cut_date n event method parameter estimate se z
1 1 1 24.00000 400 229 WLR FH(rho=0, gamma=0) -28.19483 7.521418 -3.748605
2 1 2 32.00000 400 295 WLR FH(rho=0, gamma=0) -38.32581 8.459808 -4.530340
3 1 3 45.00000 400 355 WLR FH(rho=0, gamma=0) -39.49230 9.149248 -4.316453
4 2 1 24.00000 400 241 WLR FH(rho=0, gamma=0) -26.84871 7.721484 -3.477144
5 2 2 32.00000 400 290 WLR FH(rho=0, gamma=0) -32.54824 8.425310 -3.863150
6 2 3 46.21933 400 350 WLR FH(rho=0, gamma=0) -30.06631 9.172772 -3.277778
7 3 1 24.00000 400 226 WLR FH(rho=0, gamma=0) -23.06302 7.498065 -3.075863
8 3 2 32.00000 400 282 WLR FH(rho=0, gamma=0) -30.16330 8.333910 -3.619345
9 3 3 50.86585 400 350 WLR FH(rho=0, gamma=0) -38.75506 9.178027 -4.222592 |
2abc4fa
to
73b29d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @jdblischak, it looks great to me and I only have 1 minor comment of the column order. Could you please order the columns as shown in the following screenshot?
milestone() was recently overhauled to 1. Use the log-log method to calculate the `estimate`. Setting `test_type = "naive"` restored the previous value 1. Return a single value for `se` instead of two 1. Return the unsquared Z statistic for `z` Merck#237
0b03e6c
to
19a6683
Compare
I updated the column order so that "method" and "parameter" are the 2nd and 3rd columns sim_id method parameter analysis cut_date n event estimate se z
1 1 WLR FH(rho=0, gamma=0) 1 24.00000 400 229 -28.19483 7.521418 -3.748605
2 1 WLR FH(rho=0, gamma=0) 2 32.00000 400 295 -38.32581 8.459808 -4.530340
3 1 WLR FH(rho=0, gamma=0) 3 45.00000 400 355 -39.49230 9.149248 -4.316453
4 2 WLR FH(rho=0, gamma=0) 1 24.00000 400 241 -26.84871 7.721484 -3.477144
5 2 WLR FH(rho=0, gamma=0) 2 32.00000 400 290 -32.54824 8.425310 -3.863150
6 2 WLR FH(rho=0, gamma=0) 3 46.21933 400 350 -30.06631 9.172772 -3.277778
7 3 WLR FH(rho=0, gamma=0) 1 24.00000 400 226 -23.06302 7.498065 -3.075863
8 3 WLR FH(rho=0, gamma=0) 2 32.00000 400 282 -30.16330 8.333910 -3.619345
9 3 WLR FH(rho=0, gamma=0) 3 50.86585 400 350 -38.75506 9.178027 -4.222592 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it excellent! This demonstrates tremendous effort. Thank you, @jdblischak!
FYI I just realized when updating locally that |
My previous PR #215 enabled passing a different test function to be applied at each cutting orchestrated by
sim_gs_n()
. However, it was quite limited because it only worked when the test functions gave the exact same output (which was rare).The recent PR #227 from @LittleBeannie standardized the output format of the test functions (see Issue #222 for tracking the progress of this effort). This means we can now combine the results from more diverse test functions.
The trickiest part of this PR was accommodating the tests that return more than one result (
milestone()
returns 2 values forse
andmaxcombo()
returns 2 values forz
). To continue returning a single data frame, I had to use list columns.With this PR, it is now possible to combine the results of
wlr()
(with any arguments),rmst()
, andmilestone()
. Below is example output wherewlr()
was applied at the first cutting,rmst()
at the second cutting, andmilestone()
at the third cutting:Future work:
maxcombo()
are still too heterogenous to combine with the other test functions