A Python package for simulating survival data, inspired by the R package genSurv
Project description
gen_surv
gen_surv is a Python package for simulating survival data under a variety of models, inspired by the R package genSurv. It supports data generation for:
- Cox Proportional Hazards Models (CPHM)
- Continuous-Time Markov Models (CMM)
- Time-Dependent Covariate Models (TDCM)
- Time-Homogeneous Hidden Markov Models (THMM)
๐ฆ Installation
poetry install
โจ Features
- Consistent interface across models
- Censoring support (
uniformorexponential) - Easy integration with
pandasandNumPy - Suitable for benchmarking survival algorithms and teaching
๐งช Example
from gen_surv import generate
# CPHM
generate(model="cphm", n=100, model_cens="uniform", cens_par=1.0, beta=0.5, covar=2.0)
# AFT Log-Normal
generate(model="aft_ln", n=100, beta=[0.5, -0.3], sigma=1.0, model_cens="exponential", cens_par=3.0)
# CMM
generate(model="cmm", n=100, model_cens="exponential", cens_par=2.0,
qmat=[[0, 0.1], [0.05, 0]], p0=[1.0, 0.0])
# TDCM
generate(model="tdcm", n=100, dist="weibull", corr=0.5,
dist_par=[1, 2, 1, 2], model_cens="uniform", cens_par=1.0,
beta=[0.1, 0.2, 0.3], lam=1.0)
# THMM
generate(model="thmm", n=100, qmat=[[0, 0.2, 0], [0.1, 0, 0.1], [0, 0.3, 0]],
emission_pars={"mu": [0.0, 1.0, 2.0], "sigma": [0.5, 0.5, 0.5]},
p0=[1.0, 0.0, 0.0], model_cens="exponential", cens_par=3.0)
๐ง Available Generators
| Function | Description |
|---|---|
gen_cphm() |
Cox Proportional Hazards Model |
gen_cmm() |
Continuous-Time Multi-State Markov Model |
gen_tdcm() |
Time-Dependent Covariate Model |
gen_thmm() |
Time-Homogeneous Markov Model |
genSurvPy/
โโโ gen_surv/ # Pacote principal
โ โโโ __main__.py # Interface CLI via python -m
โ โโโ cphm.py
โ โโโ cmm.py
โ โโโ tdcm.py
โ โโโ thmm.py
โ โโโ censoring.py
โ โโโ bivariate.py
โ โโโ validate.py
โ
โโโ tests/ # Testes automatizados
โ โโโ test_cphm.py
โ โโโ test_cmm.py
โ โโโ test_tdcm.py
โ โโโ test_thmm.py
โ
โโโ examples/ # Exemplos de uso
โ โโโ run_cphm.py
โ โโโ ...
โ
โโโ pyproject.toml # Configurado com Poetry
โโโ README.md
โโโ LICENSE
โโโ .gitignore
๐ง License
MIT License. See LICENSE for details.
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
gen_surv-0.7.2.tar.gz
(8.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
gen_surv-0.7.2-py3-none-any.whl
(12.3 kB
view details)
File details
Details for the file gen_surv-0.7.2.tar.gz.
File metadata
- Download URL: gen_surv-0.7.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.9.13 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
413ba5754415625be201a0ef995b0f42993577b0d3110849cf44157955230b60
|
|
| MD5 |
c0e7d502b28b54d78373183b5552e80d
|
|
| BLAKE2b-256 |
195dc82691c37a8896383255f021403cfca4634571d56ae5324fa7f1bd52e4f5
|
File details
Details for the file gen_surv-0.7.2-py3-none-any.whl.
File metadata
- Download URL: gen_surv-0.7.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.9.13 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aba7f4cc0072e8baf81c65ed9a63c0d66a4624d1f6446caa4c5a3dabb5a83ab
|
|
| MD5 |
fb7fbdf0c0ddbef537f0b97729e214b4
|
|
| BLAKE2b-256 |
32ecca9f96038e0db6024495b17d057deafb2821461a867a225f4379f1db9a6f
|