Search code examples
rlme4sjplot

How to only show fixed effect estimates of lmer model using sjPlot::plot_model


I would like to plot the estimates of the fixed effects of an lme4::lmer model. Currently, the sjPlot::plot_model output includes two additional plots that I do not want: SD (Observations) and SD (Intercept). How can I remove these two additional plots?

library(lme4)
data(iris)
lmerMod <- lmer(Sepal.Length ~ Sepal.Width * Petal.Length + (1|Species), data=iris)

library(sjPlot)
plot1 <- plot_model(lmerMod,
           type = "est",
           show.intercept = TRUE,
           title = "Estimates of fixed effects")

plot1

Essentially, I would like an output that looks like what is produced when plotting the fixed effects of an glm model, e.g.:

glmMod <- glm(Sepal.Length ~ Sepal.Width * Petal.Length, data=iris)
plot2 <- plot_model(glmMod,
           type = "est",
           show.intercept = TRUE,
           title = "Estimates of fixed effects")

plot2

I believe that this what the sjPlot::plot_model function used to produce by default when plotting lmer models before because this is what my code used to produce. Thank you for your help!


Solution

  • Have you tried reinstalling all the packages and restarting your RStudio session? It's possible that you overwrote some sort of default because I can't reproduce the images that you have attached. I'm using the most recent version of sjPlot from CRAN (2.8.9).

    This is what I get when I run your code, slightly modified to call the plot to plot window:

    library(lme4)
    data(iris)
    lmerMod <- lmer(Sepal.Length ~ Sepal.Width * Petal.Length + (1|Species), data=iris)
    
    library(sjPlot)
    plot1 <- plot_model(lmerMod,
               type = "est",
               show.intercept = TRUE,
               title = "Estimates of fixed effects")
    plot1
    

    enter image description here

    And then I run the second part:

    glmMod <- glm(Sepal.Length ~ Sepal.Width * Petal.Length, data=iris)
    plot2 <- plot_model(glmMod,
                        type = "est",
                        show.intercept = TRUE,
                        title = "Estimates of fixed effects")
    plot2
    

    enter image description here