Announcement

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

  • DID with fixed effects – problem with noestimcheck?

    Dear Statalisters,

    I am estimating a difference-in-difference with fixed effects. I use the nostimcheck to calculate the predictive margins and marginal effects. However, the difference between the control and treatment group in the first time period (98) is zero in all my models. I cannot share my original dataset, but I have made an example dataset to illustrate the issue (note: time is a standardized time variable that ranges from 98 to 103):
    Code:
    clear
    input float(id time treatment salary)
    14 100 0 20000
     7 100 0 20000
    13 102 0 23000
    13  98 0 23000
     9 102 0 21000
    10 101 0 20000
    10 102 0 20000
    10 103 0 20000
    14  99 0 22000
    10  98 0 21000
    14 101 0 20000
     7  98 0 20000
    13 100 0 23000
     6  99 0 24000
     9  98 0 21000
     8 103 0 20000
    10  99 0 21000
     8 101 0 20000
     8 100 0 20000
     8  99 0 20000
     7 102 0 20000
     7 101 0 20000
     6 102 0 24000
    13  99 0 23000
     6 101 0 24000
     7  99 0 20000
    13 103 0 22000
     9  99 0 21000
     9 100 0 21000
    14 103 0 20000
     8 102 0 20000
     9 103 0 21000
    14  98 0 20000
     8  98 0 20000
    13 101 0 23000
     6 100 0 24000
    14 102 0 20000
     6  98 0 24000
    10 100 0 20000
     7 103 0 20000
     9 101 0 21000
     6 103 0 24000
     3 102 1 24000
     1 103 1 15000
    12  98 1 20000
     4 100 1 15000
     5  99 1 20000
     2 100 1 17000
    12  99 1 20000
    12 101 1 20000
     3 103 1 24000
     3  99 1 21000
     1 101 1 15000
     2  99 1 20000
     4 102 1 15000
     1 102 1 15000
     3 100 1 24000
     2 103 1 17000
     2 101 1 17000
     2  98 1 20000
     1  99 1 20000
     1  98 1 20000
     5 102 1 22000
     1 100 1 15000
     5  98 1 20000
     5 101 1 22000
    12 100 1 20000
     4 101 1 15000
     3  98 1 21000
     3 101 1 24000
     4  99 1 19000
     2 102 1 17000
     4 103 1 15000
     4  98 1 19000
    12 102 1 19000
     5 100 1 21000
    12 103 1 19000
     5 103 1 22000
    end

    Here is some code for illustration:
    Code:
    xtset id time
    xtreg salary i.treatment##i.time, fe cluster(id)
    margins treatment, at(time =(98 99 100 101 102 103)) noestimcheck
                        *_at#treatment
                        *1 0  |     20692.31
                        *1 1  |     20692.31
    marginsplot
    Same result in time = 98 when estimating the marginal effects
    Code:
    margins, dydx(treatment) at(time =(98 99 100 101 102 103)) noestimcheck
                        *1.treatment
                        *_at
                        * 1  |     0
    marginsplot
    Can anybody explain what is happening in the first time period? This might be problematic for my case because I would like to assess the parallel trend.


    Gustav
    Last edited by Gustav Egede Hansen; 02 Jul 2021, 04:59.

  • #2
    Hi Gustav, I seem to have the same issue. Have you manged to figure out what is going on and why?

    Best wishes,
    Nicole

    Comment


    • #3
      Hi Nicole Kapelle

      I posted the question in another thread (https://www.statalist.org/forums/for...with-moderator), which provided a partial answer. However, I could not use the solution - regress salary i.treatment##i.time i.id - because I have too many individuals, so my model could not be estimated with i.id. But maybe you can 😊

      Here is the reply:
      I see. The problem you are encountering was actually flagged for you by Stata--you used the -noestimcheck- option here. But you did that because without it you got "(not estimable)" results, which was Stata's warning that you might be doing something that is ill-defined. And in this setting it is, indeed, ill-defined. The problem is that the variable treatment is colinear with the fixed effects. To break the colinearity, the treatment variable is omitted from the model. But that is an arbitrary decision. The colinearity could have been broken by omitting one of the fixed effects (try it with -regress salary i.treatment##i.time i.id- and you will see that treatment is retained in the model, but an extra id is dropped.) This means that the effects of treatment and the fixed effects cannot be separately identified. When you use -noestimcheck- you persuade Stata to do some calculations, but the results are a function of the particular way the colinearity is broken, and they are not meaningful effects.
      If you find another way to retain the timeperiod, please let me know.

      Best,
      Gustav

      Comment

      Working...
      X