biof309_fall2018 icon indicating copy to clipboard operation
biof309_fall2018 copied to clipboard

Error when running cox proportional hazard model

Open saehhan opened this issue 6 years ago • 1 comments

When running the following code, I run into the following error: RuntimeWarning: divide by zero encountered in true_divide

Code:

outcome = df_merged8.iloc[:, -1] predictors = df_merged8.iloc[:, 2:-1]

vars_as_str = str(list(predictors.columns)[:25]).replace("'","").replace('[', '').replace(']','').replace(',', ' +')

cox_model = smf.phreg("PERMTH_INT ~ " + vars_as_str, predictors, status=outcome, ties="efron") results = cox_model.fit() results.summary()

saehhan avatar Dec 12 '18 02:12 saehhan

This error is coming from one of those 25 variables. I would try to run the code with a different set of variables.

marskar avatar Dec 13 '18 19:12 marskar