2

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!

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much! I had already tried restarting my R session several time but reinstalling the sjPlotpackage did the trick!
You're welcome, glad it's sorted!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.