[R-sig-ME] Graphing lme results using marginal group means

Igor Yakovenko iyakoven at ucalgary.ca
Mon Mar 21 04:44:16 CET 2016

Hello Everyone,


I've run a number of mixed models using data from a two-group RCT evaluating
an intervention over 3 time points  and am currently trying to figure out
the best way to graphically present the results to a lay audience. I thought
the simplest and most digestible way would be to graph the marginal group
means (i.e., means controlling for other predictors in the model) at each
time point using line graphs, but I can't figure out how to do this in R.
Does anyone know how to graph the results of a model such as the one below
where X = time points (baseline, 3 months, 6 months), Y = marginal means
with two lines, one for each of the two groups? Different colors for the
group lines would be ideal. Here is a typical model that I would fit in


Time_squared <-lme(Control_Scale~Time*Condition + I(Time^2), data = vse,
random = ~Time|id, method = "ML",  na.action = na.omit, control =


In addition, I'm also wondering if there is a way to get the same graphs as
above for the regression or count portion of a zero-altered poisson model
that was fit using the MCMCglmm package. Here is a sample model. If it's
helpful, the prior being used to model includes both random intercept and
random slopes for both submodels (i.e., regression and logit) of the
zero-altered model.


days.zaglmm3 <- MCMCglmm(Estimate_Days ~ -1 + trait*(Time), 

                         data = vse, family = "zapoisson",

                         random = ~us(at.level(trait,1) +

                                        at.level(trait,1):Time):id + 

                           us(at.level(trait,2) +


                         rcov = ~ idh(trait):units,

                         prior = zi.prior3,

                         #nitt = 1050000, burnin = 50000, thin = 1000,

                         verbose = TRUE, pr = TRUE, pl = FALSE)


I would appreciate any suggestions for either of these scenarios.
Alternatively, if you have suggestions that would better show the group
trends over time to an audience that is not statistically savvy and simply
wants to visualize the outcome change over time, I would also appreciate it.


Thank you,





	[[alternative HTML version deleted]]

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