jknowles / merTools

Convenience functions for working with merMod objects from lme4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

predictInterval: crossed effects error

miked58 opened this issue · comments

I have a model of the form y ~ (x1 + x2 | group1) + (x3 | group2) + regressors, and I'm getting the following error:

Error in FUN(X[[i]], ...) :
random effects specified in re.form that were not present in original model

Traceback shows the snag is hit here:
4: lapply(seq_along(nRnms), function(i) {
rname <- nRnms[i]
if (!all(Rcnms[[i]] %in% names(re[[rname]])))
stop("random effects specified in re.form that were not present in original model")
re_x[[rname]][, Rcnms[[i]]]
})
3: mkNewReTrms(object = model, newdata = newdata, re.form, na.action = "na.pass",
allow.new.levels = TRUE)
2: buildModelMatrix(model = merMod, newdata = newdata)
1: predictInterval(mm2, holdout)

If I remove the x3 random effect and leave the intercept for group2, I'm able to get predictions. Are crossed effects supported and this is a bug, or is the functionality not yet available?

This should work. Can you put together a reprex so I can investigate this further and see what might be going on?

Closing this due to lack of a reprex. Feel free to reopen if you can reproduce this.