How this calculation works
A random-intercept model allows observations within the same group to share an unobserved offset. This calculator profiles a Gaussian likelihood over a bounded random-to-residual variance ratio, estimates fixed effects and returns conditional group intercepts. ML and REML are kept as explicit options because they estimate variance differently.
y=X beta+Zb+epsilon; b~N(0,tau²I), epsilon~N(0,sigma²I).A worked example
Three groups contain responses (1,2),(4,5),(7,8), with an intercept-only fixed design. Their means are 1.5,4.5,7.5 and the overall mean is 4.5. The balanced REML estimates are residual variance 0.5 and random-intercept variance 8.75. Group offsets are shrunk toward zero.
Good to know
Random intercept only, 3–20 groups and at least two observations per group. Fixed design must be full rank and include any desired intercept. Boundary estimates are labeled. No random slopes, non-Gaussian response, coefficient p-values or global multimodal-likelihood guarantee.
Reference: Statsmodels Gaussian mixed linear model (opens in a new tab) ↗
Grouping creates a covariance model
Observations with the same group label share one Gaussian random intercept. Their residual errors remain separate under the model. Numeric labels identify groups rather than an ordered predictor, so relabeling the groups without changing membership should not change fitted fixed effects or variance estimates.
The fixed design can include slopes and an explicit intercept column. Its columns must remain linearly independent after accounting for the weighted covariance solve. There must also be at least three groups with repeated observations, providing within-group information distinct from the between-group variation used to estimate random-intercept spread.
The GLM regression calculator from response and design matrix covers the nearby task. GLM assumes independent observations and has no estimated group random-effect variance.
ML and REML have different variance objectives
For each candidate variance ratio, generalized least squares estimates the fixed coefficients and profiles out residual variance. Restricted maximum likelihood additionally accounts for the fixed-effect design in its objective. The same data can therefore produce different ML and REML variance estimates without either numerical calculation being inconsistent.
The ratio search is bounded and refined around a sampled minimum. Reaching the search boundary is rejected instead of described as a well-resolved variance estimate. A zero random variance is retained as an explicit boundary solution when it has the better profile objective, rather than forcing a positive component.
Conditional offsets express partial pooling
Conditional group intercepts balance each group’s residual mean against the estimated population variance. Small or noisy groups are pulled more strongly toward zero. These are shrunken predictions of group deviations, not separately fitted unrestricted fixed intercepts and not known values of an observable group-level treatment effect.
Balanced data allow hand-checkable variance decompositions, while general tests compare profile likelihood and fitted variance ratios against an independent mixed-model implementation. No random slopes, non-Gaussian likelihood, likelihood-ratio significance test or coefficient interval is supplied. Model assumptions about group independence and Gaussian variation still require scientific justification outside the numerical fit.
Start from the random-intercept covariance model
Write yij=xijβ+bj+εij, where bj has variance τ² and independent within-group errors have variance σ². Two observations in the same group share covariance τ²; observations in different groups share none under this model. The marginal covariance matrix is therefore σ²I+τ²ZZᵀ, with Z marking group membership.
Conditional on a variance ratio, generalized least squares estimates the fixed coefficients. The implementation profiles the likelihood over that ratio and also evaluates the zero-random-variance boundary. This is a random-intercept model only: within-group correlation is the same for every pair, rather than declining with time separation or changing with a random slope.
See shrinkage in the three-group example
The default groups have responses (1,2),(4,5),(7,8), with grand mean 4.5 and group deviations −3,0,3. For the balanced intercept-only REML fit, σ²=0.5 and τ²=8.75. The group-effect multiplier is mτ²/(σ²+mτ²)=17.5/18=35/36 for m=2.
The predicted random intercepts are consequently about −2.916667,0,2.916667, rather than the unshrunk deviations −3,0,3. They move toward zero because the model balances between-group differences against uncertainty in each group mean. Smaller groups or larger residual noise generally receive more shrinkage. These predictions are conditional group effects, not three additional unrestricted fixed intercepts.
Decide what ML and REML comparisons mean
Maximum likelihood estimates variance while treating estimated fixed coefficients through the full likelihood. Restricted maximum likelihood adjusts for the fixed-effect estimation and can give different variance estimates, especially in small samples. The selector changes the fitting objective, so record it alongside the fixed design and the group labels.
REML criteria from models with different fixed-effect designs are not directly comparable for choosing those fixed effects. Use an appropriate model-comparison procedure outside this page. The profiled objective displayed here is not a complete inferential report with likelihood-ratio calibration or information-criterion model selection. In particular, testing a zero variance component has boundary complications that a conventional coefficient t test does not address.
Interpret boundary estimates and group structure
An estimate τ²=0 says the fitted likelihood preferred no additional group-intercept variance in this model and sample. It does not prove that all groups are scientifically identical. With only three groups, variance estimation can remain highly uncertain even though the numerical solve completes. This page requires at least three groups but does not claim that this is a generally sufficient sample size.
Use numeric group identifiers only as labels; do not place those arbitrary identifiers in the fixed design as a continuous predictor. Include real explanatory variables explicitly. Repeated observations with serial correlation, unequal residual variances, crossed grouping or changing group slopes require richer covariance structures than this form supports. The calculator reports no coefficient p-values or confidence intervals for those unmodeled effects.
A few questions, answered
Why do ML and REML variances differ?
REML accounts for fixed-effect estimation in its variance objective, while ML uses the full likelihood.
Are group offsets fitted independently?
No. They are conditional shrunken estimates tied to a shared random-intercept variance.
Are random intercepts the raw group-mean differences?
Usually not. They are shrunken conditional predictions. The amount of shrinkage depends on group size and the fitted random and residual variances.
Does a boundary estimate mean the fit failed?
Not necessarily. A zero random-intercept variance is a valid boundary solution and is labeled. It should be interpreted with sampling uncertainty and the grouping design in mind.