Announcement

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

  • omitted because of collinearity for eventdd result

    When I try to use eventdd to construct the simplest event study plot, I don't know why the date dummy become omitted and return a blank graph
    Here is the code and data I used

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str20 state byte fips float date double p_bar float(tdate diff)
    "Alabama" 1 708  814 733 -25
    "Alabama" 1 709  856 733 -24
    "Alabama" 1 710  883 733 -23
    "Alabama" 1 711  824 733 -22
    "Alabama" 1 712  792 733 -21
    "Alabama" 1 713  685 733 -20
    "Alabama" 1 714  604 733 -19
    "Alabama" 1 715  322 733 -18
    "Alabama" 1 716   35 733 -17
    "Alabama" 1 717   30 733 -16
    "Alabama" 1 718   38 733 -15
    "Alabama" 1 719   38 733 -14
    "Alabama" 1 720  983 733 -13
    "Alabama" 1 721  885 733 -12
    "Alabama" 1 722  616 733 -11
    "Alabama" 1 723  387 733 -10
    "Alabama" 1 724  711 733  -9
    "Alabama" 1 725  290 733  -8
    "Alabama" 1 726  232 733  -7
    "Alabama" 1 727  204 733  -6
    "Alabama" 1 728   57 733  -5
    "Alabama" 1 729   46 733  -4
    "Alabama" 1 730   38 733  -3
    "Alabama" 1 731   29 733  -2
    "Alabama" 1 732  810 733  -1
    "Alabama" 1 733 1066 733   0
    "Alabama" 1 734 1306 733   1
    "Alabama" 1 735 1338 733   2
    "Alabama" 1 736 1271 733   3
    "Alabama" 1 737 1169 733   4
    "Alabama" 1 738 1277 733   5
    "Alabama" 1 739 1047 733   6
    "Alabama" 1 740 1126 733   7
    "Alabama" 1 741 1295 733   8
    "Alabama" 1 742 1237 733   9
    "Alabama" 1 743 1186 733  10
    "Alabama" 1 744 1751 733  11
    "Alabama" 1 745 1711 733  12
    "Alabama" 1 746 2265 733  13
    "Alabama" 1 747 2112 733  14
    "Alabama" 1 748 2165 733  15
    "Alabama" 1 749 1979 733  16
    "Alabama" 1 750 1896 733  17
    "Alabama" 1 751 2054 733  18
    "Alabama" 1 752 2023 733  19
    "Alabama" 1 753 1946 733  20
    "Alabama" 1 754 1818 733  21
    "Alabama" 1 755 1832 733  22
    "Alaska"  2 708   71 733 -25
    "Alaska"  2 709   60 733 -24
    "Alaska"  2 710   82 733 -23
    "Alaska"  2 711   99 733 -22
    "Alaska"  2 712   88 733 -21
    "Alaska"  2 713   55 733 -20
    "Alaska"  2 714   90 733 -19
    "Alaska"  2 715   87 733 -18
    "Alaska"  2 716   92 733 -17
    "Alaska"  2 717   75 733 -16
    "Alaska"  2 718   70 733 -15
    "Alaska"  2 719   66 733 -14
    "Alaska"  2 720   64 733 -13
    "Alaska"  2 721   62 733 -12
    "Alaska"  2 722   59 733 -11
    "Alaska"  2 723   41 733 -10
    "Alaska"  2 724   64 733  -9
    "Alaska"  2 725   47 733  -8
    "Alaska"  2 726   67 733  -7
    "Alaska"  2 727   64 733  -6
    "Alaska"  2 728   67 733  -5
    "Alaska"  2 729   66 733  -4
    "Alaska"  2 730   37 733  -3
    "Alaska"  2 731   53 733  -2
    "Alaska"  2 732   59 733  -1
    "Alaska"  2 733   53 733   0
    "Alaska"  2 734   74 733   1
    "Alaska"  2 735   99 733   2
    "Alaska"  2 736   67 733   3
    "Alaska"  2 737   70 733   4
    "Alaska"  2 738   77 733   5
    "Alaska"  2 739   72 733   6
    "Alaska"  2 740   52 733   7
    "Alaska"  2 741   65 733   8
    "Alaska"  2 742   48 733   9
    "Alaska"  2 743   63 733  10
    "Alaska"  2 744   51 733  11
    "Alaska"  2 745   30 733  12
    "Alaska"  2 746   46 733  13
    "Alaska"  2 747   53 733  14
    "Alaska"  2 748   50 733  15
    "Alaska"  2 749   46 733  16
    "Alaska"  2 750   50 733  17
    "Alaska"  2 751   47 733  18
    "Alaska"  2 752   55 733  19
    "Alaska"  2 753   30 733  20
    "Alaska"  2 754   46 733  21
    "Alaska"  2 755   39 733  22
    "Arizona" 4 708 2389 733 -25
    "Arizona" 4 709 2306 733 -24
    "Arizona" 4 710 2575 733 -23
    "Arizona" 4 711 2484 733 -22
    end
    format %tmCCYY/NN date
    format %tm tdate
    label values fips fips
    label def fips 1 "Alabama", modify
    label def fips 2 "Alaska", modify
    label def fips 4 "Arizona", modify



    Code:
    gen tdate =  ym(2021,2)
    
    gen diff = date - tdate
    
    format tdate %tm
    
    
    xtset fips date
    eventdd p_bar i.date, timevar(diff) method(fe, cluster(fips))
    And the result pops the omitted for every leads and lags:

    Code:
    . eventdd p_bar i.date, timevar(diff) method(fe, cluster(fips))
    note: lead25 omitted because of collinearity
    note: lead24 omitted because of collinearity
    note: lead23 omitted because of collinearity
    note: lead22 omitted because of collinearity
    note: lead21 omitted because of collinearity
    note: lead20 omitted because of collinearity
    note: lead19 omitted because of collinearity
    note: lead18 omitted because of collinearity
    note: lead17 omitted because of collinearity
    note: lead16 omitted because of collinearity
    note: lead15 omitted because of collinearity
    note: lead14 omitted because of collinearity
    note: lead13 omitted because of collinearity
    note: lead12 omitted because of collinearity
    note: lead11 omitted because of collinearity
    note: lead10 omitted because of collinearity
    note: lead9 omitted because of collinearity
    note: lead8 omitted because of collinearity
    note: lead7 omitted because of collinearity
    ...

  • #2
    don't use i.date, but date, but I think eventdd includes a time fe in estimation.

    Comment


    • #3
      Originally posted by George Ford View Post
      don't use i.date, but date, but I think eventdd includes a time fe in estimation.
      Hello George,

      Thank you, but do you suggest to add date if I want to include the time fixed effect?

      Also, the reason why I use i.date is because in the example they provide in the stata document

      Code:
            Load data that replicates Stevenson and Wolfers' (2006) analysis of no-fault divorce reforms and female suicide, circulated with the bacondecomp command.
      
          . webuse set www.damianclarke.net/stata/
      
          . webuse bacon_example.dta, clear
      
          Estimate a baseline two-way fixed effect DD model of female suicide on no-fault divorce reforms.
      
          . xtreg asmrs post pcinc asmrh cases i.year, fe cluster(stfips)
      
          Generate standarized event-time variable giving time until passage of event for each state
      
          . gen timeToTreat = year - _nfd
      
          Generate the event study plot associated to DD model of female suicide on no-fault divorce reforms with all periods.
      
          . eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) graph_op(ytitle("Suicides per 1m Women") xlabel(-20(5)25))
      
          Generate the event study plot associated to DD model of female suicide on no-fault divorce reforms with all periods but only showing balanced periods in plot.
      
          . eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) balanced graph_op(ytitle("Suicides per 1m Women"))
      
          Generate the event study plot associated to DD model of female suicide on no-fault divorce reforms only using balanced observations in the specified period.
      
          . eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) keepbal(stfips) leads(6) lags(14) graph_op(ytitle("Suicides per 1m Women"))
      Last edited by Wenhan Yan; 15 May 2024, 00:33.

      Comment


      • #4
        Just rewrite the code for one equation

        Comment


        • #5
          Originally posted by George Ford View Post
          Just rewrite the code for one equation
          Data example I use:

          Code:
           * Example generated by -dataex-. For more info, type help dataex
          clear
          input str20 state byte fips float date double p_bar float(tdate diff)
          "Alabama" 1 708  814 733 -25
          "Alabama" 1 709  856 733 -24
          "Alabama" 1 710  883 733 -23
          "Alabama" 1 711  824 733 -22
          "Alabama" 1 712  792 733 -21
          "Alabama" 1 713  685 733 -20
          "Alabama" 1 714  604 733 -19
          "Alabama" 1 715  322 733 -18
          "Alabama" 1 716   35 733 -17
          "Alabama" 1 717   30 733 -16
          "Alabama" 1 718   38 733 -15
          "Alabama" 1 719   38 733 -14
          "Alabama" 1 720  983 733 -13
          "Alabama" 1 721  885 733 -12
          "Alabama" 1 722  616 733 -11
          "Alabama" 1 723  387 733 -10
          "Alabama" 1 724  711 733  -9
          "Alabama" 1 725  290 733  -8
          "Alabama" 1 726  232 733  -7
          "Alabama" 1 727  204 733  -6
          "Alabama" 1 728   57 733  -5
          "Alabama" 1 729   46 733  -4
          "Alabama" 1 730   38 733  -3
          "Alabama" 1 731   29 733  -2
          "Alabama" 1 732  810 733  -1
          "Alabama" 1 733 1066 733   0
          "Alabama" 1 734 1306 733   1
          "Alabama" 1 735 1338 733   2
          "Alabama" 1 736 1271 733   3
          "Alabama" 1 737 1169 733   4
          "Alabama" 1 738 1277 733   5
          "Alabama" 1 739 1047 733   6
          "Alabama" 1 740 1126 733   7
          "Alabama" 1 741 1295 733   8
          "Alabama" 1 742 1237 733   9
          "Alabama" 1 743 1186 733  10
          "Alabama" 1 744 1751 733  11
          "Alabama" 1 745 1711 733  12
          "Alabama" 1 746 2265 733  13
          "Alabama" 1 747 2112 733  14
          "Alabama" 1 748 2165 733  15
          "Alabama" 1 749 1979 733  16
          "Alabama" 1 750 1896 733  17
          "Alabama" 1 751 2054 733  18
          "Alabama" 1 752 2023 733  19
          "Alabama" 1 753 1946 733  20
          "Alabama" 1 754 1818 733  21
          "Alabama" 1 755 1832 733  22
          "Alaska"  2 708   71 733 -25
          "Alaska"  2 709   60 733 -24
          "Alaska"  2 710   82 733 -23
          "Alaska"  2 711   99 733 -22
          "Alaska"  2 712   88 733 -21
          "Alaska"  2 713   55 733 -20
          "Alaska"  2 714   90 733 -19
          "Alaska"  2 715   87 733 -18
          "Alaska"  2 716   92 733 -17
          "Alaska"  2 717   75 733 -16
          "Alaska"  2 718   70 733 -15
          "Alaska"  2 719   66 733 -14
          "Alaska"  2 720   64 733 -13
          "Alaska"  2 721   62 733 -12
          "Alaska"  2 722   59 733 -11
          "Alaska"  2 723   41 733 -10
          "Alaska"  2 724   64 733  -9
          "Alaska"  2 725   47 733  -8
          "Alaska"  2 726   67 733  -7
          "Alaska"  2 727   64 733  -6
          "Alaska"  2 728   67 733  -5
          "Alaska"  2 729   66 733  -4
          "Alaska"  2 730   37 733  -3
          "Alaska"  2 731   53 733  -2
          "Alaska"  2 732   59 733  -1
          "Alaska"  2 733   53 733   0
          "Alaska"  2 734   74 733   1
          "Alaska"  2 735   99 733   2
          "Alaska"  2 736   67 733   3
          "Alaska"  2 737   70 733   4
          "Alaska"  2 738   77 733   5
          "Alaska"  2 739   72 733   6
          "Alaska"  2 740   52 733   7
          "Alaska"  2 741   65 733   8
          "Alaska"  2 742   48 733   9
          "Alaska"  2 743   63 733  10
          "Alaska"  2 744   51 733  11
          "Alaska"  2 745   30 733  12
          "Alaska"  2 746   46 733  13
          "Alaska"  2 747   53 733  14
          "Alaska"  2 748   50 733  15
          "Alaska"  2 749   46 733  16
          "Alaska"  2 750   50 733  17
          "Alaska"  2 751   47 733  18
          "Alaska"  2 752   55 733  19
          "Alaska"  2 753   30 733  20
          "Alaska"  2 754   46 733  21
          "Alaska"  2 755   39 733  22
          "Arizona" 4 708 2389 733 -25
          "Arizona" 4 709 2306 733 -24
          "Arizona" 4 710 2575 733 -23
          "Arizona" 4 711 2484 733 -22
          end
          format %tmCCYY/NN date
          format %tm tdate
          label values fips fips
          label def fips 1 "Alabama", modify
          label def fips 2 "Alaska", modify
          label def fips 4 "Arizona", modify
          Here is the code from the document which use i.year and successfully get the result.

          Code:
          
          *Load data that replicates Stevenson and Wolfers' (2006) analysis of no-fault divorce reforms and female suicide, circulated with the bacondecomp command.    
          
           
          use "https://raw.githubusercontent.com/LOST-STATS/LOST-STATS.github.io/master/Model_Estimation/Data/Event_Study_DiD/bacon_example.dta", clear    
          
          
          *Estimate a baseline two-way fixed effect DD model of female suicide on no-fault divorce reforms.      
          
          xtreg asmrs post pcinc asmrh cases i.year, fe cluster(stfips)      
          
          *Generate standarized event-time variable giving time until passage of event for each state    
          
           gen timeToTreat = year - _nfd      
          
          eventdd asmrs pcinc asmrh cases i.year, timevar(timeToTreat) method(fe, cluster(stfips)) keepbal(stfips) leads(6) lags(14) graph_op(ytitle("Suicides per 1m Women"))
          But when I use i.date instead of date with my data, I get a blank output.


          Code:
          gen time_to_treat =  ym(2021,2) if state_abb == "OR"
          gen diff = date - time_to_treat
          format time_to_treat %tm
          xtset fips date
          eventdd p_bar date, timevar(diff) method(fe, cluster(fips))
          Last edited by Wenhan Yan; 15 May 2024, 07:58.

          Comment


          • #6
            sorry. when you use
            Code:
            method(hdfe, absorb(fips date)
            it absorbs the time fixed effect (but reghdfe must be installed).

            do you have controls (time2treat == .)?

            I added one to your data and it works with a control.



            Comment

            Working...
            X