biof309_fall2018
biof309_fall2018 copied to clipboard
Error when running cox proportional hazard model
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()
This error is coming from one of those 25 variables. I would try to run the code with a different set of variables.