-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add flexsurvspline support for survival_reg model #213
Conversation
Hi @mattwarkentin , thanks for the PR! Which changes in parsnip are you referring to? Let me know when you want feedback on the PR! (Now?) |
I am somewhat new to contributing to Basically
But maybe I'm wrong. Sure, happy to receive feedback on the PR any time! |
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.
This looks good already! Can you add tests though, please? Re parsnip changes: yes, the documentation updates need to happen in parsnip, like you highlighted already 👍
Next steps (at least what I can think of right now)
- add unit tests to censored
- PR to parsnip with documentation and making the engine args tunable (I left a more detailed comment on this on the code directly)
- Update
vignette/articles/examples.Rmd
- Update
README.Rmd
- todo for myself: add tests on case weights
- update NEWS, including PR number and contributor github name
Sorry for dropping the ball on this. I was moving across the country for a new job and just totally got sidetracked. Want me to get this back on track, @hfrick? |
No worries, there is no rush! If you want, that'd be great! The main things are the unit tests and the documentation over in parsnip. |
For me:
|
Okay @hfrick, we are getting close. The one thing I'm stumbling on is that there surely needs to be somewhere where we connect the fact that OUR parameter is called I thought maybe I handled this when I made the PR to This seems like something handled by |
Awesome! If the argument you want to make tunable is a main argument, ie an argument directly to Thanks for adding the tests! Could you update them so that they make use of the spline functionality? Then we know that this aspect also works! For survival probability and hazard, we don't need to test against rms if we test against flexsurv. Re predictions of the linear predictor: I noticed in the test example that flexsurv returns negative values and censored then tries to log those, resulting in The library(flexsurv)
#> Loading required package: survival
spline_fit <- flexsurvspline(
Surv(time, status) ~ age + sex,
data = lung
)
predict(spline_fit, lung[1:5,], type = "linear")
#> # A tibble: 5 × 2
#> .time .pred_link
#> <dbl> <dbl>
#> 1 0 -7.63
#> 2 0 -7.72
#> 3 0 -7.92
#> 4 0 -7.90
#> 5 0 -7.85
non_spline_fit <- flexsurvreg(
Surv(time, status) ~ age + sex,
data = lung, dist = "weibull"
)
predict(non_spline_fit, lung[1:5,], type = "linear")
#> # A tibble: 5 × 2
#> .time .pred_link
#> <dbl> <dbl>
#> 1 0 314.
#> 2 0 338.
#> 3 0 392.
#> 4 0 387.
#> 5 0 373. Created on 2022-10-28 with reprex v2.0.2 |
Tests are updated and removed the rms comparison.
A |
Are we sure this is the case? Maybe we should loop in @chjackson and get his input. |
Yes in flexsurv, |
Thanks @chjackson! So just to be super clear: this applies to the predict methods for both the models from Where I'm coming from with this question: For the existing engine, which uses |
Both Is there a confusion here since flexsurv models can be based on different parametric survival distributions? The meaning of "location parameter" depends on the distribution. Sometimes this parameter is defined to be positive (such as rate and scale parameters in the exponential, Weibull or gamma), and sometimes it is unrestricted (such as I guess flexsurv conflicts here with user expectations that |
FYI if this is helpful, for a parameter named |
@hfrick You may wish to use the functions in |
No it's |
Oops, my mistake. Please ignore my previous comment. |
@mattwarkentin @chjackson Thank you both; that's really helpful to know! I've now changed the transformation for the link/linear predictor in this commit 31fd6b9 - could you confirm that this is correct now? Other than that, I think this PR is ready! |
Can't see anything wrong with the transformation procedure there |
LGTM! |
Great, thanks so much both! |
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
Hi @hfrick,
This PR is a start for addressing #115.
I have marked the PR as a draft because I think some changes to
{parsnip}
are required before this PR should be merged into{censored}
.I look forward to your feedback and hopefully getting this integrated into censored eventually.