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

Get ratio as an attributes of sim_pw_surv and pass it to wlr #281

Conversation

LittleBeannie
Copy link
Collaborator

@LittleBeannie LittleBeannie commented Sep 10, 2024

image

@LittleBeannie LittleBeannie added the development New feature or request label Sep 10, 2024
@LittleBeannie LittleBeannie self-assigned this Sep 10, 2024
@LittleBeannie LittleBeannie linked an issue Sep 10, 2024 that may be closed by this pull request
@LittleBeannie LittleBeannie marked this pull request as draft September 10, 2024 19:43
@LittleBeannie LittleBeannie marked this pull request as ready for review September 10, 2024 20:59
@nanxstats
Copy link
Collaborator

It may be useful to have a vignette to document the randomization ratio workflow in simtrial. I'm happy to send a PR to create a vignette with the following Mermaid JS diagram digitalized from notes above but you'll need to fill out the text.

Untitled diagram-2024-09-11-015305

---
config:
  theme: mc
---
flowchart TB
    A["Data input"] --> B("Simulated via <code>sim_pw_surv()</code>") & C["Custom input"]
    B -- "attr <code>ratio</code>" --> D["<code>wlr.tte_data()</code>"] & E["<code>counting_process()</code>"]
    E -- "attr <code>ratio</code>" --> F["<code>wlr.counting_process()</code>"]
    C -- "① User-defined<br>② Empirical" --> G["<code>wlr.tte_data()</code>"]
    C --> H["<code>counting_process()</code>"]
    H --> I["<code>wlr.counting_process()</code>"]
    H -.-> J["Empirical ratio calculation"]
    J --> K["User-provided ratio"] & L["No user-provided ratio"]
    K --> M["Use user's ratio"]
    L --> N["Use empirical ratio"]
    style A stroke-width:1px,stroke-dasharray: 0
    style H stroke-width:1px,stroke-dasharray: 1

#' wlr(weight = fh(rho = 0, gamma = 0.5), ratio = 2)
#'
#' # If users don't provide the randomization ratio, we will calculate the emperical ratio
#' x |> wlr(weight = fh(rho = 0, gamma = 0.5))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we please convert this example to an automated test so that we can confirm that manually providing ratio = 2 returns a different result compared to using the empirical ratio via ratio = NULL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hello @jdblischak, I appreciate you bringing this to my attention. I completely agree with you that adding tests is valuable and advantageous. But I tentatively prefer to keep it as it is. My reasons are listed as follows.

First of all, since there is no equivalence between the one with ratio=2 and ratio=NULL, it's challenging to compare these two on the same scale.

Second, rather than composing my own developer tests, I should seek volunteers for independent or double programming tests, which hold more value and solidity compared to my basic developer tests.

Third, instead of including the above in the tests, I would rather keep them as examples in the help page, where users can readily distinguish the two ways to set ratio, even if they don't review the test files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I completely agree with you that adding tests is valuable and advantageous.

I'll add the tests in a follow-up PR

First of all, since there is no equivalence between the one with ratio=2 and ratio=NULL, it's challenging to compare these two on the same scale.

I don't understand the issue with the scale. I am requesting a test that confirms that the newly added argument ratio has an effect on the results. Thus something like the below would be sufficient:

wlr_w_ratio <- x |> wlr(weight = fh(rho = 0, gamma = 0.5), ratio = 2)
wlr_wo_ratio <- x |> wlr(weight = fh(rho = 0, gamma = 0.5))
expect_false(isTRUE(all.equal(wlr_w_ratio, wlr_wo_ratio)))

Second, rather than composing my own developer tests, I should seek volunteers for independent or double programming tests, which hold more value and solidity compared to my basic developer tests.

I do not understand this perspective. The potential for better tests in the future does not remove the requirement for basic developer tests. Tests are our best method to prevent the accumulation of technical debt. As a concrete, recent example, the argument ratio of gsDesign2::fixed_design_mb() had no effect because it was not passed to the downstream sub-functions (Merck/gsDesign2#463). A basic developer test could have caught this.

Third, instead of including the above in the tests, I would rather keep them as examples in the help page, where users can readily distinguish the two ways to set ratio, even if they don't review the test files.

I was not requesting that the examples be removed. I completely agree with you that the examples section is the correct place to document this for end users. My request was to use these examples as the basis for automated tests.

Copy link
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.

I'll add some tests in a follow-up PR

#' wlr(weight = fh(rho = 0, gamma = 0.5), ratio = 2)
#'
#' # If users don't provide the randomization ratio, we will calculate the emperical ratio
#' x |> wlr(weight = fh(rho = 0, gamma = 0.5))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I completely agree with you that adding tests is valuable and advantageous.

I'll add the tests in a follow-up PR

First of all, since there is no equivalence between the one with ratio=2 and ratio=NULL, it's challenging to compare these two on the same scale.

I don't understand the issue with the scale. I am requesting a test that confirms that the newly added argument ratio has an effect on the results. Thus something like the below would be sufficient:

wlr_w_ratio <- x |> wlr(weight = fh(rho = 0, gamma = 0.5), ratio = 2)
wlr_wo_ratio <- x |> wlr(weight = fh(rho = 0, gamma = 0.5))
expect_false(isTRUE(all.equal(wlr_w_ratio, wlr_wo_ratio)))

Second, rather than composing my own developer tests, I should seek volunteers for independent or double programming tests, which hold more value and solidity compared to my basic developer tests.

I do not understand this perspective. The potential for better tests in the future does not remove the requirement for basic developer tests. Tests are our best method to prevent the accumulation of technical debt. As a concrete, recent example, the argument ratio of gsDesign2::fixed_design_mb() had no effect because it was not passed to the downstream sub-functions (Merck/gsDesign2#463). A basic developer test could have caught this.

Third, instead of including the above in the tests, I would rather keep them as examples in the help page, where users can readily distinguish the two ways to set ratio, even if they don't review the test files.

I was not requesting that the examples be removed. I completely agree with you that the examples section is the correct place to document this for end users. My request was to use these examples as the basis for automated tests.

@LittleBeannie LittleBeannie merged commit 506ce7d into main Sep 17, 2024
7 checks passed
@LittleBeannie LittleBeannie deleted the 279-get-ratio-as-an-attributes-of-sim_pw_surv-and-pass-it-to-wlr branch September 17, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get ratio as an attributes of sim_pw_surv and pass it to wlr
4 participants