ropensci / aorsf

Accelerated Oblique Random Survival Forests
https://docs.ropensci.org/aorsf
Other
55 stars 10 forks source link

Return predictions when `pred_horizon = 0` #13

Closed mattwarkentin closed 1 year ago

mattwarkentin commented 1 year ago

Hey @bcjaeger,

I am just playing around with this package. It's great. But I am wondering whether it makes sense for predict.orsf_fit() to actually return predictions instead of throwing an error when pred_horizon = 0. I think it makes sense to return 0, 1, and 0 when pred_type is 'risk', 'surv', and 'chf', respectively. Do you agree?

It may seem senseless to request predictions at time zero, but ,as an example, I was trying to make risk or survival curves by making predictions from time zero to time t at equally-spaced intervals, and noted the error. I think the values suggested above are both statistically valid and would make the predict function a little friendlier.

For comparison, I contributed the predict.flexsurvreg() function to the {flexsurv} package and predictions at time = 0 are valid and return the values suggested above.

mattwarkentin commented 1 year ago

I think the relevant lines in check_predict() are at the following lines and could be changed to check_arg_gteq(...): https://github.com/ropensci/aorsf/blob/c2840713f1a1c5f7d767881a1afed25203ca7456/R/check.R#L1575-L1577

bcjaeger commented 1 year ago

Hi, @mattwarkentin. Thanks for trying out aorsf!

I think it makes sense to return 0, 1, and 0 when pred_type is 'risk', 'surv', and 'chf', respectively. Do you agree?

This makes sense to me. I think you are correct regarding the modification of check_predict(). I will look into it now.

bcjaeger commented 1 year ago

It looks like the fix was just as simple as you thought. The dev version should now allow pred_horizon = 0.

Thank you!

mattwarkentin commented 1 year ago

Awesome! Thanks for addressing this so quickly.