I am trying to understand how lme4's mixed modeling works, specifically its random effects design matrix "Z". I have the following R code:
library(lme4)
A = as.factor(c(1,1,1,1,2,2,2,2))
B = as.factor(c(1,1,2,2,1,1,2,2))
R = c(1,2,3,4,6,7,9,11) + runif(8)
remdl = lmer(R ~ (1|A/B) + (1|B))
summary(remdl)
getME(remdl, "Z")
In this mixed effect model, I believe that I am telling lmer() to treat Predictor B as both nested within A and crossed with A. When I run this code, lmer() throws a "singular fit" error, but it does fit the model.
My question is: How is this possible? How can the random effect predictor B be treated as both nested and crossed with A?