Announcement

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

  • Insufficient Observations r(2001) in Stata SE 17.0 when attempting to use xtdidregress with binary treatment variable

    Hello. I am conducting a project examining the change in value of residential properties in areas before and after the certification of nearby commercial properties as LEED (sustainability certification), compared to control groups of residential properties that are not near these certified buildings.

    This requires a difference in differences test, which I have been trying unsuccessfully to conduct. Here is the line of code I have used:

    . xtdidregress (VALUE) (bb1), group(Location_numeric) time(post2018Q2)

    where bb1 = the treated property location, Location_numeric = the population of properties and post2018Q2 = binary indicator of treatment.

    I have been getting the following error: insufficient observations
    r(2001);

    It may be the case that I do not have enough observations (variables =30, observations = 6405) in the way my regression is currently listed - I am not sure and would really appreciate some guidance. But if it is the case that I have too few observations, is there any other way I can perform some type of difference in difference test and also test for parallel trends?

    Many thanks, Hugh. Below is some code. My panel id variable is unique_id and time variable is numeric_quarter

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double VALUE str13 NumberofBedrooms long(PropertyType_numeric Location_numeric) float(bb1 post2018Q2 unique_id numeric_quarter)
    1846.71 "1 to 3 bed" 4 1 0 1  1 28
    1802.75 "1 to 3 bed" 4 1 0 1  2 30
    1712.27 "1 to 2 bed" 4 1 0 1  3 31
    1798.23 "1 to 3 bed" 4 1 0 1  4 31
    1712.27 "Two bed"    4 1 0 1  5 31
    1823.27 "1 to 3 bed" 4 1 0 1  6 32
    1096.45 "1 to 3 bed" 1 2 0 0  7  3
    1094.67 "1 to 2 bed" 1 2 0 0  8  3
     1150.5 "1 to 3 bed" 1 2 0 0  9  4
    1153.59 "1 to 3 bed" 1 2 0 0 10  5
    1153.71 "1 to 2 bed" 1 2 0 0 11  5
    1171.79 "1 to 3 bed" 1 2 0 0 12  6
    1172.47 "1 to 2 bed" 1 2 0 0 13  6
    1194.97 "1 to 3 bed" 1 2 0 0 14  7
    1194.97 "1 to 2 bed" 1 2 0 0 15  7
    1654.97 "1 to 3 bed" 1 2 0 1 16 19
    1654.97 "1 to 2 bed" 1 2 0 1 17 19
    1412.95 "1 to 2 bed" 1 3 1 0 18  1
    1823.73 "1 to 3 bed" 4 3 1 0 19  1
    1181.77 "1 to 2 bed" 3 3 1 0 20  1
    end
    label values PropertyType_numeric PropertyType_numeric
    label def PropertyType_numeric 1 "Apartment", modify
    label def PropertyType_numeric 3 "Semi detached house", modify
    label def PropertyType_numeric 4 "Terrace house", modify
    label values Location_numeric Location_numeric
    label def Location_numeric 1 "Arbour Hill, Dublin 7", modify
    label def Location_numeric 2 "Aungier Street, Dublin 2", modify
    label def Location_numeric 3 "Ballsbridge, Dublin 4", modify





  • #2
    This data won't let you do DID. for DID, you need one period were all units are untreated and a second period where some units are treated. you don't have that, at least not in this data sample.

    Comment


    • #3
      Hi George. Thanks for the pointer and for getting back so quickly - I really appreciate it.

      I went and created variables for those two periods and added them to the code below.

      Variable 'alluntreatedlocations' = binary variable signifying all the locations (treated and untreated) in my dataset pre treatment period (2018Q2).
      Variable 'treatedloaction' - binary variable that equals 1 for observations of my treated location at and beyond 2018Q2.

      What steps should I take from here to perform a good difference in differences test? Many thanks again, Hugh


      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input double VALUE str13 NumberofBedrooms long(PropertyType_numeric Location_numeric) float(bb1 post2018Q2 unique_id numeric_quarter alluntreatedlocations treatedlocation)
      1846.71 "1 to 3 bed" 4 1 0 1  1 28 0 0
      1802.75 "1 to 3 bed" 4 1 0 1  2 30 0 0
      1712.27 "1 to 2 bed" 4 1 0 1  3 31 0 0
      1798.23 "1 to 3 bed" 4 1 0 1  4 31 0 0
      1712.27 "Two bed"    4 1 0 1  5 31 0 0
      1823.27 "1 to 3 bed" 4 1 0 1  6 32 0 0
      1096.45 "1 to 3 bed" 1 2 0 0  7  3 1 0
      1094.67 "1 to 2 bed" 1 2 0 0  8  3 1 0
       1150.5 "1 to 3 bed" 1 2 0 0  9  4 1 0
      1153.59 "1 to 3 bed" 1 2 0 0 10  5 1 0
      1153.71 "1 to 2 bed" 1 2 0 0 11  5 1 0
      1171.79 "1 to 3 bed" 1 2 0 0 12  6 1 0
      1172.47 "1 to 2 bed" 1 2 0 0 13  6 1 0
      1194.97 "1 to 3 bed" 1 2 0 0 14  7 1 0
      1194.97 "1 to 2 bed" 1 2 0 0 15  7 1 0
      1654.97 "1 to 3 bed" 1 2 0 1 16 19 0 0
      1654.97 "1 to 2 bed" 1 2 0 1 17 19 0 0
      1412.95 "1 to 2 bed" 1 3 1 0 18  1 1 0
      1823.73 "1 to 3 bed" 4 3 1 0 19  1 1 0
      1181.77 "1 to 2 bed" 3 3 1 0 20  1 1 0
      end
      label values PropertyType_numeric PropertyType_numeric
      label def PropertyType_numeric 1 "Apartment", modify
      label def PropertyType_numeric 3 "Semi detached house", modify
      label def PropertyType_numeric 4 "Terrace house", modify
      label values Location_numeric Location_numeric
      label def Location_numeric 1 "Arbour Hill, Dublin 7", modify
      label def Location_numeric 2 "Aungier Street, Dublin 2", modify
      label def Location_numeric 3 "Ballsbridge, Dublin 4", modify

      Comment


      • #4
        the unique_id are all unique. this is pooled cross section?

        there are no treated units in the data by treatedlocation.

        Comment


        • #5
          Hi George,

          Thanks for the response again. I have made an effort to understand what type of dataset it is that I am working on and what commands I can run for difference-in-difference testing.

          Here is what I have found:
          • I xtset my dataset to just the panel variable Location_numeric. If I were to include a time variable such as Quarters, it would return error 451 - repeated time values within panel. This is because for, say, a time of 2014Q1, I will have numerous observations for different types of property in the same location at the same time. E.g -> 1 bed apartment, 2 bed terraced house etc.
          • This returned an unbalanced panel, which I have been able to run the following xtdidregress command on:
            • xtdidregress (VALUE) (treatvar), group(Location_numeric) time(Quarters)
            • Where treatvar = treated group post treatment, Location_numeric = all my locations in the panel and Quarters = all quarters in the dataset. In words: examining the change in price of 1 bed apartments in treated location post treatment compared to all other properties in all other locations.
          • This is great, but I have not been able to find a way to add controls to the command to get a more granular result. I want to be able to do the following: examining the change in price of 1 bed apartments in treated location post treatment compared to 1 bed apartments in a specific control location. Is this possible with xtdidregress or do I need to consider a different fixed effects approach?
          • Certain observations within the following variables would form my controls
            • Location_numeric - encoded variable of the 40 locations in the dataset.
            • Propertytype_numeric - encoded variable of the different types of property in my dataset (apartment, terrace house etc)
            • Bedrooms_numeric - encoded variable of the different bedroom amounts in the properties (1 bed, 2 bed etc)
          Many thanks,
          Hugh

          Some new code below

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input double VALUE long(PropertyType_numeric Location_numeric) float Bedrooms_numeric long Quarters float treatvar
          1094.67 1 2 2  3 0
          1153.71 1 2 2  5 0
          1654.97 1 2 2 19 0
          1172.47 1 2 2  6 0
          1194.97 1 2 2  7 0
          2324.11 1 3 2 38 1
           2201.1 1 3 2 29 1
          2216.58 1 3 2 22 1
          2212.85 1 3 2 33 1
          2256.34 1 3 2 37 1
          1442.38 1 3 2  2 0
          2187.83 1 3 2 30 1
          2304.26 1 3 2 26 1
          1932.83 1 3 2 16 0
          1577.16 1 3 2  7 0
          1501.87 1 3 2  4 0
          1614.01 1 3 2  9 0
          2271.34 1 3 2 23 1
          1604.92 1 3 2  8 0
          2282.46 1 3 2 27 1
          end
          label values PropertyType_numeric PropertyType_numeric
          label def PropertyType_numeric 1 "Apartment", modify
          label values Location_numeric Location_numeric
          label def Location_numeric 2 "Aungier Street, Dublin 2", modify
          label def Location_numeric 3 "Ballsbridge, Dublin 4", modify
          label values Quarters Quarters
          label def Quarters 2 "2014Q2", modify
          label def Quarters 3 "2014Q3", modify
          label def Quarters 4 "2014Q4", modify
          label def Quarters 5 "2015Q1", modify
          label def Quarters 6 "2015Q2", modify
          label def Quarters 7 "2015Q3", modify
          label def Quarters 8 "2015Q4", modify
          label def Quarters 9 "2016Q1", modify
          label def Quarters 16 "2017Q4", modify
          label def Quarters 19 "2018Q3", modify
          label def Quarters 22 "2019Q2", modify
          label def Quarters 23 "2019Q3", modify
          label def Quarters 26 "2020Q2", modify
          label def Quarters 27 "2020Q3", modify
          label def Quarters 29 "2021Q1", modify
          label def Quarters 30 "2021Q2", modify
          label def Quarters 33 "2022Q1", modify
          label def Quarters 37 "2023Q1", modify
          label def Quarters 38 "2023Q2", modify

          Comment

          Working...
          X