1

I'm a biology graduate trying to plot my GLMM using R and the library "effects".

I'm trying to plot my model using this string, and it works perfectly.

enter image description here

library(effects) 
mod.cowles <- glmer((preshunt)~road+(1|area),family=binomial)
eff.cowles <- allEffects(mod.cowles) 
plot(eff.cowles, main= FALSE,rug=FALSE,colors=1, band.colors=3, col=1)

My problem is that I need the axis with the same lims, starting from 0 to 0.5 values and with the same scaling. I'm trying to do that by adding them to the script

mod.cowles <- glmer((preshunt)~road+(1|area),family=binomial)
eff.cowles <- allEffects(mod.cowles) 
plot(eff.cowles, main= FALSE,rug=FALSE,colors=1, band.colors=3, col=1, xlim=c(0,0.5), ylim=c(0,0.5))

But then R just decides to give me an empty graph, not even with the correct axis.

enter image description here

Can anybody give me a hint on how to solve this problem?

MLavoie
  • 9,671
  • 41
  • 36
  • 56
Fabrizio
  • 13
  • 5

2 Answers2

3

I wrote to the author of the function John Fox and got a reply that the values on y are actually on logit scale (:facepalm:, it's a logistic regression!). It's fairly trivial to convert "raw" values to logit and back.

Here's a reproducible example:

library(effects) 
library(lme4)

mod.cowles <- glmer(volunteer ~ extraversion + (1|sex), 
                    family=binomial, data = Cowles) # doesn't converge
eff.cowles <- allEffects(mod.cowles) 

plot(eff.cowles, main= FALSE,rug=FALSE,colors=1, band.colors=3, col=1, 
     xlim=c(0, 20), ylim = qlogis(c(0.1, 0.6))) # also log(c(.1, .6)/c(.6, .1))

enter image description here

You can set ylim = qlogis(c(0.01, 0.99)) and you'll get the below plot. Mind that this is on logit scale where 0 and 1 are (-)Inf.

qlogis(seq(0, 1, by = 0.1))
[1] -Inf -2.1972246 -1.3862944 -0.8472979 -0.4054651 0.0000000
    0.4054651 0.8472979 1.3862944 2.1972246 Inf

enter image description here

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
  • Thank you for your help, it definetely seems i'll have to go back to the "trial and error" method... – Fabrizio Mar 02 '16 at 09:10
  • @Fabrizio I have updated my answer, no need for "brute force" search pattern. – Roman Luštrik Mar 02 '16 at 13:58
  • thank you, I tried the script u wrote but it still doesn't give me the desired results. My co-author wants the full y axis values, so the range should be 0-1. When I try to set those values, i still got an empty graph like the one i posted above. I'll keep trying, maybe i'll got some results using ggplot2. Thanks again! – Fabrizio Mar 03 '16 at 16:41
0

Even though this post is quite old, this might still be of help or for other people experiencing the same problem. I came across the same trouble with an empty graph & wrong axis scale and figured it has to do with the version of R or rather some packages. Changing to a newer version solved the problem.