Justin Lallemand
Justin Lallemand

Reputation: 11

CoxTimeVaryingFitter - Baseline Hazards Using Strata in Python

I am applying strata on the Rossi dataset using CoxTimeVaryingFitter and when I call ctv.baseline_survival_ I am getting a dataframe with only one column, but expected two columns - one for each strata. When I try the same thing for CoxPHFitter (static only), I get two columns - one for each value of 'wexp'.

Below reproduces the output dataframe with only one column:

from lifelines.datasets import load_rossi
rossi = load_rossi()

from lifelines.utils import to_episodic_format
rossi_long = to_episodic_format(rossi,duration_col='week',event_col='arrest',time_gaps=1.)

from lifelines import CoxTimeVaryingFitter
ctv = CoxTimeVaryingFitter()

ctv.fit(rossi_long,id_col='id',event_col='arrest',start_col='start',stop_col='stop',strata='wexp',
              formula ="bs(age,df=4,lower_bound=10,upper_bound=50)+fin+race+mar+paro+prio")

ctv.baseline_survival_

Is there a way to observe these values for the different strata? My goal is to stratify loan performance data on delinquency status (Current, 30 Days Past Due, 60 Days Past Due) to predict defaults. This strata should result in different baseline values for each delinquency status.

Upvotes: 1

Views: 34

Answers (0)

Related Questions