Announcement

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

  • Estat trendplots takes hours

    Help needed!

    I am trying to graph my pre and post-treatment period trends but it has been loading for hours and I am not sure if it will ever give me any output. This is about the fourth time I have tried it with me trying it for 30 minutes up to 2.5 hours without STATA providing me with the graphs.

    My did command is as follows: didregress (hospitalcosts i.age i.year i.gender i.postalcode) (treatpost), group (age) time (year)

    If I run estat ptrends it also takes a little while but it gives me some output. My data spans over 10 years and the dataset is rather large, I have 1.5 million observations.

    Does anyone have any ideas on how to reduce the loading time? Will STATA ever provide me the parallel trends graphs? Thank you so much in advance!
    Last edited by Leon Broos; 29 May 2024, 07:24. Reason: parallel trends

  • #2
    Is your dataset a panel dataset at the post-code level? If so, see

    Code:
    help xtdidregress
    instead of using indicators and didregress.

    Comment


    • #3
      Andrew Musau if I were to set it as panel data it would be grouped at the age, gender & postal code level. My observations are for all people in a country but grouped for age, gender & area (= postal code). Do you think changing it to a panel and running it as an xtdidregress would help? I have tried doing so with a panelid variable but now even the xtdidregress command is already taking 20 minutes. I am a little lost.

      Comment


      • #4
        How many postcodes do you have and how many age groups are present? To reduce runtime, it would be sensible to absorb the larger of these.

        Comment


        • #5
          Andrew Musau I have 800 postcodes and 91 age groups. If I were to absorb these are you still talking about running an xtdid or a regular did model?
          ​​​​​​​

          Comment


          • #6
            I mean:

            Code:
            xtset postalcode
            xtdidregress (hospitalcosts i.age i.year i.gender) (treatpost), group (postalcode) time (year)
            Check that the ATE is the same across both specifications.

            Comment


            • #7
              Andrew Musau Thank you so much! The ATE does indeed appear to be the same. However, still it takes a very long time to estat trendplots. Is there any way around this? And is it normal for STATA to take +2.5 hours? Should I just let it run all night?

              Comment


              • #8
                This is the best you can do with the did set of commands at present. You could use xtreg in StataNow as it has an -absorb()- option or reghdfe from https://github.com/sergiocorreia/reghdfe to estimate the model. Then twoway to graph the parallel trends. For the tests, the formulas are given in the documentation of the commands.

                Comment

                Working...
                X