'lmer error couldn't evaluate grouping factor

I am trying to fit a rather simple, linear nested model (teachers within schools) with about 700,000 datapoints (300,000 unique teacher ids; 60,000 school ids) as follows:

formula=outcome ~ Gender + covar1 + (1|schoolid/teacherid) 
fit=lmer(formula, data=myData)

I get the following error:

Error: couldn't evaluate grouping factor teacherid:schoolid within model frame: try adding grouping factor to data frame explicitly if possible.

I am not sure what this means and how to correct this.

The following non-nested model however works perfectly fine:

formula=outcome ~ Gender + covar1 + (1|schoolid) +(1|teacherid) 
fit=lmer(formula, data=myData)

Please help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source