Skip to main content

codecov DOI CI

intreg

intreg is a lightweight Python package for fitting interval regression models to censored and interval-bounded data using maximum likelihood estimation.

It provides:

  • Interval regression (IntReg) for left-, right-, exact-, and interval-censored data
  • Mixed-effects interval regression (MeIntReg) using random intercepts
  • Optional L2 regularisation for fixed and random effects
  • A clean NumPy/SciPy-based API suitable for modelling, research, and simulation

The package is useful for modelling censored continuous outcomes such as MIC values, detection limits, truncated biological measurements, and any interval-coded response.


📦 Installation

Install from PyPI

pip install intreg

Install from source (developer mode)

pip install -e .

🧩 Package Structure

The package exposes two core classes:

Class Description
IntReg Interval regression without random effects. Handles all types of censoring.
MeIntReg Mixed-effects interval regression with random intercepts

Both models:

  • use a Gaussian likelihood
  • parameterise variance via log(sigma) for stability
  • accept optional L2_penalties={} to regularise parameters
  • optimise using scipy.optimize.minimize

Project layout (under src/):

intreg/
    __init__.py
    intreg.py
    meintreg.py

🔧 Basic Usage

1. Interval Regression (IntReg)

import numpy as np
from intreg import IntReg

y_lower = np.array([1.0, 2.0, -np.inf, 3.0])
y_upper = np.array([1.0, 2.5, 1.5, np.inf])

model = IntReg(y_lower, y_upper)
model.fit()

print(model.result.x)  # estimated [mu, log_sigma]

2. Mixed-Effects Interval Regression (MeIntReg)

import numpy as np
from intreg import MeIntReg

y_low = np.array([1.0, 2.0, 1.5, -np.inf])
y_high = np.array([1.0, 2.2, np.inf, 1.0])

X = np.column_stack([np.ones(4)])  # intercept-only model
groups = np.array([0, 0, 1, 1])

model = MeIntReg(y_low, y_high, X, random_effects=groups)
model.fit()

print(model.result.x)  # [beta, random_effects, log_sigma]

🧪 Testing

Tests are stored under:

temp/tests/

Run them using:

pytest

📄 License

MIT License.

Metadata

Release files for intreg 0.2.3

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

Source distribution (sdist)

Source distribution for intreg 0.2.3
File Size Uploaded Provenance Actions
intreg-0.2.3.tar.gz 16.6 kB Without provenance Details for intreg-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 29.0 kB

Release files / intreg-0.2.3.tar.gz

Download URL intreg-0.2.3.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fa62198f84f8f5593e25518c8f52e1076c8b99757a14685e196d99e2116284ab
BLAKE2b-256 checksum
How to use checksums
380b3fc73d003a3222a39d9153c34f7c2e3f1094cac28aabeaab047f0f63cf27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / intreg-0.2.3-py3-none-any.whl

Download URL intreg-0.2.3-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4eace0fdd9e72856ca5d1f9ef9ce2f1d8b57790aac1532f21c8c3b18fa489d78
BLAKE2b-256 checksum
How to use checksums
25258c7815c18babf9dcca492b78afcfdc1b3102d54762235522128fb50f270d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for intreg 0.2.3

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.

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