Announcement

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

  • Panel data with two way (id and day) fixed effects

    Hi,

    I am using Stata 12/SE.

    I have a panel data set with daily prices (about 700 days) for 15000 firms. I want to estimate a two-way fixed effects model with id and time fixed effects.

    Code:

    xtset id date
    xtreg var1 var2 i.date, fe

    However, Stata calculates for days without any result. I think there are just too many dummy variables.

    Is there a way to improve the process?

    Best,
    Christoph

  • #2

    Hi, Christoph,

    I gather you don't need to add "date" after xtreg, since you did xtset this variable.

    You might well try again the commands without "date" and see if you succeed.

    Below, a link to the Stata manual on the subject:

    http://www.stata.com/manuals13/xtxtreg.pdf

    Hopefully that helps.

    Best,

    Marcos
    Best regards,

    Marcos

    Comment


    • #3
      Thanks for your commend. However, I am not sure whether I got your point.
      So, what I want to control for are id fixed effects as well as time fixed effects (i.e. cost shocks for all firms at the same day).
      Why do you think I do not have to include i.date?

      Comment


      • #4
        Try running OLS with both firm dummies and time dummies. This is equivalent to two-way fixed effects

        reg x1...xn i.id i.date

        Also verify that your date variable has integer values e.g. 1- 700
        Last edited by Andrew Musau; 07 Feb 2015, 13:28.

        Comment


        • #5
          Christoph:
          as an aside to other skillful insights, I would advise you to add -cluster- option to standard errors in pooled OLS.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Dear Christoph,

            "stata calculates for days" is usually because your computer memory (RAM) is too small to create all the required dummies. Instead of -xtreg fe- you could try -reghdfe- (install it from ssc with "ssc install reghdfe"). It works like -areg- but you can put more than one variable in absorb().

            Best,
            Sergio

            Comment


            • #7
              Thanks, guys!
              I tried areg var1 i.date, absorb(id) and reghdfe var1, absorb(FE_DATE=i.date FE_FIRM=i.id) and got the same residuals.
              It took a few minutes but it both worked.
              However, is there a reason why this works just fine and xtreg doesn't or is it likely that I made a mistake?
              Best, Christoph

              Comment


              • #8
                Christoph: As Sergio says, it is likely that your computer memory is too small to estimate all dummies when running -xtreg-

                To check this, try using a sub-sample of the data, running -xtreg- with say 500 firms and 50 days. This should work.

                -areg- is probably efficient in memory usage.

                Incidentally, if Stata had a direct command to run 2way fixed effects (without having to add time dummies), this would not be an issue.
                Last edited by Andrew Musau; 11 Feb 2015, 12:03.

                Comment


                • #9
                  Ok, I see, it is not that easy
                  I also tried _regress var1 i.date, absorb(id). It also works but I get different residuals. Is there an explanation for that?

                  Comment

                  Working...
                  X