suppressing some of the plots from plot(allEffects(model)) output

拥有回忆 提交于 2020-07-10 07:47:08

问题


I'm not sure this is possible, but I'm wondering if you can remove some of the not-as-interesting plots from the plot(allEffects(model)) output. I assume this is possible by editing some of the background mechanics that R uses to make the array of graphs. I've already used multiline to reduce the number of graphs from 20, but I'm only interested in 2 of 10 of my remaining plots because it most accurately represents one of my interaction effects from my model (generalized linear mixed model).

Example code:

glmer1 <- glmer(dv ~ categoricalv1*dimensionalv1*categoricalv2*dimensionalv2 + (1 | subjectID), data = data1, family = binomial, contrasts=contrasts1, control = glmerControl(optimizer = "bobyqa"))

When I view the values within the all effects function:

allEffects(model)
model: dv ~ categoricalv1 * dimensionalv2 * categoricalv2 * dimensionalv2

R is clearly reading the values from the output to produce 10 graphs:

E.g.:

catv1*dimv1*catv2*dimv2 effect, , catv2 = 0, dimv2 = -4 ... 
           dimv1
catv1             -2      -0.7       0.5         2         3
dv level1        0.269329 0.4296272 0.5929832 0.7686877 0.8520351
dv level2        0.730671 0.5703728 0.4070168 0.2313123 0.1479649
... (x9 more times to show all the different combinations)

Code for the plot (so far):

 plot(allEffects(model), ylab="Proportion", xlab="Standardized Dimensional V1", main="",
 type="rescale", multiline=T, rescale.axis=F, ci.style="band")

Hopefully there is a way to edit something to only show the plot I'm interested in. Any insights would be appreciated :)


回答1:


Use the function selection=2,

plot(allEffects(model), ylab="Proportion", **selection=2**, xlab="Standardized Dimensional V1", main="", type="rescale", multiline=T, rescale.axis=F, ci.style="band")

for example;

model2<-plot(allEffects(model), selection=2)

model6<-plot(allEffects(model), selection=6)

if you want to combine different plots you can use

library(gridExtra)

grid.arrange( model2, model6,  nrow=1,  ncol=2)


来源:https://stackoverflow.com/questions/50511261/suppressing-some-of-the-plots-from-plotalleffectsmodel-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!