flexsurv-dev icon indicating copy to clipboard operation
flexsurv-dev copied to clipboard

Sampling survival probabilities

Open jrdnmdhl opened this issue 8 years ago • 6 comments

Would be useful to have a way to generate a set of survival probabilities based on drawing a new set of parameters from mvnorm. This can effectively be done right now by taking either the lower or upper bound of the following:

testit = flexsurvreg(Surv(rectime,censrec)~group,data=bc,dist="weibull")
summary(testit, t=c(500,100),type="survival",ci=0.5,B=1,tidy=T)

But producing it this way is a bit of a kluge, so it would be good to have a more direct way of generating this.

jrdnmdhl avatar May 19 '17 18:05 jrdnmdhl

Does this do what you want, or do I misunderstand? This gives a sample of 10 alternative values for the 365-day survival probability, based on 10 random draws from the asymptotic normal distribution of the parameter estimates.

testit <- flexsurvreg(Surv(rectime,censrec)~group,data=bc,dist="weibull")
pars <- normboot.flexsurvreg(testit, B=10, newdata=list(group="Medium"))
testit$dfns$p(365, pars[,1], pars[,2], lower.tail=FALSE)

chjackson avatar May 21 '17 13:05 chjackson

The goal here is to produce survival probabilities at arbitrary times, but based on a single draw from the distribution of parameters. This might be necessary, for example, to run a single simulation of a probabilistic sensitivity analysis in a partitioned survival model, To slightly modify your example:

testit <- flexsurvreg(Surv(rectime,censrec)~group,data=bc,dist="weibull")
pars <- normboot.flexsurvreg(testit, B=1, newdata=list(group="Medium"))
testit$dfns$p(seq(from=0, to=1000, by=100), pars[,1], pars[,2], lower.tail=FALSE)

To have this functionality packaged as an S3 generic, like summary.flexsurvreg, would be useful.

jrdnmdhl avatar May 22 '17 12:05 jrdnmdhl

OK - I think it would be a worthwhile enhancement to summary.flexsurvreg to have the option to return a sample of B values for any required summary statistic, rather than a point estimate or a CI.

chjackson avatar May 22 '17 12:05 chjackson

Along similar lines to the comment by jrdnmdhl, is there any way that the pmatrix.fs() command can be adapted to draw from the distribution of parameters, in the case of a multistate model, for the purposes of a probabilistic sensitivity analysis?

t-patton avatar Oct 21 '19 09:10 t-patton

@t-patton The code for pmatrix.fs actually does this sampling if you request a confidence interval. It calls the function bootci.fmsm, which draws a sample, calculates the P matrix (or some other function) and takes their quantiles to get the confidence interval. You may be able to tweak these functions to get what you want - but I agree a user interface would be nice.

chjackson avatar Oct 22 '19 12:10 chjackson

Would be great to extend this (essentially parametric bootstrap?) to sim.fmsm and simulate.flexsurvreg - I think at the moment they do not consider parameter uncertainty, right? Edit: So, to generate predictions under paramter uncertainty, one would currently have to use boot or rsample packages to bootstrap the fitting itself. Quite expensive.

kkmann avatar Jan 20 '23 13:01 kkmann