rstanarm icon indicating copy to clipboard operation
rstanarm copied to clipboard

Update posterior_survfit.R

Open liuxiangyu127 opened this issue 5 years ago • 5 comments

also output the sampled survival probabilities

liuxiangyu127 avatar Feb 23 '20 04:02 liuxiangyu127

@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 avatar Jun 10 '20 17:06 jgabry

@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!! 😦 )

sambrilleman avatar Jun 16 '20 10:06 sambrilleman

Is this tantamount to a posterior_epred method for survival models?

bgoodri avatar Jul 31 '20 23:07 bgoodri

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.

sambrilleman avatar Aug 04 '20 12:08 sambrilleman

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).

sambrilleman avatar Aug 04 '20 12:08 sambrilleman