Announcement

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

  • Fixed Effects different from variables of xtset

    Hi! I have a panel data quarterly (yq) and by firm (newid), so when i run xtset, y run
    Code:
    xtset newid yq
    Now, i want to run the regression with xtreg but the fixed effect has to be by industry, with the variable sectorid and by yq. When i run
    Code:
    xtreg depvar indepvar i.yq i.sectorid, robust
    automatically stata used randomm effects, and i want fixed effects. How can i change this?
    If i try with ,fe Stata run fixed effetcs of newid.

  • #2
    Code:
    xtset sectorid
    xtreg depvar indepvar i.yq, fe robust

    Comment


    • #3
      Dear Manuel, You might to try (ssc install reghdfe and ssc install ftools):
      Code:
      reghdfe depvar indepvar, a(yq sectorid) vce(cl sectorid)
      See
      Code:
      webuse grunfeld, clear
      
      gen ind = 1
      replace ind = 2 if company > 3
      replace ind = 3 if company > 7
      
      // Mine
      reghdfe invest mvalue kstock, a(ind year) vce(cl ind)
      
      // Andrew Musau
      xtset ind
      xtreg invest mvalue kstock i.year, fe robust
      Last edited by River Huang; 08 Jun 2021, 16:39.
      Ho-Chuan (River) Huang
      Stata 19.0, MP(4)

      Comment


      • #4
        Thanks to both! And for the command reghdfe if i want to add robustness too, how can i do that? i tried with
        Code:
        vce(cluster sectorid, robust)
        and
        Code:
        vce(robust) vce(cluster sectorid)
        and didn't work, there's any way to do that in this command?

        Comment


        • #5
          vce(robust) vce(cluster sectorid)
          You cannot specify both at the same time. In reghdfe, -vce(robust)- gives you Huber-White standard errors and -vce(cluster clustervar)- gives you clustered standard errors. For panel data with \(N>>T\), the latter are robust to heteroscedasticity and arbitrary forms of serial correlation whereas the former are not appropriate. See the manual entry of xtreg for more discussion on this and the related literature.

          Code:
          help xtreg

          Comment

          Working...
          X