Skip to main content

A Python package for simulating survival data, inspired by the R package genSurv

Project description

gen_surv

Coverage Docs PyPI Tests Python

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 (uniform or exponential)
  • Easy integration with pandas and NumPy
  • Suitable for benchmarking survival algorithms and teaching

๐Ÿงช Example

from gen_surv.cphm import gen_cphm

df = gen_cphm(
    n=100,
    model_cens="uniform",
    cens_par=1.0,
    beta=0.5,
    covar=2.0
)
print(df.head())
from gen_surv import generate

df = generate(
    model="cphm",
    n=100,
    model_cens="uniform",
    cens_par=1.0,
    beta=0.5,
    covar=2.0
)

print(df.head())

๐Ÿ”ง 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


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.6.9.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gen_surv-0.6.9-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file gen_surv-0.6.9.tar.gz.

File metadata

  • Download URL: gen_surv-0.6.9.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.9.13 Darwin/24.4.0

File hashes

Hashes for gen_surv-0.6.9.tar.gz
Algorithm Hash digest
SHA256 752b611e2cab0189820dc02aac1d4824428bb765f37a238fb3b6d693f058d57a
MD5 ae7c99e3ee9755c63b71874cb92f6cf5
BLAKE2b-256 6bf035adc88bc4273bbdbcca5717a7d7a3b2d89cd2fbc34355fd1b42c7f46c83

See more details on using hashes here.

File details

Details for the file gen_surv-0.6.9-py3-none-any.whl.

File metadata

  • Download URL: gen_surv-0.6.9-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.9.13 Darwin/24.4.0

File hashes

Hashes for gen_surv-0.6.9-py3-none-any.whl
Algorithm Hash digest
SHA256 faa857cda815d3f3aaa76922cf4acd08ebcd1b3054e177123a8c7465d608e1c1
MD5 e3a8271c649be2b6a9c4554514a7497d
BLAKE2b-256 8030005c1f3c5cc2c1e928edb55a7bfdfe9dea3bb3e2cb4f1437f30e2e160768

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page