Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

MMAMixedEffects

Guides

  • MMAMixedEffects

Symbols

  • GeneralizedMixedEffectsModelFit
  • MixedEffectsFamily
  • MixedEffectsModelFit
  • MixedEffectsModel
  • NestedGrouping
  • NonlinearMixedEffectsModelFit
New in:
1.0
| Modified in:
1.2.4
| Obsolete in:
Categorization

Keywords

Syntax Templates

GeneralizedMixedEffectsModelFit
GeneralizedMixedEffectsModelFit[data,fixed,{random,group},vars]

​fits a generalized mixed model.​
​
GeneralizedMixedEffectsModelFit[...,ExponentialFamily->family]

​specifies the response family.​
​
GeneralizedMixedEffectsModelFit[...,LikelihoodApproximation->"AdaptiveGaussHermite"]

​uses adaptive Gauss-Hermite quadrature.
fits generalized linear mixed-effects models.
The conditional model is g(mu_i) = x_i beta + z_i b + offset_i, with Gaussian random effects.
Core families are Gaussian, Binomial, Poisson, Gamma, and InverseGaussian.
MixedEffectsFamily additionally supplies NegativeBinomial1, NegativeBinomial2, NegativeBinomial12, Beta, BetaBinomial, LogNormal, StudentT, zero-inflated, and hurdle specifications.
Response support, normalized log density, variance, derivatives, simulation metadata, and link functions are owned by each family definition.
Trials supplies integer binomial or beta-binomial totals. Binomial modeled means and residuals are reported on the proportion scale.
Offsets are added on the link/linear-predictor scale; exposure models normally use Log[exposure].
Generalized observation weights multiply log-likelihood contributions and are reported as frequency weights.
Laplace uses the full conditional Hessian at the random-effect mode. AdaptiveGaussHermite recenters and rescales nodes and factors independent components.
MaxQuadraturePoints prevents an unexpectedly large tensor grid; the requested approximation is never silently replaced.
For crossed designs, one connected random-effects component can contain many latent coefficients. AdaptiveGaussHermite then requires QuadratureOrder raised to that component dimension, so Laplace is normally the practical choice and MaxQuadraturePoints fails explicitly before an infeasible grid is built.
PopulationPredictedResponse sets random effects to zero; ConditionalPredictedResponse uses conditional modes; MarginalPredictedResponse integrates response-scale means over random effects.
FixedEffectCovariance is derived from the integrated marginal objective when a stable marginal Hessian is available.
Dispersion, zero-inflation, and hurdle parameters are reported in FamilyParameters with their parameterization metadata.
With OptimizationMethod->Automatic, generalized fits use a faster quasi-Newton search and fall back to deterministic Nelder-Mead if the scaled-gradient convergence audit is not satisfied.
ProgressReporting->Automatic displays a live progress panel in notebooks and stays silent in script kernels.
The following options can be given:
ExponentialFamily
Automatic
A built-in family name or validated MixedEffectsFamily Association.
LinkFunction
Automatic
Use the family default or a supported explicit link.
Trials
Automatic
Binomial/beta-binomial trial counts as a scalar, vector, function, or expression.
DispersionParameter
Automatic
Positive family dispersion/size/precision parameter, estimated when the family declares it estimable.
LikelihoodApproximation
"Laplace"
Use "Laplace" or "AdaptiveGaussHermite".
QuadratureOrder
7
Gauss-Hermite nodes per independent active component.
MaxQuadraturePoints
200000
Hard limit on the total requested adaptive quadrature grid.
InnerMaxIterations
100
Maximum conditional-mode iterations.
DegreesOfFreedomMethod
"Normal"
Generalized fixed effects use marginal-objective Wald inference.
Weights
Automatic
Observation weights. Gaussian fitters interpret these as inverse residual-variance weights; generalized fitters report their frequency-weight interpretation.
LinearOffsetFunction
None
A scalar, vector, function, or Wolfram expression added to the linear predictor.
MissingDataMethod
"Exclude"
Use "Exclude" for recorded listwise deletion or "Fail" to reject missing input.
MaxIterations
600
Maximum outer optimizer iterations.
AccuracyGoal
Automatic
Accuracy goal passed to the selected numerical optimizer.
PrecisionGoal
Automatic
Precision goal passed to the selected numerical optimizer.
WorkingPrecision
MachinePrecision
Working precision used by numerical optimization.
OptimizationMethod
Automatic
Automatic begins with quasi-Newton optimization and uses a deterministic Nelder-Mead fallback when the strict convergence audit is not met; an explicit method disables this selection.
OptimizationStarts
3
Number of deterministic starts; the fit with the smallest valid objective is retained.
ConvergenceTolerance
1
5
10
Tolerance for the scaled projected-gradient convergence gate.
ConfidenceLevel
0.95
Confidence level used for reported fixed-effect intervals.
ProgressReporting
Automatic
Show a live notebook progress panel with the current stage, objective evaluations, best objective, start number, and elapsed time. Automatic is silent without a notebook front end.
EvaluationMonitor
None
An expression evaluated after each uncached marginal-objective evaluation; use RuleDelayed for side effects.
StepMonitor
None
An expression evaluated after each completed outer optimization start; use RuleDelayed for side effects.
The fitted object supports the following property groups:
Data and design
"Data"
Rows used for fitting after missing-data processing.
"Variables"
Ordered predictor and grouping variables.
"IncludedRowIndices"
Original row indices retained for fitting.
"ExcludedRowIndices"
Original row indices excluded from fitting.
"FixedEffectsDesignMatrix"
Fixed-effect design matrix.
"RandomEffectsDesignMatrix"
Sparse random-effect design matrix.
Fixed effects
"FixedEffects"
Association of fixed-effect estimates.
"ParameterTableEntries"
Machine-readable parameter inference entries.
"FixedEffectCovariance"
Estimated covariance matrix of fixed effects.
"FixedEffectCorrelationMatrix"
Corresponding correlation matrix.
Random and residual effects
"RandomEffects"
Conditional modes grouped by random-effect structure.
"RandomEffectCovariances"
Association of estimated covariance matrices.
"ResidualVariance"
Gaussian residual variance, when applicable.
"ResidualParameterEstimates"
Estimated residual correlation and variance-function parameters.
Predictions and residuals
"PopulationPredictedResponse"
Training predictions with random effects set to zero.
"ConditionalPredictedResponse"
Training predictions using conditional random effects.
"MarginalPredictedResponse"
Response-scale predictions integrated over random effects.
"Residuals"
Conditional response residuals.
"PearsonResiduals"
Variance-standardized residuals.
"DevianceResiduals"
Signed deviance residuals when defined.
Likelihood and diagnostics
"LogLikelihood"
Constants-inclusive maximized or approximated log likelihood.
"AIC"
Akaike information criterion.
"BIC"
Bayesian information criterion.
"ConvergenceReport"
Gradient, error, optimizer, mode, and tolerance diagnostics.
"Converged"
True only when documented numerical gates pass.
"SingularFit"
Whether a random-effect covariance lies on a rank boundary.
"Warnings"
Statistical and numerical warnings retained with the fit.
See Also
MixedEffectsModelFit
▪
NonlinearMixedEffectsModelFit
▪
MixedEffectsFamily
▪
MixedEffectsModel
Related Guides
MMA MixedEffects
Related Links
ZeroInflatedFamily
▪
HurdleFamily
Examples Initialization
Needs["MarcoThiel`MMAMixedEffects`"];root=PacletObject["MarcoThiel/MMAMixedEffects"]["Location"];raw=Rest[Import[FileNameJoin[{root,"Validation","Data","cbpp.csv"}],"CSV"]];cbppData=({Boole[#1〚1〛"2"],Boole[#1〚1〛"3"],Boole[#1〚1〛"4"],#1〚2〛,#1〚4〛,#1〚3〛}&)/@raw;
Examples
MoreExamples⊳
Fit grouped binomial counts using adaptive Gauss-Hermite quadrature:
cbppFit=GeneralizedMixedEffectsModelFit[cbppData,{1,p2,p3,p4},{{1},herd},{p2,p3,p4,herd,size},ExponentialFamily"Binomial",Trialssize,LikelihoodApproximation"AdaptiveGaussHermite",QuadratureOrder9]
MixedEffectsModel[GeneralizedLinearMixedModel, AdaptiveGaussHermite]
​
Laplace and nine-point adaptive quadrature agree closely on the cbpp estimates:
cbppFit[{"FixedEffects","RandomEffectCovariances","LogLikelihood"}]
quantity
Laplace
AGHQ(9)
period 1 intercept
-1.39853
-1.39923
period 2 contrast
-0.992333
-0.991404
herd variance
0.412498
0.419279
log likelihood
-92.0263
-91.9834
​
Plot response-scale conditional probabilities:
ListPlot
T
{binomialData〚All,1〛,binomialFit["ConditionalPredictedResponse"]}

More Examples
Scope
Fit grouped binomial counts:
​
Fit Poisson rates with exposure:
​
Fit Gamma responses with a log link:
​
Fit inverse-Gaussian responses:
​
Fit an NB2 count model:
​
Fit zero-inflated counts:
​
Fit hurdle counts:
Use adaptive quadrature:
​
Combine crossed grouping factors:
Inspect a quadrature budget failure explicitly:
​
Exclude unsupported response rows and retain their indices:
​
Collect one value per objective evaluation:
Compare conditional and marginal probabilities for clustered patients:
​
Verify lme4's grouped-binomial cbpp probability/weight encoding against the trials encoding:
​
Add an observation-level random effect to absorb cbpp overdispersion:
​
Reproduce a release-sized fixture from the GLMMadaptive longitudinal logistic quadrature example:
​
Reproduce a release-sized fixture from the GLMMadaptive longitudinal Poisson example:
​
Fit the glmmTMB Salamanders habitat model with estimated NB2 dispersion:
​
Contrast the NB2 result with the official Salamanders Poisson model:
Verify the family parameterization:
Inspect separation, boundary variance, or a relaxed conditional-mode result:
​
Avoid an infeasible adaptive-quadrature tensor for a connected crossed design:
​
Distinguish fixed zero inflation from a fitted zero-part model:
Animate conditional and population event probabilities across groups:

© 2026 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com