Announcement

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

  • How to perform the pre-trend test in did_imputation?

    From reading the help file of did_imputation, I saw that

    pretrends(integer): if some value k>0 is specified, the command will performs a test for parallel trends, by a separate regression on nontreated observations only: of the outcome on
    the dummies for 1,...,k periods before treatment, in addition to all the FE and controls. The coefficients are reported as pre1,...,prek. The Wald statistic, pvalue, and
    degrees-of-freedom as reported in e(pre_chi2), e(pre_p), and e(pre_df) resp.

    - Use a reasonable number of pre-trends, do not use all of the available ones unless you have a really large never-treated group. With too many pre-trend coefficients, the power
    of the joint test will be lower.

    - The entire sample of nontreated observations is always used for pre-trend tests, regardless of hbalance and other options that restrict the sample for post-treatment effect
    estimation.

    - The number of pretrend coefficients does not affect the post-treatment effect estimates, which are always computed under the assumption of parallel trends and no anticipation.
    I am wondering about how we should conduct a pre-trend testing. Is it that after having pre1,...prek, we conduct a joint null test for the coefficient of pre1 to prek by using
    Code:
    test (pre1=0) (pre2=0)....(prek=0)?

  • #2
    Looks like did_imputation (SSC) does that for you as you noticed with the ptrends option.

    Credit to FernandoRios for most of the code. I recommend you take a look at some of the helpful entries he has on DID-
    https://friosavila.github.io/playing...did_union.html

    Code:
    
    clear all
    
    webuse nlswork
    
    bysort id (year):replace union = union[_n-1] if union==.
    bysort id (year):replace union = 1 if union[_n-1]==1
    bysort id (year):egen flag = sum(!missing(union))
    drop if flag==0
    replace union =0 if union==.
    bysort id: egen aux = min(year) if union==1
    bysort id:egen gvar = max(aux)
    
    did_imputation ln_wage id year gvar, horizons(0/15) pretrend(10) autosample
    
    di  e(pre_p)
    local df =   e(pre_df)
    
    qui test  pre1 pre2 pre3 pre4 pre5 pre6 pre7 pre8 pre9 pre10, df(`df')
    return list
    Res:
    Code:
    . di  e(pre_p)
    .00004583
    
    . local df =   e(pre_df)
    
    .
    . qui test  pre1 pre2 pre3 pre4 pre5 pre6 pre7 pre8 pre9 pre10, df(`df')
    
    . return list
    
    scalars:
                   r(drop) =  0
                   r(df_r) =  3268
                      r(F) =  3.769850804658899
                     r(df) =  10
                      r(p) =  .0000458331558073
    Last edited by Justin Niakamal; 02 Sep 2021, 18:23.

    Comment


    • #3
      Thanks Justin Niakamal
      Do you know how many days we need to test for pre-trend regarding daily data in common?

      Comment


      • #4
        There are likely no hard and fast rules. I don't know of any references, but the question is fairly broad and needs a bit more details (like N & T dimensions).

        Comment


        • #5
          Originally posted by Justin Niakamal View Post
          I don't know of any references, but think the question is too broad and needs a bit more details (like N & T dimensions).
          Justin Niakamal , N is 126 and T is 500

          Comment


          • #6
            Originally posted by Justin Niakamal View Post
            There are likely no hard and fast rules. I don't know of any references, but the question is fairly broad and needs a bit more details (like N & T dimensions).
            Hi Justin Niakamal which folder of https://friosavila.github.io/playing...ain_drdid.html that you found the code of testing above then?

            And I perform the test myself and see somethin gstrange here.

            If I run

            Code:
            did_imputation y country date ei,autosample fe(country date) controls($control_list) pretrend(10) maxit(30000) tol(0.001)
            di  e(pre_p)
            local df =   e(pre_df)
            
            qui test  pre1 pre2 pre3 pre4 pre5 pre6 pre7 pre8 pre9 pre10, df(`df')
            return list
            The result would be
            Code:
            . di  e(pre_p)
            .06730013
            
            . local df =   e(pre_df)
            
            . qui test  pre1 pre2 pre3 pre4 pre5 pre6 pre7 pre8 pre9 pre10, df(`df')
            
            . return list
            
            scalars:
                           r(drop) =  0
                           r(df_r) =  102
                              r(F) =  1.813787428247867
                             r(df) =  10
                              r(p) =  .0673001324711808
            But when I apply your code above, the result is different.

            Code:
            . test (pre1=0) (pre2=0) (pre3=0) (pre4=0) (pre5=0) (pre6=0) (pre7=0) (pre8=0) (pre9=0) (pre10=0) 
            
             ( 1)  pre1 = 0
             ( 2)  pre2 = 0
             ( 3)  pre3 = 0
             ( 4)  pre4 = 0
             ( 5)  pre5 = 0
             ( 6)  pre6 = 0
             ( 7)  pre7 = 0
             ( 8)  pre8 = 0
             ( 9)  pre9 = 0
             (10)  pre10 = 0
            
                       chi2( 10) =   18.14
                     Prob > chi2 =    0.0527
            Could you please let me know what is going on then?

            Comment


            • #7

              Hi Phuc,

              Your test is missing the df() call. That's why they don't match.

              Comment


              • #8
                Originally posted by Justin Niakamal View Post
                Hi Phuc,

                Your test is missing the df() call. That's why they don't match.
                Hi Justin Niakamal . Can I ask what does df() call mean then? Is it a must to have a df() in a paralell trend test?

                Comment


                • #9
                  Hi Phuc
                  I think there is a bit of a confusion here.
                  The idea of Pretrend test is to see if the "pre" coefficients are statistically equal to zero or not. I would have done that both jointly as well as individually (as you did).
                  Now, While the basic idea would be to do this using ALL pretrend periods, you can also do it using just a reasonable amount of data. With T=500, Perhaps 50 or 100? I don't think there is a rule of thumb. You have to decide what is reasonable.

                  Regarding on why the statistics are different? Because without adjusting for Degrees of freedom, -test- uses a chi2, otherwise, uses an F statistic. They will be different, but will converge as sample increases.
                  HTH

                  Comment

                  Working...
                  X