Get Started with pseudostate

This is a reproducible example that shows how to use pseudostate.

Background

The theoretical foundation for pseudo-observations was laid out in a 2003 paper by Andersen, Klein, and Rosthøj:

  • Andersen, P. K., Klein, J. P., & Rosthøj, S. (2003). Generalised linear models for correlated pseudo-observations, with applications to multi-state models. Biometrika, 90(1), 15–27.

A popular implementation of this technique is the pseudo R package, which is available on CRAN:

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]
})

fixed_time_horizon = 5

calculate_pseudostates(times_and_reals, fixed_time_horizon)
shape: (7, 6)
estimate_origin times state_occupancy_probability_0 state_occupancy_probability_1 state_occupancy_probability_2 row_id
enum f64 f64 f64 f64 i32
"fixed_time_horizons" 5.0 0.0 1.0 4.4409e-16 0
"fixed_time_horizons" 5.0 0.375 0.25 0.375 1
"fixed_time_horizons" 5.0 0.0 0.0 1.0 2
"fixed_time_horizons" 5.0 -0.125 1.25 -0.125 3
"fixed_time_horizons" 5.0 0.541667 -0.083333 0.541667 4
"fixed_time_horizons" 5.0 -0.791667 -0.083333 1.875 5
"fixed_time_horizons" 5.0 1.875 -0.083333 -0.791667 6