-
Notifications
You must be signed in to change notification settings - Fork 8
Do not preface Surv() or strata() with survival:: in formulas #303
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
Conversation
Whether or not we require |
Also, apparently prior to survival 3.8, using x <- covr::package_coverage()
covr::report(x) Specifically this code block is untested: Lines 407 to 411 in d2f4127
|
Requiring a too recent survival version might break people's shared basedline global library builds moving forward because the default survival version bundled with prior R releases can be lower than the required version. So I would suggest relaxing these requirements whenever possible. My understanding of the problem: qualifying the namespace in Pseudo code: fit <- if (packageVersion("survival") < "3.8-0") {
survival::coxph(Surv(time, status) ~ x + strata(group), test)
} else {
survival::coxph(survival::Surv(time, status) ~ x + survival::strata(group), test)
} Note that you still need to I patched my packages this way before in irrelevant but similar situations: nanxstats/ggsci#30 nanxstats/protr#54 |
I'm fine with removing this stringent requirement. Like I said above, I think we'd only ever have a problem with earlier versions of {survival} if we defined functions with the same names, which is unlikely to happen.
I'm not sure we need/want to do this branching. It's my understanding that {simtrial} got flagged by the {survival} reverse dependency checks specifically because it was using
That's a good point. I think importing |
Agreed! No survival version requirement + removing all |
b8b4848
to
21a7188
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.
Thank you, @jdblischak ! I will postpone the merged in case Keaven are interested in reviewing it.
21a7188
to
2d13005
Compare
I rebased the PR onto main to incorporate the recently merged #304 |
@@ -405,12 +406,12 @@ doAnalysis <- function(d, rho_gamma, n_stratum) { | |||
|
|||
event <- sum(d$event) | |||
if (n_stratum > 1) { | |||
ln_hr <- survival::coxph(survival::Surv(tte, event) ~ (treatment == "experimental") + survival::strata(stratum), data = d)$coefficients | |||
ln_hr <- survival::coxph(Surv(tte, event) ~ (treatment == "experimental") + strata(stratum), data = d)$coefficients |
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.
My only lingering concern is that this line that uses survival::strata()
is not covered by our tests/examples, and this usage is specifically noted as behaving incorrectly in previous versions of {survival}. From the release notes:
Note that prior to this update using survival::strata(inst) above would give the wrong answer; because :: mucks up formula processing the term would not be recognized as a stratum, and the resulting fit equivalent to using factor(inst).
My questions are:
- Can we add a test/example with more than one stratum to execute this code?
- Are we worried that this could give incorrect results when run with survival <3.8-1?
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.
Updating our survival formulas to adapt to the latest changes in survival 3.7 and 3.8. The basic idea is that we should not preface
Surv()
andstrata()
withsurvival::
inside of formulas.Below are the relevant bullet points from the NEWS file:
https://cran.r-project.org/web/packages/survival/news.html
https://github.com/therneau/survival/blob/9ea6560c18905ca5c83b2be18e505df6d135733f/inst/NEWS.Rd#L43