如何使用sjPlot::plot_model仅展示lmer模型的固定效应估计结果
解决方法
新版sjPlot调整了plot_model()对混合效应模型的默认输出逻辑,默认会同时展示固定效应估计值和随机效应的方差/标准差估计项。你只需要在调用函数时添加show.random = FALSE参数,即可隐藏随机效应相关的输出内容,仅保留固定效应结果,和glm模型的输出效果完全一致。
修改后的代码示例:
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, show.random = FALSE, # 隐藏随机效应估计项 title = "Estimates of fixed effects")
如果需要更精细化控制展示的变量,还可以通过terms参数手动指定要保留的固定效应变量名称。
内容的提问来源于stack exchange,提问作者Sauterelle
相关产品推荐
相关产品推荐

