首页 > 解决方案 > 在 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"))

标签: rtexreg

解决方案


您必须考虑使用正则表达式,用|. 例子:

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

推荐阅读