Skip to content

Document attribute "ratio" returned by counting_process() #311

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

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

jdblischak
Copy link
Collaborator

I updated the documentation for counting_process() to match its latest behavior. The returned attribute is now ratio.

xref: #276, #281

Idea for future improvement: It would be a good idea to also document the attribute ratio in the documentation for sim_pw_surv() too. The counting_process() code describes the simple ratio of event counts as the "empirical ratio", so I assume that sim_pw_surv() must be doing something different to calculate its ratio.

# if `x` is generated by sim_pw_surv
if ("generate_by_simpwsurv" %in% names(attributes(x))) {
ratio <- attributes(x)$ratio
} else {
# if not, calcualte the emperical ratio
ratio <- sum(x$treatment == arm) / sum(x$treatment != arm)
}
attr(ans, "ratio") <- ratio

@jdblischak jdblischak requested a review from LittleBeannie March 4, 2025 21:13
@jdblischak jdblischak self-assigned this Mar 4, 2025
@LittleBeannie
Copy link
Collaborator

I updated the documentation for counting_process() to match its latest behavior. The returned attribute is now ratio.

xref: #276, #281

Idea for future improvement: It would be a good idea to also document the attribute ratio in the documentation for sim_pw_surv() too. The counting_process() code describes the simple ratio of event counts as the "empirical ratio", so I assume that sim_pw_surv() must be doing something different to calculate its ratio.

# if `x` is generated by sim_pw_surv
if ("generate_by_simpwsurv" %in% names(attributes(x))) {
ratio <- attributes(x)$ratio
} else {
# if not, calcualte the emperical ratio
ratio <- sum(x$treatment == arm) / sum(x$treatment != arm)
}
attr(ans, "ratio") <- ratio

I wanted to clarify the two ways for utilizing counting_process:

  1. The first method involves using sim_pw_surv(...) |> counting_process(...). In this case, the ratio for counting_process is derived from the block argument in sim_pw_surv. For example, if you set block = c("control", "control", "experimental", "experimental"), this indicates a ratio of 1.
  2. The second method involves using x |> counting_process(...), where x is generated manually by the user. Here, the ratio is determined based on empirical data.

I hope this explanation is clear. I will proceed to merge the PR now.

Copy link
Collaborator

@LittleBeannie LittleBeannie left a comment

Choose a reason for hiding this comment

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

Thank you, @jdblischak!

@LittleBeannie LittleBeannie merged commit be86750 into Merck:main Mar 10, 2025
9 checks passed
@jdblischak jdblischak deleted the counting-process-ratio branch March 12, 2025 19:26
@jdblischak
Copy link
Collaborator Author

I hope this explanation is clear.

@LittleBeannie Yes! Very clear now. Thanks for the detailed explanation. Now I understand this line of code from the end of sim_pw_surv():

attr(ans, "ratio") <- sum(block == "experimental") / sum(block == "control")

I'm planning to submit a documentation PR to explain the ratio attribute returned by sim_pw_surv()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants