Is it possible to run a Cox-Proportional-Hazards-M

2019-08-31 05:30发布

问题:

I consider using the lifelines package to fit a Cox-Proportional-Hazards-Model. I read that lifelines uses a nonparametric approach to fit the baseline hazard, which results in different baseline_hazards for some time points (see code example below). For my application, I need an exponential distribution leading to a baseline hazard h0(t) = lambda which is constant across time.

So my question is: is it (in the meantime) possible to run a Cox-Proportional-Hazards-Model with an exponential distribution for the baseline hazard in lifelines or another Python package?

Example code:

from lifelines import CoxPHFitter
import pandas as pd

df = pd.DataFrame({'duration': [4, 6, 5, 5, 4, 6], 
                   'event': [0, 0, 0, 1, 1, 1], 
                   'cat': [0, 1, 0, 1, 0, 1]})

cph = CoxPHFitter()
cph.fit(df, duration_col='duration', event_col='event', show_progress=True)
cph.baseline_hazard_

gives

        baseline hazard
T   
4.0     0.160573
5.0     0.278119
6.0     0.658032

回答1: