mixedlm
A Python implementation of mixed-effects models inspired by R's lme4 package. Features a Rust backend for performance-critical operations and native support for both pandas and polars DataFrames.
Documentation | PyPI | Changelog
Features
- Linear Mixed Models (LMM) via
lmer()- REML and ML estimation - Generalized Linear Mixed Models (GLMM) via
glmer()- Laplace approximation and adaptive Gauss-Hermite quadrature - Nonlinear Mixed Models (NLMM) via
nlmer()- Self-starting models (SSasymp, SSlogis, SSmicmen, and more) and custom nonlinear functions - Formula interface - lme4-style formulas with random effects syntax
- Tidy reporting - Analysis-ready coefficient, random-effect, and model-fit tables
- Inference tools - Linear hypotheses, profile likelihood, bootstrap, confidence intervals, Satterthwaite/Kenward-Roger degrees of freedom
- Model comparison - ANOVA (including Type III), drop1, allFit
- Model selection - AIC/AICc/BIC rankings, normalized weights, and evidence sets
- Model validation - Case-level, whole-group, and custom-partition cross-validation with weighted scoring and leakage checks
- Prediction uncertainty - Conditional LMM and GLMM mean intervals with joint fixed/random-effect covariance and prior variance for new groups
- Power analysis - powerSim, powerCurve for sample size planning
- Diagnostics - Dispersion and zero-inflation checks, influence measures, Cook's distance, leverage, VIF/GVIF, condition indices
- Fit metrics - Nakagawa marginal/conditional R² and adjusted/unadjusted ICC
- Fast startup - Public objects are loaded on demand, so lightweight imports avoid the modeling stack
Installation
pip install mixedlm
mixedlm requires Python >= 3.10, NumPy >= 1.23.5, SciPy >= 1.14, and pandas >= 1.4.
Optional extras add polars input (mixedlm[polars]), plotting with matplotlib
(mixedlm[plots]), and nlopt optimizers (mixedlm[optimizers]). Building from
source requires a Rust toolchain; see the
installation guide.
Quick Start
import mixedlm as mlm
# Random intercept and slope for each subject
data = mlm.load_sleepstudy()
result = mlm.lmer("Reaction ~ Days + (Days | Subject)", data)
print(result.summary()) # Includes p-values via Satterthwaite DF
result.fixef() # Fixed effects
result.ranef() # Random effects (BLUPs)
result.VarCorr() # Variance components
result.tidy(conf_int=True) # Analysis-ready pandas table
# Binomial GLMM with successes / trials responses
cbpp = mlm.load_cbpp()
gm = mlm.glmer(
"incidence / size ~ period + (1 | herd)", cbpp, family=mlm.families.Binomial()
)
print(gm.summary())
Documentation
- Quickstart and Coming from R
- Tutorials for LMMs, GLMMs, NLMMs, inference, and power analysis
- API reference
- Contributing, including development setup and CI
- Changelog
License
The mixedlm code uses the MIT License; see LICENSE. The bundled lme4 datasets retain their upstream GPL (>= 2) license, with attribution and license text in datasets/data.
Acknowledgments
This package is inspired by and aims to be compatible with R's lme4 package by Douglas Bates, Martin Maechler, Ben Bolker, and Steve Walker.
Metadata
Release files for mixedlm 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mixedlm-1.3.0.tar.gz | 1.4 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| mixedlm-1.3.0-cp314-cp314t-win_amd64.whl | CPython 3.14 | CPython 3.14 free-threading | Windows x86-64 | Details |
| mixedlm-1.3.0-cp314-cp314t-manylinux_2_28_x86_64.whl | CPython 3.14 | CPython 3.14 free-threading | Linux glibc 2.28+ x86-64 | Details |
| mixedlm-1.3.0-cp314-cp314t-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 free-threading | macOS 11.0+ ARM64 | Details |
| mixedlm-1.3.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| mixedlm-1.3.0-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| mixedlm-1.3.0-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| mixedlm-1.3.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| mixedlm-1.3.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 16.6 MB
Release files / mixedlm-1.3.0.tar.gz
| Download URL | mixedlm-1.3.0.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70f6db1606950857a8f1f200448708ea4399c5171a53fab74fe9048b7bd6c745
|
|
BLAKE2b-256 checksum How to use checksums |
48498428508c61d6b71759e3515f463aa7984c910bf93061afdc545eaed596df
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp314-cp314t-win_amd64.whl
| Download URL | mixedlm-1.3.0-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a8cf5679fdfb44981fd92ef772a0c8898491c41365dc0560b2e64e4fdd65e024
|
|
BLAKE2b-256 checksum How to use checksums |
8575e743965bd5dbddc4b7c19a98db42da3668c6730a68da7c6b57ab00f73f2c
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp314-cp314t-manylinux_2_28_x86_64.whl
| Download URL | mixedlm-1.3.0-cp314-cp314t-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ad8b81227976f17f86743cd0f740a4277f08ee34c61ba40bd5a985ce4b9422a7
|
|
BLAKE2b-256 checksum How to use checksums |
138ce02772b99718ab0210e31b1783d1c882da5184002e424abb39e2d44c5d7a
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | mixedlm-1.3.0-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5d1c14fea25dd0698df372eec4169996849463c64287bcb312367a2e74e9965b
|
|
BLAKE2b-256 checksum How to use checksums |
d2deff3ed0c9733ee75bf685a529c980f3543942d186c32067168596afc4dbbd
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp310-abi3-win_amd64.whl
| Download URL | mixedlm-1.3.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
6c45d30b1c5eb86ed392b7294a79ce50ed2f751fb33bf0e017fdecca49eb50bd
|
|
BLAKE2b-256 checksum How to use checksums |
257ce6f3c814031c6bb2928bcd8e650f148b5efc46c998ce66716317bf005b61
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | mixedlm-1.3.0-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
63276347f4fa7730b7b819031e053a6b6683f191dcc2fce6aac6b43c00ee159d
|
|
BLAKE2b-256 checksum How to use checksums |
c0d80125fb2b9b8392c5815850e5d9595582ab97747fe0258ae62b2522bb2d44
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | mixedlm-1.3.0-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8c844539bdd89c3b7a643937d810836a4e37e15957a6fbdd6d8a62c7b12a5d1f
|
|
BLAKE2b-256 checksum How to use checksums |
04860a1cb6edc87764ea8ee646d5e99d8bf20b84cdacd692f01a49899508f4cf
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | mixedlm-1.3.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a04c2ca7a7af7f65e3272a43ee28c0226744aa6c52e9d495a0ebe251dea56f2d
|
|
BLAKE2b-256 checksum How to use checksums |
8d45bb522c993b7953a093c24401a6e2d91ecf3b1611d2e91c3dca64bc050e02
|
| 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 Oct 11, 2026.
Transparency logRelease files / mixedlm-1.3.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | mixedlm-1.3.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
150c0494e32ac48e1da93ce935a7caa794215a69ad75a62897ad15778415027e
|
|
BLAKE2b-256 checksum How to use checksums |
6374ed68ebd24b0fcfbe63887a923e7bf6063949add2ec79f362205239c88948
|
| 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 Oct 11, 2026.
Transparency log