Plotting a glm binomial model is reasonably simple with the predict function. I'm having trouble creating a similar plot for a glmer model; predict doesn't work:
id <- factor(rep(1:20, 3)) age <- rep(sample(20:50, 20, replace=T), 3) age <- age + c(rep(0, 20), rep(3, 20), rep(6, 20)) score <- rbinom(60, 15, 1-age/max(age)) dfx <- data.frame(id, age, score) library(lme4) glmerb <- glmer(cbind(score, 15-score) ~ age + (1|id), dfx, family=binomial) ndf <- expand.grid(age=10:60) #for extensibility, usually also have factors ndf$fit <- predict(glmerb, ndf, type="response") *Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "mer"*
- How can I produce the desired plot?
- While I'm at it, what other plots would be useful for this kind of model for either diagnostic, presentation or glam purposes?