Skip to content

Add hospital length of stay notebook - #914

Open
andreshernandez-spec wants to merge 1 commit into
pymc-devs:mainfrom
andreshernandez-spec:los-censored-gamma
Open

andreshernandez-spec wants to merge 1 commit into
pymc-devs:mainfrom
andreshernandez-spec:los-censored-gamma

Conversation

@andreshernandez-spec

Copy link
Copy Markdown

Adds survival_analysis/hospital_length_of_stay, a hierarchical Gamma model for hospital length of stay:

  • on a simulated outbreak: the bias of averaging completed stays, the fit with pm.Censored, recovery of the simulated values and a two-week bed forecast with pm.Truncated;
  • on New York's 2024 COVID-19 discharges (SPARCS): lengths of stay are recorded in whole days, so each is an interval, written with pt.gammainc/pt.gammaincc in a pm.Potential. Taking the recorded days as exact stays adds about a day to every mean and makes the fitted shape 1.4 to 3.5 times larger.

The SPARCS stays are in examples/data/sparcs_2024_covid19_stays.csv: the 18,290 COVID-19 stays of the public de-identified 2024 file, one row per stay, four columns. The notebook shows how the file was made and includes the disclaimer SPARCS asks for.

Runs in about 10 minutes on PyMC 6.4.0.

Prepared with AI assistance (Claude Code); I reviewed and tested every change.

A hierarchical censored Gamma model of hospital length of stay. On a
simulated outbreak it shows the bias of averaging completed stays, recovers
the simulated values and forecasts the beds of today's patients for two
weeks. On New York's 2024 COVID-19 discharges (SPARCS) it fits the
whole-day lengths of stay as intervals. The SPARCS stays are in
examples/data/sparcs_2024_covid19_stays.csv.
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

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

Successfully merging this pull request may close these issues.

1 participant