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

Mixture cure models (Weibull and log-normal) #1453

Draft
wants to merge 69 commits into
base: master
Choose a base branch
from

Conversation

yananlong
Copy link

@paul-buerkner
Copy link
Owner

Thank you! This looks like a very highy quality PR! I will go through it in the next couple of days.

@yananlong
Copy link
Author

yananlong commented Feb 7, 2023

Thanks for your prompt reply! I've actually found a couple of typos that have been fixed in a newer commit, which should be updated in this PR.

Also, since these models are (mostly) for right-censored data, could you share how to do PPC properly?

Copy link
Owner

@paul-buerkner paul-buerkner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, high quality PR! I have just a few comments and suggestions. What is more, I think it would make sense to add info about the mixcure models in the brms_families vignette.

.gitignore Outdated
@@ -9,3 +9,4 @@ tests/local/models_0.8.0.Rda
tests/local/models_0.10.0.Rda
tests/local/models_1.2.0.Rda
tests/local/Rplots.pdf
.ipynb*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like an unusal gitignore for an R package. Do we really need it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, I use jupyter lab for editing so I added that line to avoid adding the checkpoints files. Will fix this.

# take the limits of the distribution into account
out <- ifelse(q < lb, 0, out)
out <- ifelse(q > ub, -Inf, out)
if (lower.tail) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some strange indentation going on here. Please fix.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention is to use 2 spaces for indentation, correct?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but what about the if statements afterwards?

@@ -485,6 +485,16 @@ posterior_epred_hurdle_lognormal <- function(prep) {
with(prep$dpars, exp(mu + sigma^2 / 2) * (1 - hu))
}

posterior_epred_mixcure_lognormal <- function(prep) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it not possible to compute the expected value for these families?

sdist(lpdf, p$mu, p$sigma, p$inc)
}

stan_log_lik_mixcure_weibull <- function(bterms, resp = "", mix = "", ...) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like reqn should always be true given the stan code of this model. If true, should the code below be changed or simplified?

/* mixcure lognormal (AFT) log-PDF of a single response
* identity parameterization of the incidence part
*/
real mixcure_lognormal_lpdf(real y, real mu, real sigma, real inc) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some empty lines between function definitions in both stan files? And add a little more doc at the top?

@@ -1,5 +1,6 @@
library(testthat)
library(brms)
library(mixcure)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to load this package here?


fit1 <- add_criterion(fit1, criterion = "loo" , moment_match = TRUE)
fit2 <- add_criterion(fit2, criterion = "loo" , moment_match = TRUE)
loo_compare(fit1, fit1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding additional tests to see if loo results are in a sensible range. Also please add tests for the posterior_predict method here (and for posterior_epred if implemented).

@yananlong yananlong marked this pull request as draft February 16, 2023 04:26
@paul-buerkner
Copy link
Owner

@yananlong Is this PR still something you are working on?

@arnaudmgh
Copy link

Hello @yananlong and @paul-buerkner,

I started modeling Lymphoma survival data using brms with the Weibull family. However, my posterior predictive survival curve decreases more or less like an exponential decay, the data curve can start very step and flattens at some point (i.e. high hazard followed by short hazard). I added a formula for the shape parameter bf(time | cens(censor) ~ ..., shape ~ 1) but it does not help fit much better.

I suspect I could fit the data better with a cure model. Is it something ready to use in brms? Or, should I pull this branch and try to install it in R?

Any guidance would be much appreciated.

Best
Arnaud

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

Successfully merging this pull request may close these issues.

None yet

3 participants