r - 在 texreg 中省略多个因素
问题描述
使用时,texreg
我经常使用omit.coef
以下方式删除某些估计值(对于固定效应)。
screenreg(lm01,omit.coef='STORE_ID',custom.model.names = c("AA"))
在我的lm
模型中,如果我使用多个固定效应,如何省略多个变量?例如,我有两种类型的固定效果 - STORE_ID 和 Year,比方说。
这不起作用。
screenreg(lm01,omit.coef=c('STORE_ID','Year'),custom.model.names = c("AA"))
解决方案
您必须考虑使用正则表达式,用|
. 例子:
fit <- lm(mpg ~ cyl + disp + hp + drat, mtcars)
texreg::screenreg(fit)
# =====================
# Model 1
# ---------------------
# (Intercept) 23.99 **
# (7.99)
# cyl -0.81
# (0.84)
# disp -0.01
# (0.01)
# hp -0.02
# (0.02)
# drat 2.15
# (1.60)
# ---------------------
# R^2 0.78
# Adj. R^2 0.75
# Num. obs. 32
# =====================
# *** p < 0.001; ** p < 0.01; * p < 0.05
现在省略:
texreg::screenreg(fit, omit.coef=c('disp|hp|drat'))
# =====================
# Model 1
# ---------------------
# (Intercept) 23.99 **
# (7.99)
# cyl -0.81
# (0.84)
# ---------------------
# R^2 0.78
# Adj. R^2 0.75
# Num. obs. 32
# =====================
# *** p < 0.001; ** p < 0.01; * p < 0.05
推荐阅读
- python - AttributeError:模块“cv2.cv2”没有属性“CV_LOAD_IMAGE_COLOR”
- html5-canvas - 带有子路径的 HTML5 Canvas 非零填充规则
- selenium - 如果我们在锁定的机器上运行测试,Selenium Microsoft Edge 浏览器自动化会停止并失败
- angular - E2E Angular 6 websocket 模拟
- android - 使用 Flutter 接收共享文件意图
- sql - Oracle 10g:为具有其他值的表插入缺失日期
- symfony - 带正则表达式的 Symfony 路由
- java - 使用 JavaFX webEngine.print() 函数时的 IllegalStateExeption
- gcc - 英特尔 ICC 2018 与 GCC 8 程序集:堆栈初始化和完成差异
- c# - 文件路径中的正则表达式