Closed Calou1234 closed 6 years ago
You can generate the samples more easily with
coef.sample <- normboot.flexsurvreg(surv.fit, B=10)
then get a sample of (e.g. 5 year) survival probabilities using
psurvspline(5, gamma=coef.sample, knots=surv.fit$knots, lower.tail=FALSE)
Thanks a lot for your answer! Can we do the same with Gompertz or Gen Gamma in flexsurv?
Best Regards, Carine
Le jeu. 6 sept. 2018 à 12:20, Chris Jackson notifications@github.com a écrit :
You can generate the samples more easily with
coef.sample <- normboot.flexsurvreg(surv.fit, B=10)
then get a sample of (e.g. 5 year) survival probabilities using
psurvspline(5, gamma=coef.sample, knots=surv.fit$knots, lower.tail=FALSE)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chjackson/flexsurv-dev/issues/55#issuecomment-419042716, or mute the thread https://github.com/notifications/unsubscribe-auth/ApCJrc1v-V_8vxsM8GF7WbtJz9mMo1hGks5uYPbzgaJpZM4Wcn-1 .
Yes, every distribution has a "p" function, pgompertz, pgengamma,...
Thanks. Will you write it like that for 5 years and log normal distribution? plnorm(5, meanlog=coef.sample[5,1], knots=surv.fit$knots[5,2], lower.tail=FALSE)
Best Regards, Carine
Le jeu. 6 sept. 2018 à 13:11, Chris Jackson notifications@github.com a écrit :
Yes, every distribution has a "p" function, pgompertz, pgengamma,...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chjackson/flexsurv-dev/issues/55#issuecomment-419056076, or mute the thread https://github.com/notifications/unsubscribe-auth/ApCJrdRI-GkQM3ucaeO_WS3LqixiPCL8ks5uYQLDgaJpZM4Wcn-1 .
Sorry a mistake on my side, the code should be: plnorm(5, meanlog=coef.sample[,1], knots=surv.fit$knots[,2], lower.tail=FALSE)
Is it correct?
Le jeu. 6 sept. 2018 à 15:26, Carine Gubelmann gubelmann.carine@gmail.com a écrit :
Thanks. Will you write it like that for 5 years and log normal distribution? plnorm(5, meanlog=coef.sample[5,1], knots=surv.fit$knots[5,2], lower.tail=FALSE)
Best Regards, Carine
Le jeu. 6 sept. 2018 à 13:11, Chris Jackson notifications@github.com a écrit :
Yes, every distribution has a "p" function, pgompertz, pgengamma,...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chjackson/flexsurv-dev/issues/55#issuecomment-419056076, or mute the thread https://github.com/notifications/unsubscribe-auth/ApCJrdRI-GkQM3ucaeO_WS3LqixiPCL8ks5uYQLDgaJpZM4Wcn-1 .
No, knots are only for spline models. Log normal distributions have mean and SD parameters on the log scale, and no knots. You should first use flexsurvreg to fit the log normal model.
I'm closing this issue now, as this isn't really a help forum. Please take some time to understand the details of the code examples I've given, and consult the help pages for each function you use so you understand what it does, and the necessary arguments.
Dear chjackson,
Thanks for your help to my previous comment.
Now I am struggling with generating probabilistic sensitivity analysis on flexsurvspline (k=2, hazard). Do you have any extension regarding this aspect? I have managed to generate different multivariate normal distribution and got a matrix of gamma (0 to 3) using the package "MASS". Now How can I calculate the survival function using the new gamma (in my example below called "coef.sample"?
I would like to have as an output: for each time, a percentage of survival following the Spline function dictated for each coef.sample.
library("flexsurv") surv.fit <- flexsurvspline(Surv(recyrs, censrec) ~ 1, data = flexsurv::bc, k=2, scale="hazard") library("MASS") coef.sample <- MASS::mvrnorm(n = 1000, mu = surv.fit$res.t[, "est"], surv.fit$cov) ggplot2::ggplot(data.frame(coef.sample), aes_string(x = "shape", y = "scale")) + geom_point()
Best Regards, Carine