【问题标题】:how to include industry fixed effects in a panel linear model (plm) based on industry codes in R如何在基于 R 中行业代码的面板线性模型 (plm) 中包含行业固定效应
【发布时间】:2019-12-14 16:44:09
【问题描述】:

期间: 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) 你们中是否有人也知道如何将公司的注册状态作为国家固定效应包括在内?

非常感谢!!!

【问题讨论】:

    标签: r controls regression panel plm


    【解决方案1】:

    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")
    

    【讨论】:

      猜你喜欢
      • 2022-01-02
      • 2020-08-10
      • 2015-04-06
      • 1970-01-01
      • 2015-05-01
      • 1970-01-01
      • 2018-08-08
      • 1970-01-01
      • 2021-05-21
      相关资源
      最近更新 更多