Get started

pseudostate computes Aalen–Johansen pseudo-observations at a fixed time horizon. These pseudo-observations can be used as individual-level outcomes in regression models for cumulative incidence or state occupation probabilities.

Installation

With uv:

uv add pseudostate

Alternatively, with pip:

pip install pseudostate

A reproducible example

import polars as pl
from pseudostate import calculate_pseudostates

times_and_reals = pl.DataFrame(
    {
        "times": [1, 2, 2, 3, 4, 5, 6],
        "reals": [1, 0, 2, 1, 0, 2, 1],
    }
)

calculate_pseudostates(times_and_reals, fixed_time_horizon=5)
shape: (7, 6)
estimate_origintimesstate_occupancy_probability_0state_occupancy_probability_1state_occupancy_probability_2row_id
enumf64f64f64f64i32
"fixed_time_horizons"5.00.01.04.4409e-160
"fixed_time_horizons"5.00.3750.250.3751
"fixed_time_horizons"5.00.00.01.02
"fixed_time_horizons"5.0-0.1251.25-0.1253
"fixed_time_horizons"5.00.541667-0.0833330.5416674
"fixed_time_horizons"5.0-0.791667-0.0833331.8755
"fixed_time_horizons"5.01.875-0.083333-0.7916676

Background

The theoretical foundation for pseudo-observations in multi-state models was laid out by Andersen, Klein, and Rosthøj (2003), Generalised linear models for correlated pseudo-observations, with applications to multi-state models, Biometrika, 90(1), 15–27.

The pseudo R package provides a widely used implementation of this approach.

AI / Agents

Skills
llms.txt
llms-full.txt

Developers

Uriah Finkel

Meta

Requires: Python >=3.13
Package Info