Skip to content

Commit

Permalink
dont fail if no beta coefs estimated
Browse files Browse the repository at this point in the history
  • Loading branch information
jburos committed Aug 5, 2016
1 parent 871d7be commit 5a022fb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions survivalstan/survivalstan.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,17 @@ def fit_stan_survival_model(df, formula, event_col, model_code,
**kwargs
)

beta_coefs = pd.DataFrame(
survival_fit.extract()['beta'],
columns = x_df.columns
)
beta_coefs.reset_index(0, inplace = True)
beta_coefs = beta_coefs.rename(columns = {'index':'iter'})
beta_coefs = pd.melt(beta_coefs, id_vars = ['iter'])
beta_coefs['model_cohort'] = model_cohort
try:
beta_coefs = pd.DataFrame(
survival_fit.extract()['beta'],
columns = x_df.columns
)
beta_coefs.reset_index(0, inplace = True)
beta_coefs = beta_coefs.rename(columns = {'index':'iter'})
beta_coefs = pd.melt(beta_coefs, id_vars = ['iter'])
beta_coefs['model_cohort'] = model_cohort
except:
beta_coefs = None

## prep by-group coefs if group specified
if group_id_col:
Expand Down

0 comments on commit 5a022fb

Please sign in to comment.