如何基于R

期间: 2005年至2011年

自变量(在整个期间都是恒定的): famfirm05 =虚拟(如果家族拥有公司的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模型中加入行业固定效应。

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

2)你们中的一个人还知道如何潜在地将公司的成立状态作为状态固定效应吗?

非常感谢您!

zhangwenxiu_1923_com 回答:如何基于R

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),model = "pooling")
本文链接:https://www.f2er.com/2921445.html

大家都在问