2

Apologies for that. Here's my question with a reproducible data set:

library(effects)
data(Arrests)

Arrests$year <- as.factor(Arrests$year)

arrests.mod <- glm(released ~ employed + citizen + checks + colour*year + 
                   colour*age, family=binomial, data=Arrests)

t.effects  <- allEffects(arrests.mod)

plot(t.effects, "colour:year")
plot(t.effects, "colour:age")

Is it possible to combine the two plots into a single figure?

par(mfrow=c(2,1)) 

This doesn't work. I.e. the figures are reproduced separately in two graphs, but not in the same figure.

afuzzyllama
  • 6,538
  • 5
  • 47
  • 64
tasmaniac
  • 33
  • 9
  • What does `unfortunately doesn't not work` mean? Please make your situation reproducible, i.e. provide us with the data and the code needed to mimic your situation. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for more tips on how to do this. – Paul Hiemstra Apr 20 '13 at 11:59
  • You've got some rogue " in your code too - look at the coloring. – Bryan Hanson Apr 20 '13 at 12:04
  • Sorry, I provided a better example above. Julia – tasmaniac Apr 20 '13 at 13:20

2 Answers2

3

par(mfrow=c(2,1)) don't work for grid plots. It is only for base graphics. You can use gridExtra to arrange lattice plots.

library(gridExtra)
p1 <- plot(t.effects, "colour:year")
p2 <- plot(t.effects, "colour:age")
grid.arrange(latticeGrob(p1),
            latticeGrob(p2))

enter image description here

agstudy
  • 119,832
  • 17
  • 199
  • 261
0

You can reference specific effects from your alleffects object with vector indices. In your case I believe t.effects[4:5] or, equivalently, t.effects[c("colour:year", "colour:age")]

library(effects)
data(Arrests)

Arrests$year <- as.factor(Arrests$year)
arrests.mod <- glm(released ~ employed + citizen + checks + colour*year + colour*age, family=binomial, data=Arrests)
t.effects <- allEffects(arrests.mod)

plot(t.effects[4:5])
David
  • 9,284
  • 3
  • 41
  • 40