You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 04:24:04