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

Added estimate_KM.formula() method #386

Closed
wants to merge 39 commits into from
Closed

Conversation

ddsjoberg
Copy link
Collaborator

@ddsjoberg ddsjoberg commented May 23, 2022

What changes are proposed in this pull request?

  • Converted estimate_KM() to a generic and added S3 methods estimate_KM.data.frame() and estimate_KM.formula(). The data frame method is optimized for CDISC data, and the formula uses the standard survival syntax.

The estimate_KM() formula method is now marked as experimental and is not implemented for other functions at this time.

Did you include unit tests for the proposed change/bug fix (https://testthat.r-lib.org/)?
Yes

If there is an GitHub issue associated with this pull request, please provide link.
closes #379


Checklist for PR reviewer

  • PR branch has pulled the most recent updates from main branch. Ensure the pull request branch and your local version match and both have the latest updates from the main branch.
  • If a new function was added, function should be included in _pkgdown.yml
  • If a bug was fixed, a unit test was added for the bug check
  • Run pkgdown::build_site(). Check the R console for errors, and review the rendered website.
  • Code coverage is suitable for any new functions/features. Review coverage with withr::with_envvar(new = c("NOT_CRAN" = "true"), covr::report()). Before you run, begin a fresh R session without any packages loaded.
  • R CMD Check runs without errors, warnings, and notes
  • usethis::use_spell_check() runs with no spelling errors in documentation
  • Has NEWS.md been updated with the changes from this pull request under the heading indicating the latest version. If there is an issue associated with the pull request, reference it in parentheses at the end update (see NEWS.md for examples).
  • Has the version number been incremented using usethis::use_version(which = "dev")
  • Approve Pull Request
  • Merge the PR. Please use "Squash and merge".

@ddsjoberg ddsjoberg marked this pull request as ready for review May 27, 2022 19:24
Copy link
Collaborator

@SHAESEN2 SHAESEN2 left a comment

Choose a reason for hiding this comment

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

Reviewing this properly would take me some time. At a first look, it looks great but too complex for what it actually is doing. I feel like this should be part of a next CRAN release so we can properly look into this. We can discuss during our next meeting.

R/estimate_KM.R Outdated Show resolved Hide resolved
#' The function expects that the data has been filtered on the parameter (PARAM/PARAMCD) of interest. All NA values in the CNSR, AVAL and strata
#' argument are removed.
#' Alternatively, PARAM/PARAMCD can be used in the \code{strata} argument. \cr
#'
Copy link
Collaborator

Choose a reason for hiding this comment

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

You started this paragraph with "The first is optimized ...." so I expect, as a reader, to see the second method explained as well briefly.

#' Default is NULL.
#' @param AVAL Analysis value for Time-to-Event analysis. Default is "AVAL", as per CDISC ADaM guiding principles.
#' @param CNSR Censor for Time-to-Event analysis. Default is "CNSR", as per CDISC ADaM guiding principles.
#' @param data The name of the dataset. The dataset is expected to have
Copy link
Collaborator

Choose a reason for hiding this comment

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

I want to keep the main focus on data standards to catch the attention of pharma so keep the reference to ADaM. You can then explain that we can also use non-ADaM eg

The name of the dataset for Time-to-Event analysis based on the Analysis Data Model (ADaM) principles ... When using a non-ADaM-like dataset, the formula method is recommended.

R/estimate_KM.R Show resolved Hide resolved
@@ -240,7 +240,7 @@ testthat::test_that("T5.1 P-values are accurate when a filtered data frame is pi
) %>%
{pchisq(.$chisq, length(.$n) - 1, lower.tail = FALSE)} %>%
visR:::.pvalformat()
testthat::expect_equal(survfit_p, survdiff_p)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use prefixes everywhere.

tests/testthat/test-estimate_KM.R Show resolved Hide resolved
@@ -43,6 +43,9 @@
#' T7.2 The function prefixes the function call with survival
#' T8. Piped datasets still return accurate results
#' T8.1 Piped datasets still return accurate results
#' T9. The user can specify formula argument
#' T9.1 The formula method returns the same results and the data method.
#' T9.2 The formula method triggers error messages.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is too vague

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feel free to update the text to your preference

@ddsjoberg
Copy link
Collaborator Author

ddsjoberg commented May 29, 2022

Reviewing this properly would take me some time. At a first look, it looks great but too complex for what it actually is doing. I feel like this should be part of a next CRAN release so we can properly look into this. We can discuss during our next meeting.

We can ask @bailliem to assist with the review if you don't have time at the moment.

too complex for what it actually is doing

I am not sure what you mean. A simpler approach is to add a formula argument and avoid generics/S3 methods (still my preference), but I think you preferred the S3 method when we discussed.

I feel like this should be part of a next CRAN release

Yes, the next CRAN release is what was discussed.

@ddsjoberg
Copy link
Collaborator Author

@bailliem @SHAESEN2

In @SHAESEN2 's review, I think he accurately points out that the S3 methods are overly complex given the added functionality, and I agree with him. We should opt for simply adding the estimate_KM(formula=) argument to the function. I put together a new pull request (#390) based on the review comments that adds the new argument rather than implementing generics/S3 methods. The new implementation is much simpler and will be easier to maintain.

I am going to close this PR for now, and we can discuss on Tuesday.

@ddsjoberg ddsjoberg closed this May 29, 2022
@bailliem bailliem self-requested a review May 29, 2022 19:33
@ddsjoberg ddsjoberg deleted the method_for_formulas branch June 21, 2022 19:10
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.

Add estimate_KM.formula() method
3 participants