简体   繁体   中英

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

Period : 2005 until 2011

Independent variable (is constant over the whole period): famfirm05 = dummy (equals 1 if family owns >= 5% of the company)

Dependent variable : Return on assets

Industry fixed effects: Based on industry codes sic

gvkey = company id

crisis = dummy (equals 1 if year >= 2008)

This is how my data frame pdata1 looks like:

    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
...

This is how my output for the pooling, between, within and random model looks like:

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) I would like to include industry fixed effects in the OLS model.

I know that it is possible to create industry dummies for the sic variable from the pdata1 data frame.

2) Does one of you also know how to potentially include the states of incorporation of the companies as state fixed effects?

Thank you so much!!!

1) If you want to include industry fixed effects, include variable sic as a factor in your model, like so for the OLS (pooling) model:

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

2) To include state fixed effects, you would need a variable which contains the firms' state. I cannot see such a variable from the data you show. Let's assume such a variable is available and is called state . We would include it the same was as we did for the industry fixed effect - as a factor, eg in the pooling model:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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