rstanarm
rstanarm copied to clipboard
Update posterior_survfit.R
also output the sampled survival probabilities
@liuxiangyu127 thanks for the PR. I just noticed we hadn't responded, sorry!
Regarding the update to posterior_survfit
, what do you think @sambrilleman?
@jgabry @liuxiangyu127 Seems reasonable, but should we maybe add an argument to make this optional? It might dramatically inflate the size of the return object, so probably only want to return it when people explicitly ask for it.
In posterior_traj
I have a similar thing, but I called the argument return_matrix
, see here. Perhaps we could call it the same thing here? The minor difference is that in posterior_traj
with return_matrix = TRUE
it is only the matrix of draws that is returned, whereas here it seems @liuxiangyu127 wants to return the matrix of draws in addition to all the other stuff, which is probably fine, but we'd just want to be aware that doing that will mean posterior_traj
and posterior_survfit
would behave slightly differently for return_matrix = TRUE
.
@liuxiangyu127 @jgabry -- would be happy for either of you to make these changes if you want. I don't have much spare time for this stuff atm! (hence my slow reply, sorry!! 😦 )
Is this tantamount to a posterior_epred
method for survival models?
Yeah it may well be. I don't think posterior_epred()
existed back when posterior_survfit()
came into existence. So I will read the more recent docs and see.
Had a look and there are some differences.
posterior_epred
is kinda like posterior_survfit(type = "haz")
but as soon as you start looking for posterior_survfit(type = "surv")
you need a transformation of the linear predictor that isn't the link function but rather the relationship between the survival probability and the hazard (since the linear predictor is an estimate of the log hazard). It also allows various other transformations of the hazard (e.g. cumulative hazard, log survival, etc).
Also there isn't always a closed form for the relationship between the survival probability and the hazard, so depending on the model (e.g. if the model has time-varying coefficients) then posterior_survfit(type = "surv")
might use quadrature.
By default posterior_survfit()
also does a bit of summarising into median and interval bounds for the predictions, rather than returning the entire DxN matrix of posterior draws (this is because the time component in the prediction data would make the DxN matrix super difficult for the user to interpret unless they really want it).