Closed jdblischak closed 6 months ago
This is great start. Just a few design and style comments that can be easily addressed once the decision is made:
data
should be the first argument, Hadley also has a similar opinion.formula
instead of x
, to be obvious, and to be consistent with other model fitting packages?Surv(time, event) ~ treatment
.
Although we can still interpret it not literally, by only using the variable names, like your current implementation.
tidymodels/censored also has thoughts on related issues.
- I think
data
should be the first argument, Hadley also has a similar opinion.- Would it make sense to name the formula argument as
formula
instead ofx
, to be obvious, and to be consistent with other model fitting packages?- Make the argument only accept formula, instead of creating a dependency between arguments.
These are all objections to making rmst()
an S3 generic. The alternative would be to have two separate functions. Your bullet points describe essentially what I had in the first commit of this PR, 0bbdaa48d18d94dc464b99ac346d033a451459c3, prior to converting to an S3 generic
- If we enforce a single, strict formula syntax that is consistent with the conventions, I think it would encourage people to write correct code. For example,
Surv(time, event) ~ treatment
. Although we can still interpret it not literally, by only using the variable names, like your current implementation. tidymodels/censored also has thoughts on related issues.
I worry about the implementation. Dealing with formulas/language objects is difficult to do robustly. I think the end users need to know that Surv()
is not executed. For example, what if a user used the named arguments and put them out of order, eg Surv(event = x, time2 = y, time = z)
. This would be expected to work, but would fail in our setup.
Closes #189
xref: https://github.com/Merck/simtrial/pull/188#issuecomment-1924398310
I added a simple formula interface,UPDATE: After feedback, I instead added an additional argumentrmst.formula
, and convertedrmst()
to an S3 generic function. I say simple because it only extracts the variable names from the formula, and then uses these to callrmst.default()
. Converting to the S3 generic required changing the first argument name to something that could stand for a data frame or a formula. I chosex
since this is a common S3 pattern (eg see?aggregate
). The main downside I see of makingrmst()
an S3 generic is that its first argument is no longerdata
like all the other test functions likewlr()
andmaxcombo()
.formula = NULL
to the existingrmst()
functionPlease give it a try and let me know how it can be improved.