Announcement

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

  • Need help with DID fault code: None of the groups defined by group is a control.

    I'm trying to make my first DID regression on STATA for my economics course.

    You can see my variables in the photo below. Price shows log price of property's. Time is my time variable. Then I have treatment variable that takes the value 0 before the treatment and 1 after the treatment. Lastly I have. group variable that takes value 0 for the control group, and 1 for the treatment group.
    Then I try to perform the DID manually in statistics. I put in price as dependent variable, time as: time variable, treatment as treatment variable, and group as group variable. I also run a binary DID. But when I then proceed I get the fault: None of the groups defined by group is a control. Would be thankful if someone could help me






    Image 2023-10-16 at 15.04.jpeg


  • #2
    sounds like a data problem, but can't decipher that looking at four observations.

    I do see that the first two are treated==1 but group ==0, which would seem incorrect given your description.

    egen treated = max(treatment), by(whatever id you have)

    are the treated all treated at the same year? (if not, you've got other problems to deal with).

    If so,

    g post = year>=(year of treatment)

    reg price c.post#c.treated treated post

    as the simpest case.

    you can use fixed effects for id and year if you prefer that option and want to account for unobservables.

    reghdfe price c.post#c.treated , absorb(id year)




    Comment


    • #3
      The data runs from January 2008 until September 2023. The treatment happened October 2017. Before treatment variable is valued at 0, after at 1. Now I have changed it that the control group is 1 and the treatment group is 0. Im sorry but I dont really understand you answers, can you specify please?

      Comment


      • #4
        The group should be 1 for a treated cross section for all periods. Or create a treated variable:

        egen treated = max(treatment), by(id)

        Create a post variable = 1 starting at oct2017 and through end of sample for all observations.

        g post = date>=oct2017

        reg price c.post#c.treated treated post

        the coefficient on c.post#c.treated is your DID coefficient. the variable will equal 1 for any treated observation after the treatment is applied.

        the coefficient on treated tells you how different price was between the groups prior to the treatment, and the post variable tells you how the mean of all units changed after the treatment period begins.

        could also use xtdidregress. the group will be the cross section identifier, time is date, tvar is treatment.








        Comment


        • #5
          It worked when I put in the regression: reg price c.post#c.treated treated post so than you for that! But I still get the fault of no groups is defined by group is a control when I manually try to make the DID in the stata statistics options

          Comment


          • #6
            show the code and the results/errors

            Comment

            Working...
            X