Linear mixed-effects model (random intercept)
Shown in the app as mixed_model. Part of the method reference, under Mixed-effects models.
When to use
Continuous outcome with repeated or clustered measurements (multiple rows per subject or site): fixed-effect predictors plus a per-cluster random intercept.
What you provide
- Outcome: one numeric column.
- Predictors: one or more columns.
- Cluster (subject or site): one column identifying the cluster.
You can also add a random slope: one numeric predictor whose effect is allowed to differ between clusters.
Options
Missing data
- Complete case (listwise deletion)
Multiple comparisons
- Not adjustable for this method. Where it makes post-hoc comparisons, the procedure applies its own correction.
Confidence level
Every interval in the result is reported at the level you choose:
- 90%
- 95%
- 99%
Related methods
Other methods under Mixed-effects models:
- Mixed-effects logistic regression (random intercept)
- Mixed-effects Poisson regression (random intercept)
Guides that discuss this method
How to read the output
A linear mixed-effects model analyses a numeric outcome measured repeatedly, or in groups: several visits per patient, several pupils per school, several plates per batch. Each cluster (the patient, school or batch) gets its own baseline through a random intercept, and you can also let one numeric predictor that changes within clusters, such as time, have its own slope in each cluster. Only rows with a value for the outcome, every predictor and the cluster are used, and the number of rows and clusters analysed is reported.
The headline test. The model is fitted by restricted maximum likelihood (REML). The first predictor is tested with an F-test whose denominator degrees of freedom come from the Kenward-Roger approximation, which is the usual small-sample choice and reproduces the paired t-test exactly in a simple balanced design. When the first predictor is a factor with three or more levels, the test covers all its levels together and there is no single estimate; the pairwise comparisons show which levels differ. Above 20,000 rows, where Kenward-Roger becomes slow, the Satterthwaite approximation is used instead and the results say so; at that size the two agree closely.
Coefficients and confidence intervals. The table of coefficients lists each fixed effect with its standard error, degrees of freedom, t statistic, p-value and confidence interval. The interval uses the same degrees of freedom as the test beside it, so a p-value and its interval never come from different reference distributions. You can choose a 90%, 95% or 99% confidence level, and every interval in the result uses it.
Intraclass correlation and variance components. For a model with a random intercept only, the intraclass correlation (ICC) is the share of the variation that lies between clusters rather than within them, reported with a profile-likelihood confidence interval. With a random slope the between-cluster share depends on the value of the slope variable, so no single ICC is reported. The variance components table gives the between-cluster standard deviations, their correlation and the residual standard deviation; for a random-intercept model of moderate size each comes with a profile-likelihood interval.
Checks and limits. Celeus checks the normality of the residuals and of the estimated cluster effects (Shapiro-Wilk), names which variance component is at zero when the fit is singular, and refuses a random slope on a predictor that never changes within a cluster. With fewer than five clusters it notes that the between-cluster variance rests on very few clusters; five is a rule of thumb, and if the clusters are the whole population of interest a fixed effect for the cluster may serve better. Missing values are handled by complete-case analysis only. For the mixed-effects logistic and Poisson models, every number is reproduced by the downloadable R script, with one stated limit: a generalized mixed model’s Wald standard errors come from a finite-difference Hessian; re-running the script in a different R session can change them in the fifth significant digit (the estimate in the ninth).
Sources: Laird NM, Ware JH (1982), Biometrics 38(4):963-974, doi:10.2307/2529876. Kenward MG, Roger JH (1997), Biometrics 53(3):983-997, doi:10.2307/2533558. Bates D, Machler M, Bolker B, Walker S (2015), Journal of Statistical Software 67(1):1-48, doi:10.18637/jss.v067.i01. Kuznetsova A, Brockhoff PB, Christensen RHB (2017), Journal of Statistical Software 82(13):1-26, doi:10.18637/jss.v082.i13.
Worked examples
Celeus's result on a published or illustrative dataset, next to an independent computation and, where one exists, a published value. The data themselves are not reproduced here.
lme4::sleepstudy
- Source: Published dataset distributed with an R package
- Licence: lme4 (GPL)
- Reference: Belenky et al. (2003), J. Sleep Research 12
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Estimate | 10.4673 | 10.4673 | 10.47 | Yes |
| Confidence interval | 7.20595, 13.72860 | 7.20595, 13.72860 | - | Yes |
| Standard deviation (or correlation) of each random effect | 24.7407000, 5.9221400, 0.0655512, 25.5918000 | 24.7407000, 5.9221400, 0.0655512, 25.5918000 | - | Yes |
| Number of observations | 180 | 180 | - | Yes |
| Test statistic | 45.853 | 45.853 | - | Yes |
| p-value | 3.26381e-06 | 3.26381e-06 | - | Yes |
| Denominator degrees of freedom for the first predictor | 17 | 17 | - | Yes |
lme4::sleepstudy
- Source: Published dataset distributed with an R package
- Licence: lme4 (GPL)
- Reference: Belenky et al. (2003), J. Sleep Research 12; the ICC and its profile interval are an independent computation (a dense-matrix REML written out in base R)
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 169.401 | 169.401 | - | Yes |
| p-value | 6.4126e-27 | 6.4126e-27 | - | Yes |
| Denominator degrees of freedom for the first predictor | 161 | 161 | - | Yes |
| Confidence interval | 8.8791, 12.0555 | 8.8791, 12.0555 | - | Yes |
| Effect size | 0.589309 | 0.589309 | - | Yes |
| Effect size confidence interval | 0.412846, 0.765358 | 0.412846, 0.765358 | - | Yes |
MASS::shoes
- Source: Published dataset distributed with an R package
- Licence: MASS (GPL)
- Reference: Box, Hunter & Hunter (1978); the pbkrtest 0.5.5 installed vignette 'a01-pbkrtest' (Halekoh & Hojsgaard) prints the Kenward-Roger F, its df and p for this design
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 11.215 | 11.215 | 11.215 | Yes |
| p-value | 0.00853878 | 0.00853878 | 0.008539 | Yes |
| Confidence interval | 0.133046, 0.686954 | 0.133046, 0.686954 | - | Yes |
MASS::shoes
- Source: Published dataset distributed with an R package
- Licence: MASS (GPL)
- Reference: Box, Hunter & Hunter (1978); the pbkrtest 0.5.5 installed vignette 'a01-pbkrtest' deletes rows 1 and 12 and prints the Kenward-Roger F, its fractional df and p
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 5.98932 | 5.98932 | 5.9893 | Yes |
| p-value | 0.0441764 | 0.0441764 | 0.04418 | Yes |
| Denominator degrees of freedom for the first predictor | 7.0219 | 7.0219 | 7.0219 | Yes |
nlme::ergoStool
- Source: Published dataset distributed with an R package
- Licence: nlme (GPL)
- Reference: Pinheiro & Bates (2000), Mixed-Effects Models in S and S-PLUS, Section 1.2: F = 22.36 on 3 and 24 df for Type, as printed by the nlme package's own run of that section's code; p and the post-hoc labels are independent computations
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 22.3556 | 22.3556 | 22.36 | Yes |
| p-value | 3.93456e-07 | 3.93456e-07 | - | Yes |
| Degrees of freedom | 3,24 | 3,24 | - | Yes |
| First group of each pairwise comparison | T1, T1, T1, T2, T2, T3 | T1, T1, T1, T2, T2, T3 | - | Yes |
| Second group of each pairwise comparison | T2, T3, T4, T3, T4, T4 | T2, T3, T4, T3, T4, T4 | - | Yes |
nlme::Orthodont
- Source: Published dataset distributed with an R package
- Licence: nlme (GPL)
- Reference: Potthoff & Roy (1964), Biometrika 51; the F, p, interval and variance components are an independent computation (nlme::lme, REML, a different fitting engine)
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 9.2921 | 9.2921 | - | Yes |
| p-value | 0.00537506 | 0.00537506 | - | Yes |
| Confidence interval | 1.02042, 3.62163 | 1.02042, 3.62163 | - | Yes |
| Variance of each random effect | 3.26678, 2.04946 | 3.26678, 2.04946 | - | Yes |
| Whether each predictor varies between or within clusters | between, within | between, within | - | Yes |
datasets::ChickWeight
- Source: Published dataset distributed with an R package
- Licence: base R (GPL)
- Reference: Crowder & Hand (1990), Analysis of Repeated Measures, Example 5.3; the reference is pbkrtest called directly, the package the engine calls (a wiring check)
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 6.27384 | 6.27384 | - | Yes |
| p-value | 0.00117822 | 0.00117822 | - | Yes |
| Denominator degrees of freedom for the first predictor | 45.5218 | 45.5218 | - | Yes |
| Smallest number of rows in a cluster | 2 | 2 | - | Yes |
| Largest number of rows in a cluster | 12 | 12 | - | Yes |
| First group of each pairwise comparison | D1, D1, D1, D2, D2, D3 | D1, D1, D1, D2, D2, D3 | - | Yes |
| Second group of each pairwise comparison | D2, D3, D4, D3, D4, D4 | D2, D3, D4, D3, D4, D4 | - | Yes |
lme4::sleepstudy
- Source: Published dataset distributed with an R package
- Licence: lme4 (GPL)
- Reference: Belenky et al. (2003), J. Sleep Research 12; subject 308's Reaction and rows 25-26 set missing here (12 rows); the reference is the complete-case refit by the same packages the engine calls (a wiring check of the missing-data path)
| Quantity | Celeus | Independent computation | Published value | Agrees |
|---|---|---|---|---|
| Test statistic | 161.918 | 161.918 | - | Yes |
| p-value | 1.27852e-25 | 1.27852e-25 | - | Yes |
| Denominator degrees of freedom for the first predictor | 150 | 150 | - | Yes |
| Number of observations | 168 | 168 | - | Yes |
References
- Laird, N. M., Ware, J. H. (1982). Random-effects models for longitudinal data. Biometrics 38: 963-974. doi:10.2307/2529876 doi:10.2307/2529876
- Bates, D., Machler, M., Bolker, B., Walker, S. (2015). Fitting linear mixed-effects models using lme4. Journal of Statistical Software 67: 1-48. doi:10.18637/jss.v067.i01 doi:10.18637/jss.v067.i01