Skip to main content

glmm

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

License: GPL-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

GPL-3.0-or-later.


Paweł LenartowiczFreestyler Scientist · GitHub · ORCID

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glmm-0.3.1.tar.gz (941.9 kB view details)

Uploaded Source

Built Distributions

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

glmm-0.3.1-cp310-abi3-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

glmm-0.3.1-cp310-abi3-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

glmm-0.3.1-cp310-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file glmm-0.3.1.tar.gz.

File metadata

  • Download URL: glmm-0.3.1.tar.gz
  • Upload date:
  • Size: 941.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glmm-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f38cac14d01462db39e7228c77fbff2db5f45c0d4c47c673dfdebb3f99efda38
MD5 aa032091012c9d53eab05b066f1c0f06
BLAKE2b-256 27d3313854a9d48d44f9d9501155b28cc9d2f330c2513d45f325b5028cc67fde

See more details on using hashes here.

Provenance

The following attestation bundles were made for glmm-0.3.1.tar.gz:

Publisher: release.yml on pawlenartowicz/glmm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glmm-0.3.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: glmm-0.3.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glmm-0.3.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9c63e39cff1790949302deeedb472e5a8c75fbba5c123a7a1750d43b8cda89d9
MD5 d1dd600b9ba3c4206c371d6f0cd5c27c
BLAKE2b-256 9803948cd460bc9464a5db0f53557b052bf9ec3c89dd6798bd6111f453598464

See more details on using hashes here.

Provenance

The following attestation bundles were made for glmm-0.3.1-cp310-abi3-win_amd64.whl:

Publisher: release.yml on pawlenartowicz/glmm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glmm-0.3.1-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for glmm-0.3.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5cf63488d8b3f8a95e8d0296c7259aa940d8017fb364493db35a76017978b049
MD5 53b2c7b6ce9dfd632040754147725aa6
BLAKE2b-256 1aa52d6ff7c77f014a0299ade59231aba698d68f339d859ecfad8c3013fe393a

See more details on using hashes here.

Provenance

The following attestation bundles were made for glmm-0.3.1-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on pawlenartowicz/glmm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glmm-0.3.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: glmm-0.3.1-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glmm-0.3.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37c7bd2aad01e8ddf5ce213550e3a53b7fbd2fd2fb5e928e4dd7b8fff01e5609
MD5 c1f2a4eba5605225fd403cd09807f532
BLAKE2b-256 4f480b731aca37b831071323f33ea9a2bc6c3e21499fb71475ee32f35a0372f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for glmm-0.3.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on pawlenartowicz/glmm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.1 This release

4 files

0.3.0

4 files

0.2.0

4 files

0.1.3

4 files

0.1.2

4 files

0.1.1

4 files

0.1.0

4 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