interlace¶
interlace is a pure-Python mixed-effects modelling library — targeting
parity with R’s lme4,
ordinal,
coxme, and
nlme, and designed as a drop-in
replacement for
statsmodels.MixedLM
in production pipelines.
It supports linear (LMM), generalised (GLMM), cumulative link (CLMM), and Cox frailty mixed models with crossed or nested random effects.
Why interlace?¶
statsmodels.MixedLM is built around a single grouping factor. When a model has two
independent sources of variance — say, subject and item — there is no native
syntax for crossed random intercepts, and the available workarounds produce estimates
that diverge from REML. interlace fills that gap, implementing the same profiled REML
and sparse Cholesky machinery as R’s lme4::lmer().
Coming from Python / statsmodels? See For Python users for a side-by-side comparison and explanation of the limitation.
Coming from R / lme4? See For R users for formula syntax mapping and shared references.
Key features¶
LMM — crossed / nested random intercepts and slopes, REML or ML, Satterthwaite or Kenward-Roger DFs
GLMM — Laplace or adaptive Gauss-Hermite quadrature; 10+ families including binomial, Poisson, NB1/NB2, Beta, Gamma, zero-inflated, hurdle, and ZOIB
CLMM — ordinal regression with random effects, matching R’s
ordinal::clmm()Cox frailty — Cox PH with Gaussian frailty, matching R’s
coxme::coxme()Correlation structures — AR(1) and compound symmetry for longitudinal data
Sparse throughout — Z is never materialised as a dense matrix
Full suite of diagnostics: residuals, leverage, Cook’s D, MDFFITS, influence plots
Compatible result object exposing the same attributes as
statsmodels.MixedLMResultsValidated against R reference implementations to tight tolerances
Get started¶
Install interlace and fit your first crossed random-intercepts model.
Fit GLMMs with glmer() — binomial, Poisson, NB, Beta, and more.
Ordinal regression with random effects via clmm().
Survival models with shared frailty via coxme().
AR(1) and compound symmetry correlation structures for repeated measures.
Full documentation for every public function and result object.