Models for Survival and Duration Analysis


import statsmodels.api as sm
import statsmodels.formula.api as smf

data = sm.datasets.get_rdataset("flchain", "survival").data
del data["chapter"]
data = data.dropna()
data["lam"] = data["lambda"]
data["female"] = (data["sex"] == "F").astype(int)
data["year"] = data["sample.yr"] - min(data["sample.yr"])
status = data["death"].values

mod = smf.phreg("futime ~ 0 + age + female + creatinine + "
                "np.sqrt(kappa) + np.sqrt(lam) + year + mgus",
                data, status=status, ties="efron")
rslt =

Detailed examples can be found here:

There are some notebook examples on the Wiki: Wiki notebooks for PHReg and Survival Analysis


References for Cox proportional hazards regression model:

T Therneau (1996). Extending the Cox model. Technical report.

G Rodriguez (2005). Non-parametric estimation in survival models.

B Gillespie (2006). Checking the assumptions in the Cox proportional
hazards model.

Module Reference

The model class is:

PHReg(endog, exog[, status, entry, strata, ...]) Fit the Cox proportional hazards regression model for right censored data.

The result class is:

PHRegResults(model, params, cov_params[, ...]) Class to contain results of fitting a Cox proportional hazards survival model.