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

add patsy formulas for Surv() syntax #77

Merged
merged 75 commits into from Jan 10, 2019
Merged

add patsy formulas for Surv() syntax #77

merged 75 commits into from Jan 10, 2019

Conversation

jburos
Copy link
Member

@jburos jburos commented Jan 8, 2019

This is a revised PR for the add-patsy-formulas feature (PR #60).

Since then:

  1. Improved code formatting
  2. fix log_t_dur spec (Possible log_t_dur misspecification in Stan model file #71)
  3. fix dataframe merge error on pp_surv (Dataframe Merge error in utils.plot_pp_survival (Test pem_survival_model with simulated data notebook) #76)

Comments from previous PR:

Some code refactoring in order to support using patsy formulas for LHS as well as RHS spec. Closes #52

Models can now use the following syntax:

survivalstan.fit_stan_survival_model(
    formula = 'surv(event_status=end_failure, time=t) ~ age + sex',
   data = d,
   model = survivalstan.models.exp_survival_model,
    ...
)

Optional parameters to surv include group= and subject=.

The previous syntax is still also supported:

survivalstan.fit_stan_survival_model(
   event_col = 'end_failure', 
   time_col = 't',
   formula = ' ~ age + sex',
   ...
) 

Moved a fair amount of data-processing into the survivalstan.formulas module, which extends patsy syntax to support the above. For example, the patsy.ModelDesc module includes the stan-data dict which gets passed to pystan.stan for sampling.

This ipynb tests early versions of this code and may help demonstrate how the elements in formulas.py fit together.

@jburos jburos changed the title V2.0 add patsy formulas for Surv() syntax Jan 8, 2019
@jburos jburos mentioned this pull request Jan 8, 2019
@coveralls
Copy link

Coverage Status

Coverage increased (+41.9%) to 85.081% when pulling d3f8c1a on v2.0 into c1e1417 on dev.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+41.9%) to 85.081% when pulling d3f8c1a on v2.0 into c1e1417 on dev.

@coveralls
Copy link

Coverage Status

Coverage increased (+41.9%) to 85.081% when pulling d3f8c1a on v2.0 into c1e1417 on dev.

@jburos jburos merged commit 037cb47 into dev Jan 10, 2019
@jburos jburos deleted the v2.0 branch January 10, 2019 18:05
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

2 participants