Multstate modeling in Python
Project description
Multistate competing risk models in Python
Hagai Rossman, Ayya Keshet, Malka Gorfine 2022
PyMSM is a Python implementation of Competing Risks and Multistate models for survival data.
Features include:
- Fit a Multistate model based on survival analysis 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.
- Configure a pre-defined simulation model and run simulations.
- Modularity and compatibility for different time-to-event models such as Survival Forests or other custom models.
Installation
pip install pymsm
Quick example
# Load data
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, default_update_covariates_function
multi_state_model = MultiStateModel(
dataset,
terminal_states,
default_update_covariates_function)
# Fit to data
multi_state_model.fit()
# Run Monte-carlo simulation
all_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 = 100)
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymsm-0.1.6.tar.gz
(415.8 kB
view hashes)
Built Distribution
pymsm-0.1.6-py3-none-any.whl
(427.8 kB
view hashes)