Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Correlated Random Effects Code

    Dear Community,

    I am currently writing my master thesis on the effect of a company's CO2 emissions on its stock returns. I am using data from MSCI World companies between 2010-2019.

    My dependent variable is: wreturn
    My independent variable is: logco2total
    My control variables are: logssize roe capexassets logppe leverage BM EPS logsales

    Hausman test shows that I should use fixed effects and Pooled OLS shows that year, industry affiliation and the country of a company have a significant effect on the dependent variable. So I should / would like to control for year, industry and country-fixed effects in my regression. However, it is not possible to control for industry and country in fixed effects models because they are time invariant. Therefore I decided to use the Correlated Random Effects (CRE) Model.

    For this, I determined the mean values for the time variant variables (except the dependent variable) as follows:

    . egen mlogco2total = mean(logco2total), by(id)
    (1 missing value generated)

    . egen mlogssize = mean(logssize), by(id)
    (1 missing value generated)

    . egen mroe = mean(roe), by(id)
    (1 missing value generated)

    . egen mcapexassets = mean(capexassets), by(id)
    (1 missing value generated)

    . egen mlogppe = mean(logppe), by(id)
    (1 missing value generated)

    . egen mleverage = mean(leverage), by(id)
    (1 missing value generated)

    . egen mBM = mean(BM), by(id)
    (1 missing value generated)

    . egen mEPS = mean(EPS), by(id)
    (1 missing value generated)

    . egen mlogsales = mean(logsales), by(id)
    (1 missing value generated)


    and calculated CRE as follows:

    xtreg wreturn logco2total logssize roe capexassets logppe leverage BM EPS logsales mlogco2total mlogssize mroe mcapexassets mlogppe mleverage mBM mEPS mlogsales i.industry i.year i.country, i(id) re

    Is this correct? I did not calculate and considered the mean of "year". Is that okay?

    I would really appreciate the answer of some experienced people since I am a Stata beginner!

    Best

    Onur
    Last edited by Onur Buyukgok; 14 Jul 2022, 09:44.

  • #2
    Onur, it's correct if you have a balanced panel data. If your panel is unbalanced, then you need to additionally control for the means of year dummies.

    Comment


    • #3
      Originally posted by Fei Wang View Post
      Onur, it's correct if you have a balanced panel data. If your panel is unbalanced, then you need to additionally control for the means of year dummies.
      Hello Fei, thank you for your reply! My panel data is unbalanced.

      So I would need to calculate the mean of "year" with egen myear = mean(year), by(id) and then have the following regression code:

      xtreg wreturn logco2total logssize roe capexassets logppe leverage BM EPS logsales mlogco2total mlogssize mroe mcapexassets mlogppe mleverage mBM mEPS mlogsales myear i.industry i.year i.country, i(id) re

      Is that correct now? ^^ What about industry and country dummies?
      Last edited by Onur Buyukgok; 14 Jul 2022, 10:15.

      Comment


      • #4
        Onur, it should be the means of "year dummies" rather than the means of "year". For example, "i.year" means you controlled for 9 dummies of year: year2011, year2012, ..., year2019. Then you need to calculate the mean of each dummy and control for every mean.

        Code:
        egen myear2011 = mean(2011.year), by(id)
        ...
        egen myear2019 = mean(2019.year), by(id)
        What about industry and country dummies?
        They are time-invariant, so don't need to worry even though you have unbalanced panel.
        Last edited by Fei Wang; 14 Jul 2022, 10:20.

        Comment


        • #5
          Hi Onur
          i was working with a piece of code that would help you do this "automatically". You can try it if you want;
          For example, for your previous code, it should do

          cre, abs(id): xtreg wreturn logco2total logssize roe capexassets logppe leverage BM EPS logsales mlogco2total mlogssize mroe mcapexassets mlogppe mleverage mBM mEPS mlogsales i.industry i.year i.country, re

          You will need to install reghdfe
          F
          Attached Files

          Comment

          Working...
          X