Announcement

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

  • Thanks FernandoRios for the response. Yes, I have installed the drdid and csdid both. Sorry I could not get your next question. I have attached the full data in the previous post. As mentioned in the code, I have used Date as the time series variable and SCAP_Date as the gvar. I am not even sure if these are used and setup correctly. Thanks again for your time.

    Comment


    • Ok
      I haven’t seen the data yet but based on the screen shot
      data is not correctly setup
      Unless you are using daily data, try changing the scale of that variable to your preferred frequency
      recreate the gvar
      and then show me a two way table. Between time variable and group variable( time gvar)
      thanks

      Comment


      • Thanks FernandoRios . I have attached my datafile here. Main time variable id is Date (quarterly frequency) and the firm level id is GVKey. The dummy variable SCAP takes the value of '1' if a State has implemented a certain law (treatment), else it takes a value of '0' if it never implemented such a law in the sample time-period. The variable SCAP_Date shows the dates on which the law was implemented by a particular State (different dates for different states), else it takes the value of '0' if the law was never implemented. I have another dummy variable POST_SCAP which takes the value of '1' only after a state has implemented the law else it remains 0. Sorry, I am not able to create gvar. Should it be POST_SCAP?
        Attached Files

        Comment


        • Your data needs lots of work
          1. your gvar is defined (based on your definition) by scap_date (the time when people were treated)
          2. some of you "gvkey's" have more than one Scap_date data(never or an actual date) you need to clean that and define which one is correct, or drop them
          3. Your data is currently in days. need to transform everything into year-quarters, to make the data managle.
          HTH
          A quick clean up may produce this:
          F
          Click image for larger version

Name:	Graph.png
Views:	1
Size:	38.2 KB
ID:	1723487

          Comment


          • Alternatively, if you think your post_scap is correct, you can try using xthdidregress, (stata 18) which will make the necessary corrections for you (although you still need to modify your data variable

            Comment


            • Originally posted by FernandoRios View Post
              Hi Sandra
              ok so
              Not sure why you cant run the model without covariates. I just reinstalled a version on my machine (using fra install) and I'm able to use it without controls.
              Inregards to calendar. It is the Group /cohort specific Treatment effect.
              Event is the average of the effects with respect to the relative year

              Finally for group specific plots

              ssc install frause, replace
              fra install csdid2, replace

              clear all
              frause mpdta

              csdid2 lemp, ivar(countyreal) tvar(year) gvar(first) long
              estat event, rgroup(2004) plot
              estat event, rgroup(2006) plot
              estat event, rgroup(2007) plot

              Hope this helps
              Fernando
              Hi Fernando,

              I'm having some trouble getting csdid2 installed. I'm getting the following result:

              . ssc install frause, replace
              checking frause consistency and verifying not already installed...
              all files already exist and are up to date.

              . fra install csdid2, replace
              command fra is unrecognized
              r(199);

              Comment


              • Oops sorry for that.
                Please follow the instructions here https://friosavila.github.io/chatgpt/fra_03_30_2023/
                to install "fra"
                then you can install csdid2.
                F

                Comment


                • Hi FernandoRios, oops, me again. I hope you are doing well. I'm having problems with csdid and csdid2 again.

                  I've just updated to Stata 18, but for some reason, I cannot reproduce my results on csdid2 using fixed effects because csdid2 gives the same results with/without fixed effects. Not sure what is happening because I cant open the saved ster files with the estimates either.


                  Code:
                  csdid2 scores overage maeduc i.stateid  if treat==1, tvar(year) gvar(cohortuf) method(dripw) agg(simple) cluster(schoolid)
                  Producing Long Gaps by default
                  ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
                  .....
                  Difference-in-difference with Multiple Time Periods
                  Outcome model  : least squares
                  Treatment model: inverse probability
                  ------------------------------------------------------------------------------
                               |               Robust
                               | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                     SimpleATT |   .0510869    .002529    20.20   0.000     .0461303    .0560436
                  ------------------------------------------------------------------------------
                  
                  . estat event
                  ------------------------------------------------------------------------------
                               | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                       Pre_avg |   .0205535   .0033877     6.07   0.000     .0139138    .0271932
                      Post_avg |   .0500537   .0025308    19.78   0.000     .0450934    .0550139
                           tm2 |   .0205535   .0033877     6.07   0.000     .0139138    .0271932
                           tp0 |   .0097071   .0032017     3.03   0.002     .0034318    .0159823
                           tp1 |   .0576214    .003083    18.69   0.000     .0515788     .063664
                           tp2 |   .0496524   .0030823    16.11   0.000     .0436111    .0556937
                           tp3 |   .0832337   .0030235    27.53   0.000     .0773078    .0891596
                  ------------------------------------------------------------------------------
                  
                  . 
                  
                  csdid2 scores overage maeduc if treat==1, tvar(year) gvar(cohortuf) method(dripw) agg(simple) cluster(schoolid)
                  Producing Long Gaps by default
                  ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
                  .....
                  Difference-in-difference with Multiple Time Periods
                  Outcome model  : least squares
                  Treatment model: inverse probability
                  ------------------------------------------------------------------------------
                               |               Robust
                               | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                     SimpleATT |   .0510869    .002529    20.20   0.000     .0461303    .0560436
                  ------------------------------------------------------------------------------
                  
                  . estat event
                  ------------------------------------------------------------------------------
                               | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                       Pre_avg |   .0205535   .0033877     6.07   0.000     .0139138    .0271932
                      Post_avg |   .0500537   .0025308    19.78   0.000     .0450934    .0550139
                           tm2 |   .0205535   .0033877     6.07   0.000     .0139138    .0271932
                           tp0 |   .0097071   .0032017     3.03   0.002     .0034318    .0159823
                           tp1 |   .0576214    .003083    18.69   0.000     .0515788     .063664
                           tp2 |   .0496524   .0030823    16.11   0.000     .0436111    .0556937
                           tp3 |   .0832337   .0030235    27.53   0.000     .0773078    .0891596
                  ------------------------------------------------------------------------------

                  I can't figure out what's happening. I 've installed all packages, wondering if it is an update of csdid2 or in one of the packages.


                  Another problem: when I use csdid instead, I get the an error message

                  . csdid scores overage maeduc i.stateid if treat==1 , time(year) gvar(cohortuf ) method(dripw) agg(simple)
                  xxxxxestimates post: matrix has missing values
                  r(504);

                  I'm sure there must be something I'm missing. Thank you so much for helping.


                  Comment


                  • I think it’s doing what is supposed to
                    my best guess is that your treatment is at the state level
                    thus you can’t use state as fixed effect.
                    csdid is showing that by refusing to produce results
                    csdid2 is a bit smarter and tries to drop all Collinear variables before running a model
                    hth

                    Fernando

                    Comment


                    • Originally posted by FernandoRios View Post
                      I think it’s doing what is supposed to
                      my best guess is that your treatment is at the state level
                      thus you can’t use state as fixed effect.
                      csdid is showing that by refusing to produce results
                      csdid2 is a bit smarter and tries to drop all Collinear variables before running a model
                      hth

                      Fernando
                      oh FernandoRios, YES indeed. Why do we inadvertently (or conveniently) need to stick fixed effects in all specifications? LOL It was a stupid question, but I am glad I asked. Thanks a lot for clarifying. (BUT it did work before...)

                      Comment


                      • Dear Fernando,

                        someone already asked in March 2022 whether it is possible to interact the treatment variable in csdid with another variable, e.g. gender, and you replied that this is not possible. That's why I tried to use sample splits and compare treatment effects across different groups (e.g. male vs. female) by first estimating the treatment effect for each group separately and then testing, whether the difference in treatment effects between the two groups is statistically significant.

                        However, the code that I posted below does not seem to work - I keep getting an error message when using the suest command (and I found online that suest may not work with all user-written packages - but I may also be doing something wrong):
                        unable to generate scores for model Female
                        suest requires that predict allow the score option
                        r(322);

                        Code:
                           
                        csdid     $outcome if female==1 [iw = wgt], time(tvar_new) gvar(gvar_new) notyet method(reg) agg(simple)
                            estat simple
                            qui: matrix col2=r(table)
                            qui: matrix list col2
                            eststo Female
                           
                            csdid     $outcome if female == 0 [iw = wgt], time(tvar_new) gvar(gvar_new) notyet method(reg) agg(simple)
                            estat simple
                            qui: matrix col3=r(table)
                            qui: matrix list col3
                            eststo Male
                        
                        suest Female Male, vce(cl year_district_id)
                        test ...
                        Do you have any advice on how I can use the csdid results and compare them with a post-estimation command?

                        Thanks a lot in advance!

                        Kind regards,
                        Anne

                        Comment


                        • Hi Anne,
                          No easily answer unfortunately.
                          If you want to have the ability of further clustering results (as you seem to want to do ), you have to create separate RIFs for men and women, merge samples, and then try draw inference.
                          I have a pdf that perhaps may be useful
                          F
                          Attached Files

                          Comment


                          • Hi Fernando,

                            that's exactly what I needed, thanks a lot. Of course it's a bit more complicated but looks like a neat solution - will try it that way!

                            Best,
                            Anne

                            Comment


                            • Thank you so much for writing the wonderful csdid FernandoRios! I started using it recently and it is just great! This may be a very simple question but I am struggling to interpret various pre-trend tests that the program spit out. I have following results after estimation:
                              estat all
                              Test will be based on asymptotic VCoV
                              If you want aggregations based on WB, use option saverif() ad csdid_stats
                              Pretrend Test. H0 All Pre-treatment are equal to 0
                              chi2(45) = 81.7403
                              p-value = 0.0007

                              and then following:
                              *Producing a simple Plot for last results. Two different styles
                              . estat event, window(-9 9)
                              Test will be based on asymptotic VCoV
                              If you want aggregations based on WB, use option saverif() ad csdid_stats
                              ATT by Periods Before and After treatment
                              Event Study:Dynamic effects
                              ------------------------------------------------------------------------------
                              | Coefficient Std. err. z P>|z| [95% conf. interval]
                              -------------+----------------------------------------------------------------
                              Pre_avg | 1.377292 1.249099 1.10 0.270 -1.070898 3.825482
                              Post_avg | 12.49752 5.192085 2.41 0.016 2.32122 22.67382
                              Tm9 | -8.080732 7.265344 -1.11 0.266 -22.32054 6.15908
                              Tm8 | 5.598478 5.353457 1.05 0.296 -4.894104 16.09106
                              Tm7 | -2.086951 3.468995 -0.60 0.547 -8.886055 4.712154
                              Tm6 | 4.414266 3.246138 1.36 0.174 -1.948048 10.77658
                              Tm5 | -1.489702 2.190728 -0.68 0.497 -5.783451 2.804047
                              Tm4 | .2051074 2.022997 0.10 0.919 -3.759894 4.170109
                              Tm3 | 3.786438 2.131636 1.78 0.076 -.3914916 7.964367
                              Tm2 | 8.519847 2.240238 3.80 0.000 4.129062 12.91063
                              Tm1 | 1.528876 1.548208 0.99 0.323 -1.505555 4.563307
                              Tp0 | -1.345033 1.9418 -0.69 0.489 -5.150891 2.460825
                              Tp1 | 4.807234 2.515641 1.91 0.056 -.1233311 9.737799
                              Tp2 | 8.066187 3.037854 2.66 0.008 2.112102 14.02027
                              Tp3 | 14.20465 3.46684 4.10 0.000 7.409768 20.99953
                              Tp4 | 13.06161 4.38758 2.98 0.003 4.46211 21.66111
                              Tp5 | 18.62453 5.329493 3.49 0.000 8.178916 29.07014
                              Tp6 | 21.59786 6.454643 3.35 0.001 8.946991 34.24873
                              Tp7 | 17.31846 8.301969 2.09 0.037 1.046902 33.59002
                              Tp8 | 13.76577 11.6833 1.18 0.239 -9.133085 36.66462
                              Tp9 | 14.87394 20.70136 0.72 0.472 -25.69998 55.44786

                              My understanding is that the first test above rejects PTA and the second the 'Pre-avg' does not reject PTA. Then you have, apparently, for PTA for individual years in the form of Tmx and for some of those years, PTA is rejected. Based on the first pre-test, I cannot really interpret my results as causal, and then based on Pre_avg, I can. Then I have individual years giving me mixed pre-tests results. Can you help me? Thank you so much.

                              Comment


                              • Well, the pre-trend test is very restrictive.
                                the one you see in the event aggregation is not a pre-trend test perse. Just shows the average effect over all pre-trend periods.
                                Perhaps something you can do is simply test all pre-trend values using -test-
                                HTH
                                fernando

                                Comment

                                Working...
                                X