I have some experience with lme4, but today I tried lmerTest for the first time and was surprised by some results when using the rand() function to examine the random components. (I know this is not advised by the authors of lme4!) In troubleshooting, I think I discovered some undesired behavior: when rand() sees a random effect term whose variable name contains a dot, it appears to parse the term into multiple variables. Of course these may or may not exist in the dataset, but unfortunately it doesn't throw an error, it just gives weird results.
Here's a MWE:
library(dplyr)
nsub <- 500
nvis <- 6
data <- data.frame(subjid = factor(sort(rep(c(1:nsub),nvis))),
visit = rep(c(1:nvis),nsub))
base <- filter(data, visit==1) %>%
select(subjid) %>%
mutate(baseage=rnorm(nsub, 40, 10)) %>%
merge(data, by="subjid") %>%
mutate(interval = ifelse(visit==1, 0, 2*(visit-1) + runif(nsub*nvis, 0, 1)),
age = baseage + interval,
ageverylong = age,
age.very.long = age,
y = 100 - 0.1*age + rnorm(nsub*nvis))
mod1 <- lmer(y ~ (age | subjid), data=base)
mod2 <- lmer(y ~ (ageverylong | subjid), data=base)
mod3 <- lmer(y ~ (age.very.long | subjid), data=base)
summary(mod1) # These three give the same results (so it's not an lme4 problem)
summary(mod2)
summary(mod3)
rand(mod1) # The top two are the same
rand(mod2)
rand(mod3) # But this one is different