Announcement

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

  • Suest for comparting coefficients for two samples using Fixed Effects regression

    I am using xtivreg for fixed effects regression. I want to compare coefficients for identical models, using two different subsets for the data. I'd like to use suest, but it looks like I can't do this with fixed effects models.

    I found this tip by Mark Schaffer on how to transform a fixed effect model to one using regress (http://www.stata.com/statalist/archi.../msg00507.html). Then, one could use -suest- as usual. I did this, but I got the following error:

    "score variables for model est1 contain missing values"

    I use the simple example that he has on the link above, subsetting the data by those with years >1980 vs. those with year <1980. When I subsequently do "suest est1 est2", I get the error.

    I've been searching this error message with stata, but I can't find any guidance on it.

    There is another example of this here:
    http://www.stata.com/statalist/archi.../msg00282.html
    Last edited by Eric Lin; 15 Nov 2016, 13:17.

  • #2
    Trading some emails with Mark, I have a good functioning example I can integrate into this question.

    Mark was able to provide the following example of the approach that runs clean:

    webuse abdata, clear

    * Note the degrees of freedom = 890
    xtreg n w, fe

    * Apply centering to the same sample
    by id: center n w if e(sample)

    * Force dof to be 890
    reg c_n c_w, dof(890) nocons
    est store reg1

    * Note the degrees of freedom = 890
    xtreg ys k, fe

    * Apply centering to the same sample
    by id: center ys k if e(sample)

    * Force dof to be 890
    reg c_ys c_k, dof(890) nocons
    est store reg2

    * suest
    suest reg1 reg2, cluster(id)

    However, the issue I have with this is that I'm trying to use suest to test if between two identical models, (but run on different subsets of data), the coefficients on a single regressor is the same. The example here has two models that have different DVs and IVs. If I amend the example, subsetting the data by id (cutting it at the id 70), but using the same model, I would do the following:

    webuse abdata, clear

    * Note the degrees of freedom = 69
    xtreg n w if id > 70, fe vce(cl id)

    * Apply centering to the same sample
    by id: center n w if e(sample)

    * Force dof to be 69
    reg c_n c_w, dof(69) nocons
    est store reg1

    drop c_n c_w

    * Note the degrees of freedom = 69
    xtreg n w if id <= 70, fe vce(cl id)

    * Apply centering to the same sample
    by id: center n w if e(sample)

    * Force dof to be 69
    reg c_n c_w, dof(69) nocons
    est store reg2

    * suest
    suest reg1 reg2, cluster(id)

    This returns the error: "core variables for model reg1 contain missing values"

    Given this recent example, I'm wondering if I'm not thinking about -suest- correctly. In the way I have seen this done before, the next lines of code if the suest runs would be:
    suest est1 est2, cluster (id)
    test [est1_mean]var - [est2_mean]var= 0
    And this would finally test if the coefficient across the two data sets are the same.

    Not sure why this error continues, but welcome any guidance.


    Comment


    • #3
      Eric:

      Two problems with your code.

      First, you should estimate using xtreg without vce(cl id) to get the right dof. This will be 470 and 419, if I'm not mistaken.

      Second, the error is being caused by the line "drop c_n c_w". What you should do instead is create two new variables for each one you are using, e.g.

      Code:
      gen n1=n
      gen n2=n
      gen w1=w
      gen w2=w
      Then use n1 and w1 for your first sub-sample, and n2 and w2 for your second sub-sample. You won't have to drop anything, and the code should work.

      --Mark

      Comment


      • #4
        all clear, works great, thanks!

        Comment


        • #5
          One additional follow up question. If there are factor variables in the original fixed effects specification, how should these be treated? When centering them, using the [by id: center . . . ] approach, I get the error "factor variables and time-series operators are not allowed". The example we are using here only looks at numeric variables, and it intuitively makes sense how these can be centered by id. But how can a factor variable be "centered"?. Say, for the simple case of two periods, we have a factor variable for region (north, south, east, and west). If a person was working in the north region at time=1, then the south region at time=2, then would the centered variables for that individual be .5 for north, .5 for south, 0 for east and 0 for west?

          Comment


          • #6
            Originally posted by Eric Lin View Post
            One additional follow up question. If there are factor variables in the original fixed effects specification, how should these be treated? When centering them, using the [by id: center . . . ] approach, I get the error "factor variables and time-series operators are not allowed". The example we are using here only looks at numeric variables, and it intuitively makes sense how these can be centered by id. But how can a factor variable be "centered"?. Say, for the simple case of two periods, we have a factor variable for region (north, south, east, and west). If a person was working in the north region at time=1, then the south region at time=2, then would the centered variables for that individual be .5 for north, .5 for south, 0 for east and 0 for west?
            Hi Eric, have you found a solution for the factor variables?

            Also, why did you use "nocons" in the reg? is it required? Thanks.

            Comment

            Working...
            X