Predict error with nested random effect structure


#1

Hi,

I am having issues using the predict.brmsfit function when I have new random effect levels. I have a nested random effect structure of (1|Region/Species). From the R documentation, I have tried setting allow_new_levels=TRUE as well as re_formula=NA however, in both cases I get the following error:
Error: New factor levels are not allowed. followed by a list of all of contained species incorporated in the analysis.

I have tried to troubleshoot this and I have found if I remove the nestedness and re-fit the model with only (1|Species) setting either allow_new_levels = TRUE or re_formula=NA results in a normal predict output.

Is there something else I need to specify in order for this to work with my nested structure?

Thanks in advance - Liam

Please also provide the following information in addition to your question:

  • Operating System: Mac OS High Sierra
  • brms Version: 2.31

#2

Strange, I would expect allow_new_levels = TRUE. Let me see if I can reproduce this problem.


#3

Thanks, if not I will make a reproducible example and post it on here


#4

If it is not too much work, I would prefer a reprex from you, of course. :-)


#5

no problem, i’m on it


#6

Here you go - i fitted the model with only a subset and then tried to use predict using the entire data frame

df.csv (2.1 KB)

forum_example.R (205 Bytes)


#7

Thanks! It should be fixed now in the dev version of brms. You can install it via

if (!requireNamespace("devtools")) {
  install.packages("devtools")
}
devtools::install_github("paul-buerkner/brms")

#8

fantastic, thank you! it works perfectly