strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
608 stars 91 forks source link

plot_model fails on simple random effects model #476

Open jebyrnes opened 5 years ago

jebyrnes commented 5 years ago

The following simple example used to plot nicely with sjp.lmer but now gives me faceting errors. Something seems off here.


library(lme4)
library(sjPlot)
adf <- data.frame(site = rep(letters[1:5], 10),
                  y = rnorm(50, rep(-2:2, 10)))

mod <- lmer(y ~ 1|site, data = adf)

plot_model(mod, type = 'est')

This yields

Error: At least one layer must contain all faceting variables: `group`.
* Plot is missing `group`
* Layer 1 is missing `group`
* Layer 2 is missing `group`

when I'm expecting a plot with one estimate for each group (e.g., FE + RE)

I thought maybe I was using the wrong type (sjp.lmer took "coefs"), but, when I changed to off, got

Error in stats::model.frame(formula = y, data = adf, drop.unused.levels = TRUE) : 
  object 'y' not found
strengejacke commented 5 years ago

Honestly, I mostly neglect intercept-only models, because there's not much to plot anyway ;-) But I'll look into this.

when I'm expecting a plot with one estimate for each group (e.g., FE + RE)

This plot type (type = "coef") was removed during the re-implementation of the plotting-function. I have drafted a plot-type to do this again, but not yet finished. It had lower priority, because coef is simply fe+re, and so there's not much more information according the variance then in type = "re". But this plot-type is on my todo-list.