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
base: master
Are you sure you want to change the base?
Conversation
add internal global option to shorten the summary output
Thank you! This looks like a very highy quality PR! I will go through it in the next couple of days. |
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? |
There was a problem hiding this 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* |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
R/distributions.R
Outdated
# take the limits of the distribution into account | ||
out <- ifelse(q < lb, 0, out) | ||
out <- ifelse(q > ub, -Inf, out) | ||
if (lower.tail) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 = "", ...) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
tests/local/setup_tests_local.R
Outdated
@@ -1,5 +1,6 @@ | |||
library(testthat) | |||
library(brms) | |||
library(mixcure) |
There was a problem hiding this comment.
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?
tests/local/tests.models-6.R
Outdated
|
||
fit1 <- add_criterion(fit1, criterion = "loo" , moment_match = TRUE) | ||
fit2 <- add_criterion(fit2, criterion = "loo" , moment_match = TRUE) | ||
loo_compare(fit1, fit1) |
There was a problem hiding this comment.
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 Is this PR still something you are working on? |
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 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 |
See this issue