# NOT RUN { (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |herd), cbpp, binomial)) str(p0 <- predict(gm1)) # fitted values str(p1 <- predict(gm1,re.form=NA)) # fitted values, unconditional (level-0) newdata <- with(cbpp, expand.grid(period=unique(period), herd=unique(herd))) str(p2 <- predict(gm1,newdata)) # new data, all RE str(p3 <- predict(gm1,newdata,re.form=NA)) # new data, level-0 str(p4 <- predict(gm1,newdata,re.form= ~(1|herd))) # explicitly specify RE stopifnot(identical(p2, p4)) # } # NOT RUN { <!-- %dont --> # }
Run the code above in your browser using DataCamp Workspace