Skip to content

Interval indexing in Bayesian Survival Analysis #808

@JulietteOrtholand

Description

@JulietteOrtholand

Notebook title: Bayesian Survival Analysis
Notebook url: https://www.pymc.io/projects/examples/en/latest/survival_analysis/survival_analysis.html

Issue description

The baseline hazard is computed over $K$ intervals indexed by $k$, thanks to $\lambda(t) = \lambda_k$ for $t \in [\tau_{k-1},\tau_k]$. This value is saved under the variable base_hazard and is of size $K$: $[\lambda_1, ...., \lambda_K]$. Yet there is another variable interval_bounds that stores $[\tau_0, ..., \tau_K ]$, thus of size $K+1$.
The cumulative baseline hazard, which is $\int_{\tau_0}^t \lambda(t)$ is estimated as (interval_length * hazard).cumsum(axis=-1), thus still a variable of size $K$. At a certain point, the cumulative hazard is plotted depending on the interval_bounds variables. The two objects do not have the same size, and the choice in the notebook was to use interval_bounds[:-1]. So this means that at time $\tau_0$, the variables is equal $(\tau_1-\tau_0)\lambda_1$, yet at time the cumulative baseline hazard equal $\int_{\tau_0}^{\tau_0} \lambda(t) = 0$.

Expected output

Thus I think, interval_bounds[:-1] in plots should be replaced by interval_bounds[1:]

Proposed solution

Let me know if you agree. Then, I can make a PR and check that this issue "only" occurs in plots.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions