(gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |herd), cbpp, binomial))
str(p0 <- predict(gm1)) # fitted values
str(p1 <- predict(gm1,ReForm=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,ReForm=NA)) # new data, level-0
str(p4 <- predict(gm1,newdata,ReForm=~(1|herd))) # explicitly specify RE
Run the code above in your browser using DataLab