Skip to main content

glmm

Linear-regression family — OLS → GLM → LMM → GLMM — in pure Rust, with an eight-name Python API.

License: LGPL-3.0-or-later

Fits fixed-effect and mixed (random-intercept / random-slope) models for Gaussian, Binomial (logit/probit), Poisson, Gamma, and Negative-Binomial outcomes. The numerics are the glmm Rust crate — no BLAS/LAPACK system dependency, no unsafe, validated against R/lme4 and Julia/MixedModels.jl goldens.

Install

pip install glmm

Requires Python 3.10+. The only runtime dependency is NumPy.

One call

You hand fit a data table and an R-style formula. It parses the formula against the table's columns, builds the design matrix, fits, and returns a Fit. There is no model object to construct.

import glmm

data = {
    "y":     [1.02, 1.05, 1.11, 1.13, 1.21, 1.24, 1.30, 1.33, 1.42, 1.44, 1.51, 1.53],
    "x1":    [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1],
    "group": ["a", "a", "b", "b", "c", "c", "d", "d", "e", "e", "f", "f"],
}

# y ~ x1 + (1 | group) — Gaussian, random intercept.
fit = glmm.fit(data, "y ~ x1 + (1 | group)")

assert fit.converged
fit.summary()   # prints the coefficient table (and returns it as a string)

The public surface is eight names: glmm.fit, glmm.Fit, and the six warning categories the diagnostics channel raises — glmm.DiagnosticWarning (the base) plus glmm.IllConditionedWarning, glmm.PirlsExhaustedWarning, glmm.UnusedGroupingLevelsWarning, glmm.ReDesignScaleWarning and glmm.HessianSeFallbackWarning. Families, links, and knobs are string or scalar arguments, not types.

data is documented as a dict[str, array-like], but anything column-addressable works — pandas / polars DataFrame, pyarrow Table — by duck-typing, so there is no dataframe dependency.

Model routing

Routing is inferred from the formula and family — fixed-only means OLS/GLM, adding a (… | g) term makes it LMM/GLMM.

family default link other links fixed-only with (… | g)
gaussian identity — OLS LMM
binomial logit probit, cloglog GLM GLMM
poisson log — GLM GLMM
gamma log inverse GLM GLMM
negativebinomial log — GLM GLMM
inversegaussian log inverse_squared GLM random effects raise
fit = glmm.fit(data, "s ~ x1 + (1 | group)", "binomial", link="probit", nagq=7)

The formula follows R conventions: * desugars to main effects + interaction, A/B to nesting, (1 + x | g) is a correlated random intercept + slope, and additional (… | g2) terms add crossed or nested grouping factors. Treatment contrasts (R's default) code the factors against the column's first level; the full syntax, rejected constructs and workarounds, and factor-coding rules are in formula.md.

Not yet implemented

Two combinations have an approved design but no kernel support, and raise a clean NotImplementedError: quasi-likelihood dispersion= on binomial/poisson, and a float init_theta= seed (only the default init_theta=None cold start is supported). See troubleshooting.md for fixes to common errors.

Documentation

Full walkthrough — every knob, the Fit object, and warm starts: tutorial-python.md.

The algorithm map (dispatch graph, solver paths, tuning knobs) is traced to code in documentation/algorithms.md.

License

LGPL-3.0-or-later.


Paweł Lenartowicz — Freestyler Scientist · GitHub · ORCID

Metadata

Release files for glmm 0.3.2

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

Source distribution (sdist)

Source distribution for glmm 0.3.2
File Size Uploaded
glmm-0.3.2.tar.gz 1.2 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for glmm 0.3.2
File Interpreter ABI Platform
glmm-0.3.2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
glmm-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
glmm-0.3.2-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 9.1 MB

Release files / glmm-0.3.2.tar.gz

Download URL glmm-0.3.2.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
e6e4fca11163416822dd4e528915ca21c80e20913c34fd9d3dcea98d0cf27de8
BLAKE2b-256 checksum
How to use checksums
e439be6a3e2657baf7e62f9d582787f91e96489d6e403cc06f18484e088f99c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release files / glmm-0.3.2-cp310-abi3-win_amd64.whl

Download URL glmm-0.3.2-cp310-abi3-win_amd64.whl
Size 2.7 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7632e2906d8689e178c719941cdd0cd1d75918cf362b946e628050513ebe3d7e
BLAKE2b-256 checksum
How to use checksums
d1bef3c8a3f9313de5af0dc8ee16723a547cde018deb938fcc2b5849fa26c010
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release files / glmm-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL glmm-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl
Size 3.0 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
e852a8fbfbd31253c3df1908d56a7bd666152f1aa815c1da05d3fe9fd60a584c
BLAKE2b-256 checksum
How to use checksums
0130719a0df2a1c6b851feb4f21c6d9efeff9be2583d7f38dd0ba7fa451d763e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release files / glmm-0.3.2-cp310-abi3-macosx_11_0_arm64.whl

Download URL glmm-0.3.2-cp310-abi3-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ec25f4a57d3b04441e4915e712d73a9588fd01d86568c48e046ba49a8a914060
BLAKE2b-256 checksum
How to use checksums
98db00eee7ecbdc454179500d74c2356d73e0f41b26283711087c49a899da4df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.6.0

4 release files

0.5.0

4 release files

This release

0.3.2 This release

4 release files

0.3.1

4 release files

0.3.0

4 release files

0.2.0

4 release files

0.1.3

4 release files

0.1.2

4 release files

0.1.1

4 release files

0.1.0

4 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