Skip to main content

COMES — COx with MEmory via Stable subordinators

Recurrent events with memory: regression on an operational clock.

comes fits regression models for recurrent events whose gaps have memory. Each subject's events form a Poisson process run on a random operational clock, the inverse α-stable subordinator, with the covariates acting on the operational rate. The gaps then follow a Mittag-Leffler renewal law, events come in bursts, exp(β) is a rate ratio on the operational clock, and α = 1 is the Andersen–Gill model with a constant baseline. The package contains:

  • fit_memory: maximum likelihood for (α, λ, β) from Mittag-Leffler gaps, with the boundary test of α = 1 and sandwich standard errors clustered by subject;
  • fit_memcox: the flexible operational baseline (piecewise constant in operational time, forward-filter likelihood);
  • fit_combined: memory and gamma frailty in one likelihood, on exact times or on grid-recorded occupancy;
  • fit_mmpp: a switching risk (two-state Markov-modulated Poisson process with gamma frailty), the main impostor of memory;
  • analyze: the analysis protocol, covering the effective time resolution, the memory, heterogeneity, trend and combined models, the tournament between them, and a report;
  • the competitors (fit_frailty_gamma, fit_nhpp_weibull, fit_weibull_gap_frailty, ag_fit), the occupancy likelihoods (fit_rounded_ml and the others), diagnostics and the bootstrap of α = 1;
  • simulate: cohorts from the model and from its competitors; example_cohort(): the example data of the manual.

Installation

pip install comes

Python ≥ 3.10. The dependencies (numpy, scipy, mpmath) are installed with it.

Example

import numpy as np
import comes

rng = np.random.default_rng(1)
n = 200
X = rng.binomial(1, 0.5, (n, 1)).astype(float)            # a binary covariate
taus = np.full(n, comes.tau_for_mean_events(0.7, 3.0))     # three expected events at x = 0
d = comes.simulate(X, [np.log(2.0)], taus, rng, alpha=0.7)  # memory with alpha = 0.7, rate ratio 2

fit = comes.fit_memory(d)
print(fit["alpha"], fit["beta"], fit["se_beta_robust"], fit["p_alpha_eq_1"])

The cohort format is a dict of aligned arrays, one row per (start, stop] interval: id, start, stop, event, and the covariates in X (rows × p) or x.

Data sets

example_cohort() returns the simulated cohort used in the documentation; it ships with the package. The loaders load_bladder1, load_cgd, load_rhdnase and load_kidney read four clinical data sets of the R package survival from CSV files in a directory of your choice. This R code writes the files:

library(survival)
dir.create("survival_data", showWarnings = FALSE)
write.csv(bladder1, "survival_data/bladder1.csv", row.names = FALSE)
write.csv(cgd,      "survival_data/cgd.csv",      row.names = FALSE)
write.csv(kidney,   "survival_data/kidney.csv",   row.names = FALSE)
# rhDNase: the rows at risk, as in the documentation of survival::rhDNase
first <- subset(rhDNase, !duplicated(id))
dnase <- tmerge(first, first, id = id, tstop = as.numeric(end.dt - entry.dt))
temp.end <- with(rhDNase, pmin(ivstop + 6, end.dt - entry.dt))
dnase <- tmerge(dnase, rhDNase, id = id, infect = event(ivstart), end = event(temp.end))
dnase <- subset(dnase, (infect == 1 | end == 0), c(id:trt, fev:infect))
write.csv(dnase[, c("id", "inst", "trt", "fev", "tstart", "tstop", "infect")],
          "survival_data/rhDNase_ag.csv", row.names = FALSE)

Then, in Python, comes.load_bladder1("survival_data") and the other loaders return cohorts ready for analyze.

Documentation

Every public function has a docstring with an example (help(comes.fit_memory)). The reference manual documents the model and its competitors, the analysis protocol and a tutorial on the example data. The same models are implemented in the R package comes and in the Julia package Comes.jl.

Author and citation

Calin-Adrian Comes (ORCID 0000-0003-2013-5589), Department of Economic Sciences, Faculty of Economics and Law, George Emil Palade University of Medicine, Pharmacy, Science and Technology of Targu Mures, Romania; Institute of National Economy - Romanian Academy, Bucharest, Romania.

To cite the software: Comes, C.-A. (2026). COMES - COx with MEmory via Stable subordinators (Python package comes). The method: Comes, C.-A. Recurrent events with memory: regression on an operational clock, and what the usual models estimate (manuscript, 2026). Licence: MIT.

Metadata

Release files for comes 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for comes 0.3.0
File Size Uploaded Provenance Actions
comes-0.3.0.tar.gz 125.2 kB Without provenance Details for comes-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for comes 0.3.0
File Interpreter ABI Platform Actions
comes-0.3.0-py3-none-any.whl Python 3 none any Details for comes-0.3.0-py3-none-any.whl

Total release size: 263.0 kB

Release files / comes-0.3.0.tar.gz

Download URL comes-0.3.0.tar.gz
Size 125.2 kB
Tags Source
SHA-256 checksum
How to use checksums
67e47447a8815f9d95f4a3a9a504b4ab0659d8518ee3ffb2fc422d6ad91194ca
BLAKE2b-256 checksum
How to use checksums
8f3b0a27ed754a1edea2548107a1f153304da7d276bf98a81e24b3ebfcde7c38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / comes-0.3.0-py3-none-any.whl

Download URL comes-0.3.0-py3-none-any.whl
Size 137.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c4182ceb94b3bd9fffa8ce1421b4fbc45fb0b3760689b2f9d7280f65a034231
BLAKE2b-256 checksum
How to use checksums
37e3ce9bb9313c8f942951117ab4df287c6740ae3ddc9271a0cb171815953a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for comes 0.3.0

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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page