Announcement

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

  • pretrends--command written by Jonathen ROth

    Hi there,

    Does anyone have experience with the "pretrends" command (https://github.com/mcaceresb/stata-pretrends#pretrends). I am trying to implement it with the code below but it really won't run. My data set is not that large (a couple thousand observations) and I left it over night and it was still working. I am wondering if something is wrong in my intuition. I tried it with reghdfe as well and that didn't seem to work. Thanks in advance.

    Code:
    preserve
    keep if age>=17 & age<=23
    *pretrend analysis
    gen rel_date0=0
    gen rel_date1=0
    gen rel_date2=0
    gen rel_date3=0
    gen rel_date4=0
    gen rel_date5=0
    gen rel_date6=0
    gen rel_date7=0
    gen rel_date8=0
    gen rel_date9=0
    gen rel_date10=0
    gen rel_date11=0
    gen rel_date12=0
    gen rel_date13=0
    gen rel_date14=0
    gen rel_date15=0
    
    
    replace rel_date0=1 if time==`=tm(2022m6)'
    replace rel_date1=1 if time==`=tm(2022m7)'
    replace rel_date2=1 if time==`=tm(2022m8)'
    replace rel_date3=1 if time==`=tm(2022m9)'
    replace rel_date4=1 if time==`=tm(2022m10)'
    replace rel_date5=1 if time==`=tm(2022m11)'
    replace rel_date6=1 if time==`=tm(2022m12)'
    replace rel_date7=1 if time==`=tm(2023m1)'
    replace rel_date8=1 if time==`=tm(2023m2)'
    replace rel_date9=1 if time==`=tm(2023m3)'
    replace rel_date10=1 if time==`=tm(2023m4)'
    replace rel_date11=1 if time==`=tm(2023m5)'
    replace rel_date12=1 if time==`=tm(2023m6)'
    replace rel_date13=1 if time==`=tm(2023m7)'
    replace rel_date14=1 if time==`=tm(2023m8)'
    replace rel_date15=1 if time==`=tm(2023m9)'
    
    *reldatexage
    foreach x of numlist 0/15 {
        gen rel_x_age`x'=rel_date`x'*age2
    }
    
    label var rel_date0 "-12"
    label var rel_date1 "-11"
    label var rel_date2 "-10"
    label var rel_date3 "-9"
    label var rel_date4 "-8"
    label var rel_date5 "-7"
    label var rel_date6 "-6"
    label var rel_date7 "-5"
    label var rel_date8 "-4"
    label var rel_date9 "-3"
    label var rel_date10 "-2"
    label var rel_date11 "-1"
    label var rel_date12 "0"
    label var rel_date13 "1"
    label var rel_date14 "2"
    label var rel_date15 "3"
    
    foreach v of varlist hi_ed  da_all mh_all mh_inpatient mh_crisis mh_outpatient jpo_all acj_jail_all_act_ind hous_all hous_emerg hous_prevent padhs_all padhs_snap padli_ui_benefits_act_ind ccac_all bhs_all total_day  {
    areg `v' rel_x_age0-rel_x_age9 o.rel_x_age11 rel_x_age12-rel_x_age15 rel_date0-rel_date15 c.age2 i.time, absorb(mci)
    pretrends power 0.8, pre(1/11) post(12/15)
    coefplot, keep(rel_x_age*) vertical base omitted msymbol(diamond) ///
            xtitle("Time") ytitle("`V'")  title("`v'") ///
            mcolor("106 208 200") ciopts(lcolor("118 152 160")) ///
            yline(0,lcolor("106 208 200") lpattern(dash)) xline(11.5, ///
            lpattern(dash) lcolor(red)) scale(.8) xsize(9) ysize(7) ///
            graphregion(fcolor(white) ifcolor(white) ilcolor(white)) ///
            xscale(lcolor("0 51 102")) yscale(lcolor("0 51 102")) coeflabels(, truncate(10) angle(45)) ///
            xlabel(, labcolor("0 51 102") noticks)
    graph save "`home'eventstudy_`v'_3m_2", replace
    graph export "`home'eventstudy`v'_3m_2.png", as(png) replace
    }

  • #2
    It's not usually possible to debug without knowing what type of issue you're having. My only guess is that you might want to include the -omit- option and see if that works, but otherwise you don't even specify what the error is, exactly.

    Comment


    • #3
      So, no error shows up--it is just that I left this to run all night and it still didn't complete. Wheel still spinning, etc! So I feel like there is something wrong here.

      Comment


      • #4
        Ok, I redownloaded it from github (the newer version of it, looks like I may have had an old version). Same code, but now I get:

        warning: option b() detected without option vcov()
        PreTrendsPower(): Power level 80% too low; please increase power.
        PreTrendsPower(): 198 Stata returned error
        PreTrends(): - function returned error
        <istmt>: - function returned error

        Comment


        • #5
          If you post the estimates I can check it out (b and V).

          Comment


          • #6
            I am using pre-trends package. My code is as follows.

            pretrends, pre(1/2) post(4/7) b(beta) v(sigma) slope(`r(slope)')
            coefplot name(honest_graph, replace) title("Sensitivity of Treatment Effect to Trend Violations")

            I just wanted to know how the include scalars to show in the default graph of this command. Following are the ddetails.

            . return list

            scalars:
            r(LR) = .1139622787284402
            r(Bayes) = .6269053180434926
            r(Power) = .4332768226911979
            r(slope) = 2.292209914611234

            I will be obliged of your guidance

            Comment


            • #7
              You can put them in a note on the graph, using the -note()- option as a passthru. The issue is building the note itself. So you will have to decide on things like how many decimal places you want to show, and whether you want all four statistics on a single line, or you want to use several lines. To illustrate the approach, here's how you would do it with 2 decimal places with LR and Bayes on the first line, and Power and Slope on the second:

              Code:
              pretrends, pre(1/2) post(4/7) b(beta) v(sigma) slope(`r(slope)')
              local note1 LR = `:display %3.2f `r(LR)'', Bayes = `:display %3.2f `r(Bayes)''
              local note2 Power = `:display %3.2f `r(Power)'', Slope = `:display %3.2f `r(slope)''
              local note `""`note1'" "`note2'""'
              
              coefplot name(honest_graph, replace) title("Sensitivity of Treatment Effect to Trend Violations") note(`note')
              Pay careful attention to the use of backtick (`), single quote (') and compound double quote (`"..."') in the code shown. And although it is somewhat hard to distinguish visually, remember that a sequence of two single quote characters ('') is not the same thing as a double quote (").

              Comment


              • #8
                Clyde Schechter ... Thank you for your response...I apologize for the delay reply....much appreciated

                Comment

                Working...
                X