I'm having a difficult time diagnosing the reasons for singular fits in a business problem I'm working on.
The lme4::isSingular
documentation recommends lme4::rePCA
as a function to help diagnose singular fits. I can successfully run the function on my models, but I don't know how to interpret the results.
I created a reproducible example and included below. Some specific questions:
- What is the meaning of Subject standard deviations? How do I know what components 1, 2, 3 of this vector correspond to in the model?
#> $Subject
#> Standard deviations (1, .., p=3):
#> [1] 9.8639459 0.2313664 0.0000000
- What do the dimensions n, k correspond to in the PCA. Perhaps one of n, k corresponds to model terms and the other to principal components?
#> Rotation (n x k) = (3 x 3):
#> [,1] [,2] [,3]
#> [1,] 1 0 0
#> [2,] 0 0 -1
#> [3,] 0 -1 0
- How do I interpret those PCA rotation results to understand why this model is singular?
- Are there any tools I can use for diagnosing singular
lmer
andglmer
models?
Many thanks!
library(Matrix)
library(lme4)
model <- lmer(Reaction ~ 0 + Days + (1 | Subject) + (Days | Subject), data = sleepstudy)
#> boundary (singular) fit: see ?isSingular
print(model)
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Reaction ~ 0 + Days + (1 | Subject) + (Days | Subject)
#> Data: sleepstudy
#> REML criterion at convergence: 1828.653
#> Random effects:
#> Groups Name Std.Dev. Corr
#> Subject (Intercept) 252.446
#> Subject.1 (Intercept) 0.000
#> Days 5.921 NaN
#> Residual 25.593
#> Number of obs: 180, groups: Subject, 18
#> Fixed Effects:
#> Days
#> 10.61
#> optimizer (nloptwrap) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings
print(isSingular(model))
#> [1] TRUE
print(rePCA(model))
#> $Subject
#> Standard deviations (1, .., p=3):
#> [1] 9.8639459 0.2313664 0.0000000
#>
#> Rotation (n x k) = (3 x 3):
#> [,1] [,2] [,3]
#> [1,] 1 0 0
#> [2,] 0 0 -1
#> [3,] 0 -1 0
#>
#> attr(,"class")
#> [1] "prcomplist"
Created on 2022-04-22 by the reprex package (v2.0.1)