Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hazard rates (dividing by timedelta, censored times) #1592

Open
shilet opened this issue Jan 19, 2024 · 0 comments
Open

Hazard rates (dividing by timedelta, censored times) #1592

shilet opened this issue Jan 19, 2024 · 0 comments

Comments

@shilet
Copy link

shilet commented Jan 19, 2024

When I use the NelsonAalen fitter to determine the hazard rate I came across the following two issues:

  1. in calculating the instantaneous hazard, the time between two events is not used to determine the hazard. Normally h0 = d_j/(n_j * T_j) where d_j are the number of deaths, n_j ,the number at risk, and T_j the time between t_j and t_(j+1)
  2. the hazard rate is also determined at censored times. The hazard is then zero. To my knowledge, hazard rates are not determined at censored times.

For a simple example see:
data = {
'duration': [2, 4, 6, 7, 8],
'event': [1, 1, 0, 1, 1],
}

df = pd.DataFrame(data)
naf = NelsonAalenFitter()
naf.fit(df['duration'], df['event'])
naf.plot_hazard(bandwidth=1, ci_show=False, label='NA hazard lifelines')

The same problem in the CoxPH fitter. For determining the baseline_hazard_ dividing by delta time is not done, and the hazard is also determined at censored times.

I was also wondering why the calculation of the hazard rate based on the Kaplan Meier event table is not implemented as this seems to me the most straightforward implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant