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

Implement censored families #697

Merged
merged 7 commits into from
Jul 20, 2023
Merged

Conversation

tomicapretto
Copy link
Collaborator

This PR implements censored families. For example

model = bmb.Model(
    "censored(time, status) ~ 1 + sex + age", 
    df_kidney, 
    family="gamma",
    link="log"
)

where time is a survival time and status is either "right" or "none" indicating right-censoring and no censoring, repsectively.


But there's an additional feature I discuss below

In addition, bmb.Model gains an extra argument called center_predictors. By default, when there's an intercept, Bambi centers all the predictors in the design matrix. This usually results in better sampling speed because (if I'm correct) mitigates some correlation in the posterior.

However, while I was testing the new censored models I was having lots of sampling initialization problems. I think it was due to a combination of the prior choice and the scale of the predictor variable, that when centered, caused the issue. So by doing bmb.Model(..., center_predictors=False) we get rid of the centering and the problem disappears.

Notice the center_predictors=False may also be usefu.l to people that just want to make sure the intercept they select for the prior has the natural interpretation they expect. With automatic centering, the interpretation of the intercept is not what you think it is (unless all your predictors are centered around zero)

@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2023

Codecov Report

Merging #697 (3f85e4f) into main (6268ccf) will decrease coverage by 0.66%.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##             main     #697      +/-   ##
==========================================
- Coverage   89.52%   88.87%   -0.66%     
==========================================
  Files          40       43       +3     
  Lines        2951     3362     +411     
==========================================
+ Hits         2642     2988     +346     
- Misses        309      374      +65     
Impacted Files Coverage Δ
bambi/data/datasets.py 96.15% <ø> (ø)
bambi/defaults/families.py 87.50% <ø> (ø)
bambi/families/univariate.py 94.38% <77.77%> (-1.74%) ⬇️
bambi/backend/model_components.py 100.00% <100.00%> (ø)
bambi/backend/pymc.py 94.94% <100.00%> (ø)
bambi/backend/terms.py 96.65% <100.00%> (+0.18%) ⬆️
bambi/models.py 79.22% <100.00%> (+0.05%) ⬆️
bambi/terms/response.py 79.36% <100.00%> (+0.67%) ⬆️
bambi/terms/utils.py 93.75% <100.00%> (+93.75%) ⬆️

... and 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@tomicapretto tomicapretto merged commit cbbf955 into bambinos:main Jul 20, 2023
4 checks passed
@tomicapretto tomicapretto deleted the censoring branch July 20, 2023 21:56
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.

2 participants