繁体   English   中英

如何基于 R 中的行业代码在面板线性模型 (plm) 中包含行业固定效应

[英]how to include industry fixed effects in a panel linear model (plm) based on industry codes in R

期间: 2005 年至 2011 年

自变量(在整个期间保持不变): famfirm05 = dummy(如果家族拥有 >= 5% 的公司,则等于 1)

因变量:资产回报率

行业固定效应:基于行业代码sic

gvkey = 公司 ID

crisis = 虚拟(如果年份 >= 2008,则等于 1)

这是我的数据框pdata1样子:

    pdata1 <- pdata.frame(data_panel, index=c("gvkey","t"))

       year t gvkey famfirm05 lag_investment crisis  sic
1004-2 2005 1  1004         0     0.07637079      0 5080
1004-3 2006 2  1004         0     0.11489159      0 5080
1004-4 2007 3  1004         0     0.09772772      0 5080
1004-5 2008 4  1004         0     0.11211958      1 5080
1004-6 2009 5  1004         0     0.08628114      1 5080
...

这就是我的池、组间、组内和随机模型的输出如下所示:

ols <- plm(ROA ~  
           + famfirm05*crisis
           + lag_investment
           , data=subset(pdata), model = "pooling")
between <- update(ols, model = "between")
within <- update(ols, model = "within")
walhus <- update(ols, model = "random", random.method = "walhus", random.dfcor = 3)

library("texreg")
screenreg(list(ols = ols, between = between, within = within, 
               walhus = walhus),
          digits = 5, omit.coef = "(Intercept)")

==============================================================================
                      ols             between       within          walhus        
------------------------------------------------------------------------------
famfirm05            0.01148 *       0.10879 *                     0.01064    
                    (0.00532)       (0.04770)                     (0.00712)   
crisis              -0.01662 ***     0.12100 *    -0.01742 ***    -0.01732 ***
                    (0.00403)       (0.04875)     (0.00324)       (0.00324)   
lag_investment       0.01183        -0.04228       0.06096 ***     0.04252 ***
                    (0.00948)       (0.02290)     (0.01042)       (0.00950)   
famfirm05:crisis    -0.00279        -0.20953 *     0.00189         0.00051    
                    (0.00776)       (0.10085)     (0.00623)       (0.00623)   
------------------------------------------------------------------------------
R^2                  0.00528         0.01250       0.01465         0.01002    
Adj. R^2             0.00468         0.00897      -0.18591         0.00943    
Num. obs.             6665            1125          6665            6665          
==============================================================================
*** p < 0.001, ** p < 0.01, * p < 0.05
> 
> car::vif(ols)
       famfirm05           crisis   lag_investment famfirm05:crisis 
        1.884555         1.374256         1.011674         2.252301 

1) 我想在 OLS 模型中包含行业固定效应。

我知道可以从pdata1数据框中为sic变量创建行业虚拟变量。

2) 你们中的一个人是否也知道如何将公司的注册状态潜在地包括为状态固定效应?

非常感谢!!!

1) 如果您想包含行业固定效应,请在模型中包含变量sic作为一个因素,就像 OLS(池化)模型一样:

plm(ROA ~ famfirm05*crisis + lag_investment + factor(sic), data = pdata, model = "pooling")

2) 要包括状态固定效应,您需要一个包含公司状态的变量。 从您显示的数据中我看不到这样的变量。 让我们假设这样一个变量可用并且称为state 我们会像我们对行业固定效应所做的一样将它包括在内 - 作为一个因素,例如在池模型中:

plm(ROA ~ famfirm05*crisis + lag_investment + factor(sic) + factor(state), data = pdata, model = "pooling")

暂无
暂无

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

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