【问题标题】:How to only show fixed effect estimates of lmer model using sjPlot::plot_model如何使用 sjPlot::plot_model 仅显示 lmer 模型的固定效应估计
【发布时间】:2021-11-23 11:08:13
【问题描述】:

我想绘制 lme4::lmer 模型的固定效应的估计值。目前, sjPlot::plot_model 输出包括两个我不想要的附加图:SD(观察)和 SD(截距)。如何删除这两个额外的地块?

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

基本上,我想要一个看起来像绘制 glm 模型的固定效果时产生的输出,例如:

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

我相信这是 sjPlot::plot_model 函数在之前绘制 lmer 模型时默认生成的,因为这是我的代码用来生成的。感谢您的帮助!

【问题讨论】:

    标签: r lme4 sjplot


    【解决方案1】:

    您是否尝试过重新安装所有软件包并重新启动您的 RStudio 会话?您可能覆盖了某种默认值,因为我无法复制您附加的图像。我正在使用来自 CRAN (2.8.9) 的最新版本的 sjPlot。

    这是我在运行您的代码时得到的,稍作修改以调用绘图到绘图窗口:

    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
    

    然后我运行第二部分:

    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
    

    【讨论】:

    • 非常感谢!我已经尝试过几次重新启动我的 R 会话,但重新安装 sjPlotpackage 就成功了!
    • 不客气,很高兴它已排序!
    猜你喜欢
    • 1970-01-01
    • 2020-10-14
    • 2020-06-10
    • 1970-01-01
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多