Search code examples
rmodeleffectmixed

Which R package can I use to visualize mixed effect model coefficient


I am working on mixed effect model using lmer function in R. My response variable is Productivity which is continues variable and I try to find the effect of 5 predictors on productivity(SR, NRI, CWM_H, and CWM_Chl and FDispersion) all the predictors are continues variables. I want to visualize the model result using coefficient plot in the same way as you can see on the image. (using different colors for positive and negative predictors).The data collected in 2017 and 2018 from 32 plots (sampled from 32 plots) repeated measure, so that I used the four predictors mentioned above as fixed effect and the plot as random effect in the model. Which package I should use to visualize the coefficient? Any help would be greatly appreciated!

Formula I have used

mixed_model<- lmer(Productivity_log ~ SpR + NRI + CWM_Height + CWM_Chlorophyl +  
    FDispersion + (1 | Plot), Data= datsc,REML=TRUE) 

<img src="http://example.com/img.jpg">
<img src="http://file:///C:/Users/Gossaye/Desktop/CWM/png.jpg">


Solution

  • sjPlot::plot_model() does exactly this. A quick demo:

    library(lme4)
    library(sjPlot)
    data(msleep, package = "ggplot2")
    
    mixed_model <- lmer(
      sleep_total ~ brainwt + bodywt + factor(vore) + (1 | order),
      data = msleep
    )
    
    plot_model(mixed_model)