Search code examples
rsurvival-analysisextrapolation

How to extrapolate using cuRe package in R?


I am fitting a non-mixture cure model in R with splines, using the cuRe package. Here is my example:

dat <- cuRe::colonDC

non_mcm_spl_3df <- GenFlexCureModel(formula = Surv(FUyear, status) ~ 1,
                                    smooth.formula =  ~ ns(log(FUyear), df = 3),
                                    data = dat,
                                    type = "nmixture")

plot(non_mcm_spl_3df)

I wish to do this for multiple models and plot them all in a single plot using ggplot2. This is easy to do using flexsurv functions in R as you can use summary to extract coefficients specifying time points for extrapolation. I think it could be possible using predict here, but the output does not give me time points and I wish to extrapolate the model to 50-years on the graph, which I am not sure how to do. Any advice appreciated.

non_mcm_spl_3df_line <- as.data.frame(predict(non_mcm_spl_3df, type = "surv"))

Solution

  • Yes, this is possible via the predict function. Predictions at certain time points can be specified by using the time argument:

    predict(fit.gen.timevar, time = c(2, 5, 50)).
    

    The predict function can provide numerous functionals. This is specified via the type argument and the default is "surv", which is total survival. If you want to plot this functions, there is a time argument to the plot function:

    plot(non_mcm_spl_3df, time = seq(0.001, 50, length.out = 100))
    

    The plot function calls the predict function and thus the type argument can be used here in a similar fashion.