[R-sig-ME] Visualizing three-way interaction
Klemens Knöferle
knoeferle at gmail.com
Thu Apr 13 17:47:00 CEST 2017
Dear all,
thanks for the many helpful suggestions. I decided to go with Ulf's
approach to extract the values from the effects plot; it is very easy and
the results should satisfy these 2-dimensional reviewers (I hope!). Just
wanted to correct a typo in Tom's code:
ne.effect$neuroticismF <- factor(ne.effect$neuroticism,
labels = paste0("extraversion: ",
unique(ne.effect$neuroticism)))
I guess the pasted label should read "Neuroticism: " (correct me if I'm
wrong). Thanks again for all the help and happy Easter!
Klemens
On 13 April 2017 at 11:03, Houslay, Tom <T.Houslay at exeter.ac.uk> wrote:
> Hi Klemens,
>
>
> You probably have all the answers you need now, but just in case they are
> at all useful then I have a little series of posts on my website about
> visualising 3-way interactions using various methods:
>
> 2 continuous, 1 categorical:
> https://tomhouslay.com/2015/06/02/understanding-3-way-
> interactions-between-continuous-and-categorical-
> variables-part-ii-2-cats-1-con/
>
> 1 continuous, 2 categorical:
> https://tomhouslay.com/2014/09/06/understanding-3-way-
> interactions-between-continuous-and-categorical-variables-small-multiples/
>
> 3 continuous:
> https://tomhouslay.com/2014/03/21/understanding-3-way-
> interactions-between-continuous-variables/
>
> Some of these are a little old and don't take advantage of better
> functions in R (that didn't exist or I was unaware of at the time!), but
> might be helpful for ideas on different ways of plotting things. These are
> generally using standard regression models, but predict/broom etc can be
> used to average over random effects (eg using 're.form = NA' in the
> predict.merMod function).
>
> Good luck with your plots!
>
> Cheers
>
> Tom
>
> ------------------------------
> *From:* R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org> on
> behalf of r-sig-mixed-models-request at r-project.org <
> r-sig-mixed-models-request at r-project.org>
> *Sent:* 13 April 2017 09:39
> *To:* r-sig-mixed-models at r-project.org
> *Subject:* R-sig-mixed-models Digest, Vol 124, Issue 12
>
>
> Message: 1
> Date: Wed, 12 Apr 2017 11:41:00 +0200
> From: Klemens Kn?ferle <knoeferle at gmail.com>
> To: r-sig-mixed-models at r-project.org
> Subject: [R-sig-ME] LMER: Visualizing three-way interaction
> Message-ID:
> <CAANFXSJgSG7oUBDhY-+dDuvrFUWfBNm=TP2BZ20QCbYOj5KPL
> w at mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> Hi all,
>
> I'm trying to visualize a three-way interaction from a rather complex
> linear mixed model in R (lmer function from the lme4 package; the model has
> a complex random-effects structure). The interaction consists of two
> continuous variables and one categorical variable (two experimental
> conditions).
>
> So far, I have graphed the interaction via two 3D-surface plots using
> visreg2d from the visreg package. But my reviewers found these plots
> confusing and asked for a different illustration, such as conditional
> coefficient plots (i.e., plots of the strength of coefficient 1 as
> coefficient 2 increases).
>
> I've tried to find a package that allows me to create these kind of plots,
> but failed. The existing packages only allow coefficient plots for two-way
> interactions (for instance the interplot package;
> https://cran.r-project.org/web/packages/interplot/
> vignettes/interplot-vignette.html).
> That means I only get a conditional coefficient plot of the two-way
> interaction, collapsed across both levels of the categorical variable.
>
> Is there a package for my case? If not, I probably have to manually extract
> fitted values from my model (e.g., using broom) and somehow plot them in
> ggplot2. But I don't really know how to do this, whether or not to take
> into account random effects (and how), etc. Any ideas would be much
> appreciated...
>
> Klemens Kn?ferle, Ph.D.
> Associate Professor - Department of Marketing
> BI Norwegian Business School
> Visiting address: Nydalsveien 37, 0484 Oslo
>
> [[alternative HTML version deleted]]
>
>
>
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list