Multistate competing risk models in Python
Hagai Rossman, Ayya Keshet, Malka Gorfine 2022
PyMSM is a Python package for fitting competing risks and multistate models, with a simple API which allows user-defined model, predictions at a single or population sample level, statistical summaries and figures.
Features include:
- Fit a Competing risks Multistate model based on survival analysis (time-to-event) models.
- Deals with right censoring, competing events, recurrent events, left truncation, and time-dependent covariates.
- Run Monte-carlo simulations for paths emitted by the trained model and extract various summary statistics and plots.
- Load or configure a pre-defined model and run path simulations.
- Modularity and compatibility for different time-to-event models such as Survival Forests and other custom models.
Installation
pip install pymsm
Requires Python >=3.8
Quick example
# Load data (See Rotterdam example for full details)
from pymsm.datasets import prep_rotterdam
dataset, states_labels = prep_rotterdam()
# Define terminal states
terminal_states = [3]
#Init MultistateModel
from pymsm.multi_state_competing_risks_model import MultiStateModel
multi_state_model = MultiStateModel(dataset,terminal_states)
# Fit model to data
multi_state_model.fit()
# Run Monte-Carlo simulation and sample paths
mcs = multi_state_model.run_monte_carlo_simulation(
sample_covariates = dataset[0].covariates.values,
origin_state = 1,
current_time = 0,
max_transitions = 2,
n_random_samples = 10,
print_paths=True)
stateDiagram-v2
s1 : (1) Primary surgery
s2 : (2) Disease recurrence
s3 : (3) Death
s1 --> s2: 1518
s1 --> s3: 195
s2 --> s3: 1077
Full examples
Citation
If you found this library useful in academic research, please cite:
@software{Rossman_PyMSM_Multistate_modeling_2022,
author = {Rossman, Hagai and Keshet, Ayya and Gorfine, Malka},
doi = {https://doi.org/10.5281/zenodo.6300873},
license = {MIT},
month = {2},
title = {{PyMSM, Multistate modeling in Python}},
url = {https://github.com/hrossman/pymsm},
year = {2022}
}
Also consider starring the project on GitHub
This project is based on methods first introduced by the authors of Roimi et. al. 2021.
Original R code by Jonathan Somer, Asaf Ben Arie, Rom Gutman, Uri Shalit & Malka Gorfine available here.
Also see Rossman & Meir et. al. 2021 for an application of this model on COVID-19 hospitalizations data.
Metadata
Release files for pymsm 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymsm-0.1.7.tar.gz | 416.3 kB | Without provenance | Details for pymsm-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymsm-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for pymsm-0.1.7-py3-none-any.whl |
Total release size: 844.5 kB
Release files / pymsm-0.1.7.tar.gz
| Download URL | pymsm-0.1.7.tar.gz |
|---|---|
| Size | 416.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25b43bbd7b9350da9b3f4147cbdcb87aced294ed50cb368ff024168391232831
|
|
BLAKE2b-256 checksum How to use checksums |
26456615a285bf809e8eabf059b894b5abfae5f4a8244f518fbf337d60c97c62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.7.0 Linux/5.10.16.3-microsoft-standard-WSL2
|
Release files / pymsm-0.1.7-py3-none-any.whl
| Download URL | pymsm-0.1.7-py3-none-any.whl |
|---|---|
| Size | 428.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1203effe745be716b420d9dc654cc90764e4244abf04bdac7a1bf61fadc3106d
|
|
BLAKE2b-256 checksum How to use checksums |
66d4906b1032d799623d88ffa15119a47251fcad547b8645a9eaf79e71ec3ea0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.7.0 Linux/5.10.16.3-microsoft-standard-WSL2
|
Security for pymsm 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.