[R-sig-ME] visualising interaction with predict.merMod

Richard Zijdeman richard.zijdeman at gmail.com
Thu Jul 10 12:46:06 CEST 2014


Dear all,

I’ve fitted a model with the lme4 (version 1.1.7) package, using the glmer command. The only random component in the model is the intercept. The model contains an interaction with time and a dichotomous variable and I would like to visualise this interaction (the model actually contains more interactions and variables, but I don’t think this matters):

model1 <- glmer(dep.var ~ var1 + var2 + … + time + var1_time + (1 | reff), data = data, family = binomial("logit”)) # where var1_time is the interaction

To visualise the interaction, I think I would need to predict new values from the model. To do so, I have used the actual data, but I don’t think that’s right:

pred.values <- predict(model1, type = "response")

I think I should create a new dataset, in which all variables are held at constant value (e.g. the mean), except for, in this case the main effects of the interaction and the interaction.

My questions are: 
- could someone please comment on my reflection (do I indeed need to create a new dataset)?
- If I indeed would need to create such a new dataset, with average values, how would I do that (my model actually contains a lot of variables)?

Thanks in advance,

Richard


More information about the R-sig-mixed-models mailing list