Linear-regression family OLS / GLM / LMM / GLMM — Python port of the glmm crate
Project description
glmm
Linear-regression family — OLS → GLM → LMM → GLMM — in pure Rust, with a two-name Python API.
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 exactly two names: glmm.fit and glmm.Fit. 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 |
GLM | GLMM |
poisson |
log |
— | GLM | GLMM |
gamma |
log |
inverse |
GLM | GLMM |
negativebinomial |
log |
— | GLM | GLMM |
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
Four combinations have an approved design but no kernel support, and raise a
clean NotImplementedError: family="inversegaussian", link="cloglog",
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ł Lenartowicz — Freestyler Scientist · GitHub · ORCID
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glmm-0.1.1.tar.gz.
File metadata
- Download URL: glmm-0.1.1.tar.gz
- Upload date:
- Size: 646.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1b15726e2f0a7490a839e48057650492daacdeea56bde73f44d9a8325e563cb
|
|
| MD5 |
13286f92506d063fb8d9636674436cb5
|
|
| BLAKE2b-256 |
ab94b42c3d656ffbd03adc34d85e19488ccc9881ec54672a78c7a2974db2d139
|
Provenance
The following attestation bundles were made for glmm-0.1.1.tar.gz:
Publisher:
release.yml on pawlenartowicz/glmm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glmm-0.1.1.tar.gz -
Subject digest:
e1b15726e2f0a7490a839e48057650492daacdeea56bde73f44d9a8325e563cb - Sigstore transparency entry: 2194561125
- Sigstore integration time:
-
Permalink:
pawlenartowicz/glmm@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pawlenartowicz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file glmm-0.1.1-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: glmm-0.1.1-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57197c054dcf521390ae32b345585ada2469b2269ca9a5ed7d4bc010d462a80b
|
|
| MD5 |
ba5301cfba9e3aa0fcf163d90a7f39da
|
|
| BLAKE2b-256 |
3cc11e44c88a7b59268e3a9f2e1c74ef579bc9a3f7bba2d861400603a5911429
|
Provenance
The following attestation bundles were made for glmm-0.1.1-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on pawlenartowicz/glmm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glmm-0.1.1-cp310-abi3-win_amd64.whl -
Subject digest:
57197c054dcf521390ae32b345585ada2469b2269ca9a5ed7d4bc010d462a80b - Sigstore transparency entry: 2194561133
- Sigstore integration time:
-
Permalink:
pawlenartowicz/glmm@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pawlenartowicz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file glmm-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: glmm-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e818a3cfead530e651c4a34f80d3a8d01bf8c89688c990d118af3bbfbb55bf
|
|
| MD5 |
1a054a55cd1ea1b31d7418a68acb4095
|
|
| BLAKE2b-256 |
7da7fbe7661a43ff53e20306d2d1da80c5cfa8daaf2870f7c4bbb39e92683793
|
Provenance
The following attestation bundles were made for glmm-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on pawlenartowicz/glmm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glmm-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
47e818a3cfead530e651c4a34f80d3a8d01bf8c89688c990d118af3bbfbb55bf - Sigstore transparency entry: 2194561130
- Sigstore integration time:
-
Permalink:
pawlenartowicz/glmm@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pawlenartowicz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file glmm-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: glmm-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a501babe3b5966f9343d224bd9fa042b4f950a61bcf91cac309ecc0785d7b0a5
|
|
| MD5 |
38c2e3a0f0e91a987294f0e92d02601d
|
|
| BLAKE2b-256 |
fa8c08e7f76933d1b63b5cc0c0c47edc8cce3834961d0e6297851255fe1348e5
|
Provenance
The following attestation bundles were made for glmm-0.1.1-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on pawlenartowicz/glmm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glmm-0.1.1-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
a501babe3b5966f9343d224bd9fa042b4f950a61bcf91cac309ecc0785d7b0a5 - Sigstore transparency entry: 2194561138
- Sigstore integration time:
-
Permalink:
pawlenartowicz/glmm@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pawlenartowicz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9b7d6112905d6d71443e0df34fe0bb039a1ccf6 -
Trigger Event:
push
-
Statement type: