繁体   English   中英

如何在逻辑回归中将 ci_method 更改为“wald” R

[英]How to change ci_method to "wald" in a logistic regression in R

我需要对包含大约 1,000,000 个数据点的数据集运行逻辑回归。 我跑了一个 model

logit_results <<- glm(y ~ p1 + p2 + p3,
                      data = df,family="binomial", 
                      na.action = "na.exclude")

我想使用plot_model()可视化结果 function

library(sjPlot)
plot_x <- plot_model(logit_results,vline.color = "#1EA891",sort.est = TRUE,title="Graph") 

这需要永远运行(我已经等了大约一个小时,但还没有完成)。 我收到一条消息Profiled confidence intervals may take longer time to compute. Use `ci_method="wald"` for faster computation of CIs. Profiled confidence intervals may take longer time to compute. Use `ci_method="wald"` for faster computation of CIs. 但是,我不知道在哪里更改 ci_method,因为the glm()plot_model()都没有使用ci_method

任何人都知道如何将 ci_method 更改为“wald”?

此消息来自parameters package,它是sjPlot package 的依赖项。如果我们查看 sjPlot 中sjPlot的源代码(我从tidy_model中查找了,但我认为我们可以做类似sjPlot:::tidy_model ) ,那么我们会发现如下代码:

if (is.null(p.val)) {
      if (inherits(model, c("glm", "polr"))) {
        p.val <- "profile"
      } else {
        p.val <- "wald"
      }
    }

这意味着如果未指定p.val并且 model 来自 glm 或 polr,则 p.val 是配置文件,稍后将转换为 ci_method="profile",否则 ci_method 将是 "wald"。

所以这变得非常明显,我们所要做的就是指定p.val="wald"

plot_x <- plot_model(logit_results,vline.color = "#1EA891",
      sort.est = TRUE,title="Graph",p.val="wald") 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM