Announcement

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

  • Two-dimensional random effects model

    Dear All,

    I have a panel data set with 86 individuals (ind) and 36 time periods (time). I have estimated a 2-dimensional fixed effects model with dependent variable y and two explanatory variables x1 and x2 using xtreg:

    xtreg y x1 x2 i.time, fe

    Now I want to estimate the same specification but with 2-dimensional random effects rather than fixed effects. How do I do that? I tried

    xtreg y x1 x2 i.time, re

    but that gives me a RE/FE model with random effect for 86 individuals and fixed effects for 36 time periods. I have also tried

    mixed y x1 x2 || ind: || time:

    and then I obtain two random effects, one for 86 individuals and one for 3096 individuals/time periods, instead of for just the 36 time periods.

    And if I try

    xtmixed y x1 x2 || ind: || time:

    I get the same again.

    Can anybody suggest me how to obtain what I want?



  • #2
    Code:
    mixed y x1 x2 i.time || time:
    is a random intercepts model: each time period is allowed to have a different intercept (i.e. you are not constraining all observations to have the same intercept). It would intuitively make more sense to allow random intercepts by id. It is called a mixed effects model because the expression before || represents fixed effects (fixed across units), and after || represents random.

    If time is one of your regressors, you could try a random slopes model:

    Code:
    mixed y x1 x2 i.time ||ind: || time:
    Now, time can have a different effect on y according to each group.

    Code:
    xtreg y x1 x2 i.time, re
    gives you a random effect model. Have you run a Hausman (or Mundlak) test on your data? Random effects models make a very stringent assumption of no correlation between the regressors and the unit-specific unobserved heterogeneity. This assumption rarely holds, which is why researchers generally revert to fixed-effects models.

    Comment


    • #3
      For crossed random effects use the syntax:
      Code:
       levelvar: R.varname
      For example, this returns 10 RE for company and 20 RE for time

      Code:
      . webuse grunfeld,clear
      
      . distinct company time
      
      --------------------------------
               |     total   distinct
      ---------+----------------------
       company |       200         10
          time |       200         20
      --------------------------------
      
      . qui mixed invest kstock || _all: R.com || _all: R.time
      
      . predict b*, reffects
      
      . distinct b1 b2
      
      ---------------------------
          |     total   distinct
      ----+----------------------
       b1 |       200         10
       b2 |       200         20
      ---------------------------
      Using Nick Cox & Gary Longton's -distinct-:
      Code:
      net sj 20-4 dm0042_3

      Comment


      • #4
        To Maxence Morlet:

        Many thanks for your feedback. I appreciate your explanation and recommendations. However, I still do not see how to do the RE/RE regression with random effect for 86 individuals and random effect for 36 time periods.

        Note that I understand the need to do the Hausman test, and the fact that FE/FE is probably the best model. But I just want to see what the RE/RE model looks like. Do you know how to do that?

        Comment


        • #5
          To Scott Merryman:

          Many thanks for your feedback. But frankly, I do not understand what you are trying to tell me. As I explained I have ind and time; you refer to 10RE for company and 20 RE for time and I am already lost there.

          Comment


          • #6
            It appears that you want crossed random effects (RE) rather than nested random effects. The example was using the available data set grunfeld.dta to illustrate the syntax. In this data set, the dimensions are company and time.

            In your particular example, I think you would want:
            Code:
            mixed y x1 x2 || all: R.ind || _all: R.time

            Comment


            • #7
              To Scott Merryman:

              Thank you very much for your clarification. You were absolutely right about what I wanted, and about the required code. This worked well, and gave a result that was quite similar to the FE/FE result, as I expected.

              A very big Thank You, and sorry that I did not understand right away!

              Comment

              Working...
              X