Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could we run Probabilistic sensitivity analysis on Curve fit? #55

Closed
Calou1234 opened this issue Sep 6, 2018 · 6 comments
Closed

Could we run Probabilistic sensitivity analysis on Curve fit? #55

Calou1234 opened this issue Sep 6, 2018 · 6 comments

Comments

@Calou1234
Copy link

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

@chjackson
Copy link
Owner

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)

@Calou1234
Copy link
Author

Calou1234 commented Sep 6, 2018 via email

@chjackson
Copy link
Owner

Yes, every distribution has a "p" function, pgompertz, pgengamma,...

@Calou1234
Copy link
Author

Calou1234 commented Sep 6, 2018 via email

@Calou1234
Copy link
Author

Calou1234 commented Sep 6, 2018 via email

@chjackson
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants