I have fit a Cox model (with a cluster-specific random intercept) using
stan_surv. Is there an easy way to predict the median survival time for each observation? Note that this is not what is returned by
posterior_survfit (at least not by default), which returns the median of the posterior of the survival probabilities for a number of time points. The “median survival time” is the (first) time that this probability drops below 50%.
Ideally I would be able to get the posterior for the median survival time, for each observation. Is there an easy way to do this?
As an aside, I came across a potential bug. When I fit the model I included a random effect
id is a factor. When I call
posterior_survfit, I get the following warning:
In model.frame.default(TermsF, data, xlev = xlevs, drop.unused.levels = drop.unused.levels, ... : variable 'id' is not a factor
And then in the return object, the
id column just has the numbers 1 through the number of levels, as opposed to the actual factor labels. I assume these correspond to as.numeric(id), but it would be more convenient if the function supported factors without the warning.
Thanks in advance.