Expand description
glmm — standalone f64 GLMM fit kernels (OLS → GLM → LMM → GLMM).
Two public surfaces:
-
fit_cold/fit_warm+ModelSpec+GroupIds: the stable, semver-covered friendly API. -
loop_advanced(cargo feature, off by default): the unstable scratch-explicit hot-path surface (loop tier) that warm-start consumers like MCPower bind to, exposing the kernels andStartValues. NO semver guarantees. -
formula(cargo feature, on by default): the R-style formula frontend —formula::lower("y ~ x + (1|g)", &table, family)builds the kernel’s inputs from a formula string and a data table instead of by hand. -
orchestrate(cargo feature, off by default): the string-typed fit orchestration the FFI ports (glmm-python,glmm-r) share — likeloop_advanced, NO semver guarantees.
parallel (cargo feature, off by default, experimental): enables in-fit
parallelism (AGQ cluster loop, FD-Hessian grid) via rayon’s global pool; a
no-op on wasm32; gated at runtime by FitOptions::parallel_inner (also off
by default — both the feature and the knob are explicit opt-ins).
Modules§
- consts
- Scratch-bounding capacity constants.
glmmowns these; they size the solver’s stack buffers, so they are HARD ceilings. These ceilings live here inconstsas the single source, no drift. - dual
- Crate-own forward-mode dual number types.
- formula
- R-style formula frontend for the
glmmkernel. - linalg
- Linear-algebra primitives shared by the sim and fit layers.
- scalar
- The scalar type the blocked fit kernel is generic over.
- simd_
transcendental - Restricted-domain SIMD transcendentals for the GLM/GLMM fit path — a single
compiled-in, full-precision
exp/log1pthat vectorizes across the PIRLS row loop (the scalar libmexp/ln_1pare extern calls the compiler cannot vectorize; profiling put them at ~51% of the no-extras GLMM fit).
Structs§
- Diagnostics
- Everything a fit reports about itself, reached as
fit.diagnostics. - Fit
- Result of
fit. Fixed-effect estimates cover all p predictors; SE and tau2 have the ranges below. Non-target SE slots are NaN. - FitOptions
- Options for
fit. Carries the safe, defaulted method knobs: unlike a warm start these do not silently move the estimate based on a caller’s guess. - Group
Ids - Per-row random-effect level ids for one fit. Each vector has length
n. - Grouping
- An extra (crossed or nested) grouping factor beyond the primary grouping.
slopesare the random-slope design columns; the RE correlation structure is always full (parametrized by the fitted θ). Structure-only, likeModelSpec: magnitudes and warm starts are not carried here. - Model
Spec - The kernels’ model-spec input.
familyselects the outcome kernel;reselects fixed-only vs mixed (None→ OLS/GLM,Some→ LMM/GLMM). - ReStructure
- Random-effect structure of a mixed model — present iff the model has random
effects. Carried in
ModelSpec::reasOption, soNoneis a fixed-only model (OLS/GLM) andSomeis mixed (LMM/GLMM): an OLS-with-grouping state is unrepresentable. Holds exactly the RE fields the LMM/GLMM kernels read. - Start
Values - Raw optimizer warm-start state for one model fit.
Enums§
- Binomial
Link - Binomial link function.
Logitis canonical (the fused-SIMD kernel);ProbitandCloglogboth use the general Fisher-scoring branch. - Boundary
- Where the accepted θ sits in its parameter space.
- Family
- Outcome distribution + link. Selects the fit kernel together with
ModelSpec::re(re.is_some()⇒ mixed):Gaussian→ OLS / LMM,Binomial{Logit}→ GLM / GLMM. Every variant here has a wired kernel, so no kernel-less variant is reachable throughcrate::fit_cold. - Gamma
Link - Gamma link function.
Logis the safe default;Inverseis the classic Gamma link but can driveμ≤0mid-IRLS (domain-clamped). - Grouping
Relation - How an extra grouping’s clusters map onto rows, relative to the primary grouping.
- Inverse
Gaussian Link - Inverse-Gaussian link function.
Logis the safe default;InverseSquaredis R’sinverse.gaussian()default and can driveμ≤0mid-IRLS (domain-clamped). - NegBinomial
Link - Negative-binomial link function. Only the log link is offered.
- Note
- A solver observation about the fit that has no dedicated field. The enum variant, not any English sentence, is the stable identifier a caller filters on; the wrappers turn each variant into their own warning category (Python) or condition class (R).
- Poisson
Link - Poisson link function. Only the canonical log link is offered.
- Sizing
- Cluster sizing regime: a fixed cluster count, or a fixed per-cluster size.
- WaldSe
- GLMM fixed-effect Wald-SE denominator.
Constants§
- THETA0
- The blind θ start. Re-exported because a caller that must supply
StartValues(β and θ are bundled) cannot reach theNone-θ blind path, and so has to reproduce that start explicitly. θ start — DIAGONAL vech entries only; off-diagonals cold-start at 0 (unit diagonal, the lme4/MixedModels.jl default — theblind_theta_and_boundsshape). Cold start per fit; no warm-start across sims (would re-import cross-grid-point path dependence).
Functions§
- fit_
cold - Cold single fit — the default real-data entry. Random-effect
level ids are supplied per-row via
ids(GroupIds); every level count is derived from them, soModelSpecstays structure-only. Exactlyfit_warm(.., None, ..). - fit_
warm - Warm single fit — identical to
fit_coldbut accepts an optionalStartValueswarm start.Somewarm-starts the optimizer;Nonecold-starts (byte-identical tofit_cold). One fit, one answer — the start only shortens the path. The start threadsbeta+thetainto the LMM/GLMM kernels; fixed-only (OLS/GLM) and the NB global-θ search ignore it (seecrate::StartValues).
Type Aliases§
- Column
Id - Predictor column index — indexes into the
p-wide design matrixx.