Skip to main content

splitpopsurv (Python)

Split-population (cure / mover–stayer) survival models in Python: an accelerated failure-time regression for event timing among "movers", combined with a logistic regression on the probability of belonging to the immune "stayer" population.

Five baseline timing distributions are provided — log-logistic, Weibull, log-normal, gamma, and the generalized gamma that nests the other four — following Schmidt & Witte (1989) and Yamaguchi (1992, 1998). This package is a Python translation of a set of Stata ml programs, with the log-likelihood corrected to match the published model and verified by simulation against known parameters.

📖 Full manual (theory, formulas, the likelihood correction, and a complete function reference): docs/manual.html

Companion packages implementing the same corrected models are available for R and Stata.

Author

Nobutaka Fukuda, Tohoku University — nobutaka.fukuda@tohoku.ac.jp

Installation

pip install git+https://github.com/nobifukuda/splitpopsurv-py.git

Usage

import pandas as pd
from splitpopsurv import fit_splitpop_weibull

# mydata needs: time, event (0/1), and your covariates
fit = fit_splitpop_weibull(
    data=mydata,
    time="time",
    event="event",
    h_vars=["x1"],       # H_regression: covariates for timing
    p_vars=["x2"],       # P_regression: covariates for cure probability
)

print(fit.summary())     # coefficients, SEs, z-values, log-likelihood
fit.params               # named parameter vector (numpy array)
fit.as_dataframe()        # coefficients table as a pandas DataFrame

The other four distributions use the same signature: fit_splitpop_loglogistic(), fit_splitpop_lognormal(), fit_splitpop_gamma(), fit_splitpop_ggamma().

A note on the original Stata code

All five Stata programs this package translates compute a log-likelihood term that turns out to be the marginal density where the formula requires the marginal hazard (density divided by survival) — a discrepancy from Yamaguchi's own published model. This was confirmed by fitting simulated data with known parameters: the as-translated formula gives visibly biased estimates, or fails to converge outright, while the corrected formula implemented here recovers the true parameters accurately. See docs/manual.html for the full derivation and the simulation results. This is the same correction independently verified for the R and Stata ports of this model.

Development

pip install -e ".[test]"
pytest

License

MIT — see LICENSE.

References

Prentice, R. L. (1974). A log gamma model and its maximum likelihood estimation. Biometrika, 61(3), 539–544.

Schmidt, P., & Witte, A. D. (1989). Predicting criminal recidivism using "split population" survival time models. Journal of Econometrics, 40(1), 141–159.

Yamaguchi, K. (1992). Accelerated failure-time regression models with a regression model of surviving fraction: An application to the analysis of "permanent employment" in Japan. Journal of the American Statistical Association, 87(418), 284–292.

Yamaguchi, K., & Ferguson, L. R. (1995). The stopping and spacing of childbirths and their birth-history predictors: Rational-choice theory and event-history analysis. American Sociological Review, 60(2), 272–298.

Yamaguchi, K. (1998). Mover-stayer models for analyzing event nonoccurrence and event timing with time-dependent covariates: An application to an analysis of remarriage. Sociological Methodology, 28(1), 327–361.

Release files for splitpopsurv 0.1.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 splitpopsurv 0.1.0
File Size Uploaded
splitpopsurv-0.1.0.tar.gz 13.3 kB Details

Built distribution (wheel)

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

Total release size: 24.3 kB

Release files / splitpopsurv-0.1.0.tar.gz

Download URL splitpopsurv-0.1.0.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1c78783fdf9d2d9582f8cb273a9f428311b9d86a50a9b963d9dfb6037177a765
BLAKE2b-256 checksum
How to use checksums
df0fca3bf3414e82d9a44b0df262dbc42ca8e2ca94c313715c59b00de9d0651a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release files / splitpopsurv-0.1.0-py3-none-any.whl

Download URL splitpopsurv-0.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc0b51ed1c2d986b7e9cd20a81fab03d6001d48c4523a4056b6014fccd95a078
BLAKE2b-256 checksum
How to use checksums
32cca2cd89e8e6c0287c78578f2fa00bf79b818fbef7461f39c996423cbeff08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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