chjackson / flexsurv

The flexsurv R package for flexible parametric survival and multi-state modelling
http://chjackson.github.io/flexsurv/
54 stars 28 forks source link

Does `sim.fmsm` take into account coefficient uncertainty? #80

Closed sdaza closed 4 years ago

sdaza commented 4 years ago

Hello, Thank you for such a great package.

I wonder if the sim.fmsm function considers the uncertainty of model coefficients and estimates. It seems that msfit.flexsurvreg does.

Thanks

chjackson commented 4 years ago

No, sim.fmsm simulates a sample from a fitted model with parameters fixed at their maximum likelihood estimates. To get uncertainty around summaries of the sample, you could wrap bootci.fmsm around the function that computes the summary. See the example in help(bootci.fmsm). This function is available in the GitHub version but not on CRAN yet.

sdaza commented 4 years ago

Thanks! Do you know if I can use the output from bootci.fsm as input for the functionsim.fmsm? Otherwise, just resampling would be an alternative.

chjackson commented 4 years ago

It works like this - as explained in the help page.

summfn <- function(x, ...){
    sim <-  sim.fmsm(x, ...) 
 ##  [[ compute the summary you want here. ]] 
}
mod <- flexsurvreg(...)

Then

bootci.fmsm(mod, fn=summfn, ) 

computes a bootstrap sample or a confidence interval for the summary you want.

sdaza commented 4 years ago

Cool, thanks!