Skip to content

Repository files navigation

LoS Estimator

A tool for estimating Length of Stay (LoS) distributions in healthcare settings using deconvolution techniques.

Overview

The LoS Estimator derives patient length of stay distributions from ICU admission and occupancy time series data. It employs statistical fitting techniques to identify the underlying probability distribution that best explains observed occupancy patterns, enabling data-driven resource planning and capacity management.

Note

This work builds on the methodology described in:

  1. Schuppert, S. Theisen, P. Fränkel, S. Weber-Carstens, C. Karagiannidis.

Bundesweites Belastungsmodell für Intensivstationen durch COVID-19. (English: Nationwide exposure model for COVID-19 intensive care unit admission)

doi: https://doi.org/10.1007/s00063-021-00791-7

Key Features

  • Multiple Distribution Support: Fit lognormal, weibull, gamma, Gaussian, exponential, beta, cauchy, t, invgauss, linear, compartmental, and sentinel models
  • Rolling Window Analysis: Track temporal changes in LoS distributions over time
  • Uncertainty Quantification: Optional Laplace-approximation error bars on fitted parameters, kernels, and predictions, with empirical coverage validation against a nominal confidence level
  • Automated Model Selection: Compare distributions and identify the best-fitting model
  • Rich Visualizations: Generate plots and animations of fitting results
  • Flexible Configuration: TOML-based configuration with command-line overrides
  • Real-World Data Ready: Includes preprocessing tools for RKI COVID-19 ICU data

Methodology

The estimator is built on the following principles:

Convolution Model

We assume that individual patient length of stay (LoS) follows a probability distribution (e.g., lognormal, gamma). By convolving the admission time series with discharge probabilities derived from the LoS distribution, we can model expected occupancy over time:

\text{Occupancy}(t) = \sum_{\tau=0}^{t} \text{Admissions}(t-\tau) \cdot P(\text{LoS} > \tau)
Deconvolution Problem
Given observed admissions and occupancy, estimating the LoS distribution can be described as the inverse problem of fitting distribution parameters to minimize prediction error.
Temporal Dynamics
LoS distributions may shift due to treatment protocol changes, patient demographics, or disease characteristics. The estimator uses a rolling window approach to track these changes, fitting distributions on overlapping time windows.
Uncertainty Quantification
Each window's fit optimizes distribution parameters against a loss surface; a Laplace approximation around that optimum (finite-difference Hessian of the loss, rescaled by the residual variance) gives an approximate posterior covariance. Sampling from it and rejecting draws outside physically valid parameter ranges yields percentile bands on the fitted kernel, predicted occupancy, and per-parameter standard errors, together with an empirical coverage check against the nominal confidence level. This is opt-in via uncertainty_config and off by default.

The animation below illustrates the rolling window training process:

Rolling Window LoS Estimation Animation

Figure: Evolution of fitted LoS distributions across time windows

Quick Start

Installation

git clone git@github.com:JRC-COMBINE/los-estimator.git
cd los-estimator
python -m venv .venv

# On Windows
.\.venv\Scripts\activate

# On Linux/macOS
source .venv/bin/activate

python -m pip install --upgrade pip
pip install -e .

Run Synthetic Example

python examples/synthetic_example.py

This example runs with uncertainty_config.enabled = true, so its output also includes kernel/prediction uncertainty bands, per-parameter standard errors, and coverage metrics (see Output Format).

Run with Real Data

python -m los_estimator --config_file los_estimator/default_config.toml

Run Tests

pip install -e ".[dev]"
pytest

Documentation

Full documentation is available at: https://los-estimator.readthedocs.io/

Project Structure

los-estimator/
├── los_estimator/          # Main package
│   ├── cli/                # Command-line interface
│   ├── config/             # Configuration management
│   ├── core/               # Core data structures
│   ├── data/               # Data loading and preprocessing
│   ├── evaluation/         # Model evaluation
│   ├── fitting/            # Distribution fitting algorithms
│   └── visualization/      # Plotting and animation
├── examples/               # Example scripts and data
├── docs/                   # Sphinx documentation
├── tests/                  # Unit and integration tests
└── results/                # Output directory (created at runtime)

Contact

For questions, issues, or contributions:

Links

Documentation: https://los-estimator.readthedocs.io/

Source: https://github.com/JRC-COMBINE/los-estimator

Issue tracker: https://github.com/JRC-COMBINE/los-estimator/issues

About

Length of Stay Estimator for ICU data using deconvolution

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages