I'm trying to understand why I get a singular fit when a linear mixed-effect model is fitted to the data below.
I used R lme4::lmer
and the model is very simple having only the intercept as fixed effect and a factor variable as random.
Here's the dataset (can be copy & pasted to R)
data <- read.table(text= "
group_id y
1 6.38
1 10.83
1 13.25
1 2.96
1 11.29
1 11.52
1 8.28
1 8.36
1 8.31
1 7.33
2 8.57
2 7.00
2 7.67
2 10.19
2 12.88
2 9.67
2 8.47
2 7.27
2 7.49
2 17.25
3 10.40
3 8.53
3 8.68
3 11.38
3 7.92
3 5.66
3 11.72
3 6.93
3 9.95
3 7.19
4 13.31
4 8.57
4 7.87
4 8.50
4 5.11
4 6.50
4 3.46
4 5.98
4 9.12
4 8.60
5 14.35
5 6.79
5 7.43
5 9.16
5 7.02
5 7.09
5 6.68
5 6.24
5 8.43
5 8.51",
header= TRUE, colClasses= c('factor', 'numeric'))
This is the fitted model:
library(lme4)
fit <- lmer(data= data, y ~ 1 + (1|group_id))
boundary (singular) fit: see ?isSingular <<<<<<
summary(fit)
Linear mixed model fit by REML ['lmerMod']
Formula: y ~ 1 + (1 | group_id)
Data: data
REML criterion at convergence: 239
Scaled residuals:
Min 1Q Median 3Q Max
-2.139 -0.604 -0.093 0.467 3.242
Random effects:
Groups Name Variance Std.Dev.
group_id (Intercept) 0.00 0.00
Residual 7.05 2.66
Number of obs: 50, groups: group_id, 5
Fixed effects:
Estimate Std. Error t value
(Intercept) 8.641 0.376 23
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see ?isSingular
Help for isSingular
says that some "dimensions" of the variance-covariance matrix have been estimated as exactly zero and I'd like to see in the data why this is happening.