如何使用R中的Modelmary获得标准化的Beta系数?以及如何使用Modelsummary省略多个变量?

发布于 2025-01-30 00:33:56 字数 104 浏览 2 评论 0 原文

我正在使用Modelmary创建表。我想对标准化的估计(回归系数)进行标准化。我使用了lm.beta(),但是估计=给我非标准的系数。另外,我想使用COEF.OMITT取出多个变量。我该怎么做?

I am using modelsummary to create a table. I would like to the estimate (regression coefficients) to be standardized. I used lm.beta() but the estimate = is giving me the non-standardized coefficient. Also, I would like to use coef.omitt to take out more than one variable. How might I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆离笙 2025-02-06 00:33:56

该解决方案仅使用 modelsummary 的开发版本起作用。此版本应在接下来的几周内使用Cran,但是您可以立即安装:

library(remotes)
install_github("vincentarelbundock/modelsummary")

在引擎盖下, modelsummary 使用参数软件包来从模型对象提取参数。 标准化参数直接传递到 modelsummary(),然后将其传递到参数

COEF_OMIT 参数接受正则表达式。 请参阅文档以了解如何忽略几个系数。代码> coef_omit =“ x | y | z”

library(modelsummary)
mod <- lm(mpg ~ hp + factor(cyl), data = mtcars)
modelsummary(mod, standardize = "basic")
模型1
(截距) 0.000
(0.000)
HP -0.273
(0.175)
因子(CYL)6 -0.416
(0.114)
因子(CYL)8 -0.713
(0.195)
num.Obs。 32
R2 0.754
R2调整。 0.727
AIC 169.9
BIC 177.2
F 28.585
RMSE 2.94

This solution only works using the development version of modelsummary. This version should be on CRAN in the next few weeks, but you can install it now:

library(remotes)
install_github("vincentarelbundock/modelsummary")

Under the hood, modelsummary uses the parameters package to extract parameters from model objects. As you can see here, that package can apply several different kinds of standardization. You can pass a standardize argument directly to modelsummary(), which will then pass it down to parameters.

The coef_omit argument accepts regular expressions. See the documentation to learn how to omit several coefficients. ex: coef_omit="x|y|z"

For example:

library(modelsummary)
mod <- lm(mpg ~ hp + factor(cyl), data = mtcars)
modelsummary(mod, standardize = "basic")
Model 1
(Intercept) 0.000
(0.000)
hp -0.273
(0.175)
factor(cyl)6 -0.416
(0.114)
factor(cyl)8 -0.713
(0.195)
Num.Obs. 32
R2 0.754
R2 Adj. 0.727
AIC 169.9
BIC 177.2
F 28.585
RMSE 2.94
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文