Skip to content
Prev 15355 / 20628 Next

LMER: Visualizing three-way interaction

Hello Klemens,

Have a look at the effects package and this document:

https://www.jstatsoft.org/article/view/v008i15/effect-displays-revised.pdf

Using the Owles data (two continuous variables and one categorical, but
fit to a bernoulli response, which doesn't matter for your problem,
because it results also in a continuous variable for the fit), you can
cut your data in sections:

library(effects)

data("Cowles")
cowles.mod <- glm(volunteer ~ sex * neuroticism * extraversion,
                  data=Cowles, family=binomial)

# standard effects plot via lattice:
plot(effect("sex*neuroticism*extraversion", cowles.mod,
            xlevels = list(neuroticism = 0:24,
		           extraversion = seq(0, 24, 6))),
     multiline = TRUE, ylab = "Probability(Volunteer)")

# easily to get a dataframe to do it yourself with ggplot2:
ne.effect <- data.frame(effect("sex*neuroticism*extraversion",
                               cowles.mod, 		
			       xlevels=list(neuroticism = seq(0, 24, 6),
			       extraversion=0:24)))

library(ggplot2)
ne.effect$neuroticismF <- factor(ne.effect$neuroticism,
				labels = paste0("extraversion: ",
				unique(ne.effect$neuroticism)))

ggplot(ne.effect, aes(x = extraversion, y = fit, group = sex)) +
theme_bw() + ylim(0,1) +
    geom_line(aes(linetype = sex), size = 1.2) +
    geom_ribbon(aes(ymin = lower, ymax = upper, linetype = sex),
    color = "black", fill = "grey", alpha = 0.1) +
    facet_wrap(~ neuroticismF)

Extracting data with different levels for continuous variables does also
work with objects from lmer if you want to only concentrate on the fixed
effects estimates. And this attempt at plotting three variables is the
most standard one for the every day reviewer from my opinion...

Good luck!



Am 12.04.2017 um 20:54 schrieb Thierry Onkelinx:
--

_____________________________________________________________________

Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard G?ke (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Pr?l?, Rainer Schoppik
_____________________________________________________________________

SAVE PAPER - THINK BEFORE PRINTING