-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Frailty survival model #580
Frailty survival model #580
Conversation
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Signed-off-by: Nathaniel <[email protected]>
…ates Signed-off-by: Nathaniel <[email protected]>
View / edit / reply to this conversation on ReviewNB ricardoV94 commented on 2023-10-08T23:16:38Z Any reason not to use
NathanielF commented on 2023-10-09T07:54:47Z In the case of the CoxPH regression the "Poisson trick" is a classic of the literature and it works to give me the results i was expecting. It's also consistent with the approach already documented in Austin's notebook.
More generally in the case of the AFT models below. I tried using the pm.Censored with the Weibull regression, but it gave me garbage results and was allot slower than using the Potential. And again in the case of the Weibull AFT my current parameterisation gives the expected results.
But maybe i'm missing something, was there a pattern of usage you had in mind w.r.t. to using censored liklihoods for survival?
|
In the case of the CoxPH regression the "Poisson trick" is a classic of the literature and it works to give me the results i was expecting. It's also consistent with the approach already documented in Austin's notebook.
More generally in the case of the AFT models below. I tried using the pm.Censored with the Weibull regression, but it gave me garbage results and was allot slower than using the Potential. And again in the case of the Weibull AFT my current parameterisation gives the expected results.
But maybe i'm missing something, was there a pattern of usage you had in mind w.r.t. to using censored liklihoods for survival?
View entire conversation on ReviewNB |
From a first glance it sounded like you just wrote your own Censored likelihood by hand. Since we implemented it in PyMC we've been moving examples towards using the Censored factory instead because that fits much more with the PyMC vibe. Similarly, nobody is writing Potentials for Mixture likelihoods either, because we have pm.Mixture.
I am not familiar with the Poisson trick. Google didn't elucidate it quickly for me. |
I was talking about this one yes, not the Poisson trick. Sounds like a bug or a difference in the parametrization of the PyMC-defined Weibull and what you're comparing against. Using pm.Censored could be slower but shouldn't give different results. Logp wise it should be equivalent to what you did with the Potential. |
See maybe here: https://cran.r-project.org/web/packages/survival/vignettes/approximate.pdf |
In that example you didn't pass observed. When you have mixed censored and not censored you have to pass an array to
|
Maybe try |
Your
|
Just as a sanity check do you get a -inf logp at the starting point if you just use a vanilla Weibull (without censoring). I wonder if the PyMC parametrization is just different than what you were working with. |
No, run it with all observations, censored and non-censored as if they were all uncensored |
Interesting, that suggests a precision issue with the CDF (or a bug in the CDF). Can you open a GitHub issue with a minimal reproducible example? |
@ricardoV94 added the issue here: pymc-devs/pytensor#471 |
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
Fixed View entire conversation on ReviewNB |
Fixed View entire conversation on ReviewNB |
Adjusted View entire conversation on ReviewNB |
Adjusted View entire conversation on ReviewNB |
Added View entire conversation on ReviewNB |
Thanks so much for the detailed feedback!
I think I've addressed all the above comments and it's much stronger now. |
Indeed! View entire conversation on ReviewNB |
Replaced with print statement View entire conversation on ReviewNB |
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
I'm happy with this now! Caught a few extra typos and mistakes in the writing, but basically the same with adjustments for your feedback @drbenvincent. Thanks again for the detailed review! |
Signed-off-by: Nathaniel <[email protected]>
Signed-off-by: Nathaniel <[email protected]>
Just giving this another nudge @drbenvincent . If you have time it'd be great to get it over the line this week. |
Thanks for the nudge. Fingers crossed I'll have time in the next few days |
"In the context of a failure modelling" -> "In the context of failure modelling" View entire conversation on ReviewNB |
Thanks View entire conversation on ReviewNB |
Found a typo "strucuture" |
I'm not sure what I feel about this, but I'm wondering if in this case of utility functions we might want to add type hints just to help the reader out a bit def cum_hazard(hazard):
return hazard.cumsum(dim="intervals")
def survival(hazard):
return [np.exp](https://numpy.org/doc/stable/reference/generated/numpy.exp.html#numpy.exp)(-cum_hazard(hazard))
def get_mean(trace):
return trace.mean(("draw", "chain")) |
Where we have the cell |
Missing capitalisation. Doesn't follow on from a previous unfinished sentence.
Same here:
and
|
Cool! Have added a set of comments above. Mostly small grammatical or stylistic things. Great addition to the set of examples. |
Signed-off-by: Nathaniel <[email protected]>
Thanks @drbenvincent, addressed those notes! Pleased with this one. |
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.
Nicely done
Thank you Ben! Appreciate it! |
Frailty Models - Hierarchical Survival Models
Related to this issue: #579
Leaving as Draft for now.
Helpful links
📚 Documentation preview 📚: https://pymc-examples--580.org.readthedocs.build/en/580/