R: Continuous and categorical variable interaction plot for GLMM (lme4)

I would like to make a graph of interaction to visually display the difference or similarity in the slopes of the interaction of a categorical variable (4 levels) and a standardized continuous variable from the results of the regression model.

with(GLMModel, interaction.plot(continuous.var, categorical.var, response.var)) Not what I'm looking for. It creates a graph in which the slope changes for each value of the continuous variable. I want to make a graph with constant slopes, as in the following figure:

enter image description here

Any ideas?

I approach a model of the form fit<-glmer(resp.var ~ cont.var*cat.var + (1|rand.eff) , data = sample.data , poisson) Here are some examples of data:

 structure(list(cat.var = structure(c(4L, 4L, 1L, 4L, 1L, 2L, 1L, 1L, 1L, 1L, 4L, 1L, 1L, 3L, 2L, 4L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 3L, 1L, 1L, 2L, 4L, 1L, 2L, 1L, 1L, 4L, 1L, 3L, 1L, 3L, 3L, 4L, 3L, 4L, 1L, 3L, 3L, 1L, 2L, 3L, 4L, 3L, 4L, 2L, 1L, 1L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 1L, 4L, 4L, 3L, 3L, 1L, 3L, 3L, 3L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 4L, 1L, 3L, 4L, 1L, 1L, 4L, 1L, 3L, 1L, 1L, 3L, 2L, 4L, 1L, 4L, 1L, 4L, 4L, 4L, 4L, 2L, 4L, 4L, 1L, 2L, 1L, 4L, 3L, 1L, 1L, 3L, 2L, 4L, 4L, 1L, 4L, 1L, 3L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 4L, 1L, 2L, 2L, 1L, 1L, 2L, 3L, 1L, 4L, 4L, 4L, 1L, 4L, 4L, 3L, 2L, 4L, 1L, 3L, 1L, 1L, 4L, 4L, 2L, 4L, 1L, 1L, 3L, 4L, 2L, 1L, 3L, 3L, 4L, 3L, 2L, 3L, 1L, 4L, 2L, 2L, 1L, 4L, 1L, 2L, 3L, 4L, 1L, 4L, 2L, 1L, 3L, 3L, 3L, 4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L, 1L, 4L, 1L, 2L, 4L, 1L, 1L, 4L, 1L, 1L, 1L, 1L, 1L, 3L, 4L, 1L, 4L, 4L, 2L, 2L, 2L, 2L, 3L, 4L, 4L, 1L, 1L, 4L, 2L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 3L, 4L, 2L, 3L, 1L, 1L, 1L, 4L, 1L, 1L, 4L, 4L, 4L, 1L, 1L, 1L, 1L), .Label = c("A", "B", "C", "D"), class = "factor"), cont.var = c(-0.0682900527296927, 0.546320421837542, -0.273160210918771, -0.887770685486005, 0.136580105459385, 0.75119058002662, 0.546320421837542, -0.273160210918771, -0.682900527296927, 0.136580105459385, 0.75119058002662, 0.75119058002662, 0.75119058002662, 0.341450263648464, 0.75119058002662, 0.546320421837542, 0.546320421837542, -0.478030369107849, -0.478030369107849, -0.682900527296927, -0.682900527296927, 0.546320421837542, -0.478030369107849, -0.0682900527296927, 0.136580105459385, 0.136580105459385, 0.75119058002662, -0.478030369107849, 0.75119058002662, -0.887770685486005, 0.136580105459385, -0.478030369107849, 0.341450263648464, -0.682900527296927, -0.478030369107849, 0.341450263648464, -0.478030369107849, 0.546320421837542, 0.75119058002662, -0.478030369107849, -0.273160210918771, 0.546320421837542, -0.682900527296927, 0.75119058002662, -0.478030369107849, -0.887770685486005, 0.136580105459385, -0.887770685486005, -0.0682900527296927, -0.478030369107849, 0.546320421837542, 0.75119058002662, 0.136580105459385, -0.273160210918771, -0.273160210918771, 0.75119058002662, -0.682900527296927, 0.136580105459385, -0.273160210918771, -0.273160210918771, 0.136580105459385, 0.136580105459385, 0.341450263648464, 0.136580105459385, -0.273160210918771, -0.273160210918771, -0.682900527296927, -0.887770685486005, -0.0682900527296927, 0.136580105459385, -0.0682900527296927, -0.273160210918771, -0.273160210918771, 0.341450263648464, 0.75119058002662, -0.682900527296927, -0.0682900527296927, -0.273160210918771, -0.887770685486005, -0.0682900527296927, 0.75119058002662, 0.546320421837542, 0.75119058002662, 0.75119058002662, -0.887770685486005, 0.341450263648464, 0.75119058002662, -0.887770685486005, 0.136580105459385, -0.273160210918771, 0.546320421837542, 0.546320421837542, -0.682900527296927, 0.75119058002662, 0.136580105459385, -0.0682900527296927, -0.478030369107849, 0.75119058002662, -0.478030369107849, 0.341450263648464, 0.136580105459385, -0.0682900527296927, -0.478030369107849, -0.0682900527296927, -0.0682900527296927, 0.546320421837542, -0.273160210918771, 0.75119058002662, 0.341450263648464, 0.546320421837542, -0.478030369107849, 0.136580105459385, -0.887770685486005, -0.273160210918771, -0.273160210918771, -0.478030369107849, -0.478030369107849, 0.75119058002662, -0.682900527296927, -0.0682900527296927, 0.546320421837542, 0.75119058002662, 0.546320421837542, 0.136580105459385, -0.478030369107849, 0.136580105459385, 0.546320421837542, -0.478030369107849, -0.0682900527296927, -0.0682900527296927, 0.546320421837542, -0.273160210918771, 0.136580105459385, -0.0682900527296927, 0.75119058002662, -0.0682900527296927, 0.546320421837542, -0.887770685486005, -0.0682900527296927, -0.682900527296927, -0.478030369107849, -0.478030369107849, -0.682900527296927, 0.75119058002662, 0.341450263648464, -0.0682900527296927, 0.341450263648464, -0.0682900527296927, -0.887770685486005, -0.887770685486005, -0.273160210918771, -0.0682900527296927, 0.546320421837542, -0.0682900527296927, -0.0682900527296927, 0.75119058002662, -0.0682900527296927, -0.273160210918771, -0.478030369107849, 0.546320421837542, 0.546320421837542, 0.546320421837542, 0.341450263648464, 0.136580105459385, -0.478030369107849, 0.136580105459385, 0.136580105459385, 0.136580105459385, -0.478030369107849, -0.273160210918771, -0.273160210918771, -0.273160210918771, 0.341450263648464, -0.273160210918771, -0.0682900527296927, 0.136580105459385, 0.546320421837542, -0.478030369107849, -0.273160210918771, 0.546320421837542, 0.546320421837542, -0.273160210918771, -0.0682900527296927, 0.341450263648464, 0.546320421837542, -0.0682900527296927, 0.136580105459385, -0.478030369107849, 0.75119058002662, -0.478030369107849, -0.682900527296927, -0.478030369107849, 0.136580105459385, -0.273160210918771, -0.0682900527296927, -0.887770685486005, -0.887770685486005, 0.546320421837542, -0.273160210918771, 0.546320421837542, -0.478030369107849, 0.546320421837542, -0.0682900527296927, 0.75119058002662, -0.273160210918771, 0.546320421837542, 0.341450263648464, -0.0682900527296927, -0.0682900527296927, -0.0682900527296927, -0.887770685486005, 0.136580105459385, -0.273160210918771, -0.478030369107849, 0.75119058002662, 0.341450263648464, 0.546320421837542, -0.273160210918771, 0.546320421837542, 0.75119058002662, -0.273160210918771, 0.75119058002662, 0.546320421837542, -0.273160210918771, -0.273160210918771, 0.75119058002662, -0.273160210918771, -0.0682900527296927, 0.136580105459385, -0.478030369107849, 0.75119058002662, 0.75119058002662, -0.887770685486005, -0.887770685486005, 0.546320421837542, -0.682900527296927, -0.887770685486005, 0.136580105459385, 0.75119058002662, 0.75119058002662, -0.478030369107849, 0.136580105459385, 0.75119058002662, -0.273160210918771, -0.682900527296927, -0.273160210918771, 0.136580105459385, 0.546320421837542, -0.682900527296927, -0.478030369107849, 0.136580105459385, -0.682900527296927, -0.0682900527296927, -0.478030369107849, 0.136580105459385, -0.887770685486005, -0.273160210918771, -0.0682900527296927, -0.273160210918771, -0.887770685486005, 0.546320421837542, 0.546320421837542, -0.478030369107849, -0.273160210918771, -0.0682900527296927, 0.136580105459385, -0.478030369107849, 0.75119058002662, 0.341450263648464, 0.136580105459385, 0.136580105459385, 0.75119058002662, 0.136580105459385, -0.0682900527296927, 0.546320421837542, -0.0682900527296927, -0.887770685486005, 0.75119058002662, 0.75119058002662, 0.546320421837542, -0.887770685486005, -0.0682900527296927, -0.682900527296927, -0.682900527296927, 0.75119058002662, 0.75119058002662, -0.478030369107849, 0.546320421837542, -0.273160210918771, 0.75119058002662, -0.0682900527296927, 0.546320421837542, -0.0682900527296927, -0.273160210918771, 0.546320421837542, 0.75119058002662, -0.0682900527296927, 0.546320421837542, -0.682900527296927, -0.273160210918771, -0.0682900527296927, -0.478030369107849, -0.478030369107849, 0.136580105459385, -0.273160210918771, 0.136580105459385, 0.546320421837542, 0.75119058002662, -0.273160210918771, 0.341450263648464, -0.273160210918771, 0.136580105459385, 0.546320421837542, 0.546320421837542, 0.136580105459385, 0.136580105459385, -0.682900527296927, 0.341450263648464, 0.341450263648464, -0.273160210918771, -0.682900527296927, -0.0682900527296927, 0.75119058002662, -0.887770685486005, -0.478030369107849, -0.273160210918771, -0.478030369107849, -0.478030369107849, 0.136580105459385, -0.478030369107849, 0.136580105459385, -0.478030369107849, 0.136580105459385, -0.0682900527296927, -0.273160210918771, 0.136580105459385, 0.341450263648464, -0.478030369107849, 0.75119058002662, 0.136580105459385, 0.341450263648464, 0.546320421837542, -0.887770685486005, 0.75119058002662, 0.341450263648464, -0.0682900527296927, -0.478030369107849, 0.546320421837542, 0.136580105459385, -0.682900527296927, -0.0682900527296927, 0.341450263648464, -0.478030369107849, -0.0682900527296927, -0.478030369107849, -0.0682900527296927, 0.341450263648464, -0.478030369107849, -0.682900527296927, 0.75119058002662, -0.478030369107849, -0.682900527296927, 0.341450263648464, -0.887770685486005, -0.478030369107849, 0.546320421837542, -0.887770685486005, -0.478030369107849, -0.478030369107849, 0.341450263648464, 0.75119058002662, -0.682900527296927, 0.75119058002662, 0.75119058002662, 0.341450263648464, -0.0682900527296927, 0.546320421837542, -0.0682900527296927, 0.136580105459385, 0.136580105459385, 0.136580105459385, 0.136580105459385, 0.546320421837542, 0.546320421837542, -0.0682900527296927, 0.75119058002662, -0.0682900527296927, -0.0682900527296927, -0.682900527296927, -0.273160210918771, -0.682900527296927, -0.478030369107849, 0.136580105459385, 0.75119058002662, 0.546320421837542, 0.341450263648464, -0.887770685486005, -0.0682900527296927, 0.136580105459385, 0.75119058002662, -0.273160210918771, -0.682900527296927, 0.136580105459385, -0.478030369107849, -0.273160210918771, -0.273160210918771, 0.136580105459385, 0.341450263648464, -0.478030369107849, -0.0682900527296927, -0.682900527296927, 0.75119058002662, -0.273160210918771, -0.478030369107849, -0.0682900527296927, -0.0682900527296927, -0.273160210918771, -0.0682900527296927, -0.478030369107849, 0.75119058002662, -0.0682900527296927, 0.136580105459385, 0.546320421837542, 0.546320421837542, -0.478030369107849, -0.273160210918771, 0.546320421837542, -0.478030369107849, -0.682900527296927, 0.75119058002662, -0.0682900527296927, -0.682900527296927, -0.682900527296927, 0.75119058002662, 0.341450263648464, -0.478030369107849, 0.75119058002662, 0.136580105459385, -0.887770685486005, 0.341450263648464, 0.341450263648464, 0.546320421837542, -0.273160210918771, 0.136580105459385, 0.75119058002662, -0.0682900527296927, -0.682900527296927, -0.478030369107849, -0.478030369107849, 0.75119058002662, 0.546320421837542, -0.478030369107849, 0.546320421837542, 0.136580105459385, -0.887770685486005, 0.75119058002662, -0.0682900527296927, 0.75119058002662, 0.75119058002662, -0.273160210918771, -0.682900527296927, 0.546320421837542, 0.546320421837542, -0.887770685486005, 0.75119058002662, -0.273160210918771, 0.546320421837542, -0.0682900527296927, 0.136580105459385, 0.341450263648464, -0.478030369107849, 0.136580105459385, 0.136580105459385, -0.273160210918771, 0.546320421837542, -0.273160210918771, -0.273160210918771, -0.273160210918771, 0.75119058002662, -0.887770685486005, -0.887770685486005, -0.0682900527296927, -0.478030369107849, -0.0682900527296927, 0.75119058002662, -0.273160210918771, 0.136580105459385, -0.478030369107849, -0.273160210918771, 0.136580105459385, 0.75119058002662, 0.546320421837542, -0.478030369107849, -0.273160210918771, -0.273160210918771, 0.136580105459385, -0.273160210918771, -0.0682900527296927, 0.75119058002662, 0.136580105459385), resp.var = c(2L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 3L, 1L, 0L, 1L, 0L, 1L, 2L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 2L, 0L, 3L, 2L, 0L, 2L, 2L, 0L, 0L, 0L, 1L, 1L, 3L, 1L, 2L, 0L, 1L, 0L, 0L, 1L, 0L, 2L, 0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, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L, 43L)), .Names = c("cat.var", "cont.var", "resp.var", "rand.eff"), row.names = c(NA, 500L), class = "data.frame") 
+4
source share
3 answers

Here is a kind answer (by the way, you had some missing quotes in your data frame above that needed to be fixed manually ...)

Install Model:

 library(lme4) fit <- glmer(resp.var ~ cont.var:cat.var + (1|rand.eff) , data = sample.data , poisson) 

(Note that this is a slightly strange model specification - it makes all categories have the same value in cont.var==0 Did you mean cont.var*cat.var ?

 library(ggplot2) theme_update(theme_bw()) ## set white rather than gray background 

Fast and dirty linear regressions:

 ggplot(sample.data,aes(cont.var,resp.var,linetype=cat.var))+ geom_smooth(method="lm",se=FALSE) 

Now with a Poisson GLM (but not including a random effect) and showing data points:

 ggplot(sample.data,aes(cont.var,resp.var,colour=cat.var))+ stat_sum(aes(size=..n..),alpha=0.5)+ geom_smooth(method="glm",family="poisson") 

The following bit requires the development (r-forge) of lme4 , which has a predict method:

Setting the data frame for prediction:

 predframe <- with(sample.data, expand.grid(cat.var=levels(cat.var), cont.var=seq(min(cont.var), max(cont.var),length=51))) 

Predict at the population level ( REform=NA ), on the linear predictor scale (logit) (this is the only way to get straight lines on the graph)

 predframe$pred.logit <- predict(fit,newdata=predframe,REform=NA) minmaxvals <- range(sample.data$cont.var) ggplot(predframe,aes(cont.var,pred.logit,linetype=cat.var))+geom_line()+ geom_point(data=subset(predframe,cont.var %in% minmaxvals), aes(shape=cat.var)) 

enter image description here Now about the response scale:

 predframe$pred <- predict(fit,newdata=predframe,REform=NA,type="response") ggplot(predframe,aes(cont.var,pred,linetype=cat.var))+geom_line()+ geom_point(data=subset(predframe,cont.var %in% minmaxvals), aes(shape=cat.var)) 

enter image description here

+12
source

The jtools package ( CRAN link ) can make drawing such a model quite simple. I am the developer of this package.

We will put a model like Ben in our answer:

 library(lme4) fit <- glmer(resp.var ~ cont.var:cat.var + (1 | rand.eff), data = sample.data, family = poisson) 

And with jtools we just use the interact_plot function as follows:

 library(jtools) interact_plot(fit, pred = cont.var, modx = cat.var) 

Result:

By default, it displays the scale of the response, but you can plot it on a linear scale with the argument outcome.scale = "link" (the default is "response" ).

+2
source

The effects package supports lme4 models and should be able to do what you want.

: effects for linear, generalized linear and other models

The graphical and tabular effect displays, for example, interactions for various statistical models with linear predictors.

It also comes with two slightly outdated documents (you can imagine them as vignettes).

+1
source

Source: https://habr.com/ru/post/1410795/


All Articles