Announcement

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

  • Error with SDID command for "Synthetic control for Difference-in-Difference"- 'repeated time values within panel'

    Hi Stata Lovers,


    I am using the SDID command to perform a synthetic control, difference-in-difference on the individual level data using the following command.

    sdid quality state year treated, vce(bootstrap) covariates(education wealth) graph

    I am getting following error.

    “repeated time values within panel”
    • The outcome variable ‘quality’ is binary: ‘quality care provided; yes == 1 and no == 0’.
    • Group variable- state- representing various states of India. The intervention was applied to only some states
    • The 'treated' variable is binary, representing a state (region) that was ‘exposed to treatment; yes == 1 or no == 0’.
    • Period of intervention= 1 if year >= 2016 (data from year 2010 to 2021).
    • Variable treatment, represent which unit received treatment at what time ( treatment =1 if treated ==1 & year >= 2016)
    I read the paper by Clarke et al., 'Synthetic Difference In Differences Estimation' and they recommend this command is for a balanced panel of units (group variable == state in my data set).

    I have the following questions regarding this command.
    1. Is there a way if the SDID command can be used for individual-level data for a binary outcome variable?
    2. How can I convert my individual-level data, to balance panel data i.e., the percentage of patients who received quality care in each state every year (from 2010 to 2021)?
    3. If I cannot use SDID, is there another command for Synthetic Control DiD for individual-level data?
    . dataex caseid quality state wealth education year treated treatment

    ----------------------- copy starting from the next line -----------------------
    [CODE]
    * Example generated by -dataex-. For more info, type help dataex
    clear


    input str15 caseid float(quality state) byte(wealth education) int year float(treated treatment)

    " 07010620 01" 0 1 1 0 2011 1 0
    " 07053475 02" 0 1 4 10 2011 1 0
    " 07039679 02" 0 1 1 5 2011 1 0
    " 07062097 02" 0 1 2 3 2011 1 0
    " 07011050 02" 0 1 3 7 2016 1 1
    " 07046119 02" 1 1 1 0 2011 1 0
    " 07059056 02" 0 1 1 6 2011 1 0
    " 07013006 04" 1 1 4 12 2011 1 0
    " 07014430 02" 0 1 4 7 2018 1 1
    " 07084001 02" 0 1 1 4 2011 1 0
    " 07071186 08" 0 1 3 1 2018 0 0
    " 07082027 02" 0 1 3 5 2019 1 1
    " 07007234 02" 0 1 3 8 2011 1 0
    " 07077928 02" 0 1 1 3 2020 0 0
    " 07055459 02" 0 1 1 5 2021 1 1
    " 07038595 08" 0 1 2 5 2011 1 0
    " 07054441 03" 0 1 5 12 2011 1 0
    " 07104808 03" 0 1 3 8 2011 1 0
    " 07056183 02" 0 1 1 3 2011 1 0
    " 07025259 02" 0 1 1 4 2011 1 0
    " 07025359 02" 0 1 2 8 2011 1 0
    " 07065109 02" 0 1 5 5 2011 1 0
    " 07073581 06" 0 1 2 0 2011 1 0
    " 07000219 02" 1 1 1 0 2011 1 0
    " 07021937 02" 1 1 1 0 2011 1 0
    " 07045416 04" 0 1 1 3 2011 1 0
    " 07044204 04" 1 1 2 0 2011 1 0
    " 07016332 02" 1 1 2 6 2011 1 0
    " 07092891 02" 1 1 1 0 2011 1 0
    " 07040634 02" 0 1 2 0 2011 1 0
    " 07041366 02" 0 1 4 2 2011 1 0
    " 07027310 04" 1 1 3 7 2011 1 0
    " 07058348 02" 1 1 2 0 2011 1 0
    " 07008565 02" 0 1 1 0 2011 1 0
    " 07076575 02" 0 1 1 0 2011 1 0
    " 07045223 02" 0 1 4 5 2011 1 0
    " 07054028 02" 0 1 1 6 2011 1 0
    " 07100051 02" 0 1 3 5 2011 1 0
    " 07012511 03" 1 1 4 9 2011 1 0
    " 07071093 02" 1 1 2 0 2011 1 0
    " 07082351 02" 0 1 5 5 2011 1 0
    " 07051074 02" 0 1 1 0 2011 1 0
    " 07010397 02" 1 1 1 0 2014 1 0
    " 07011950 02" 0 1 3 6 2011 1 0
    " 07042812 02" 0 1 1 0 2011 1 0
    " 07035515 02" 0 1 2 0 2018 1 1
    Last edited by pavan pandey; 06 Oct 2023, 10:18.

  • #2
    You need one observation per unit per time period. At the moment you don't have that, and you'll need to do some aggregation

    Comment


    • #3
      Originally posted by Jared Greathouse View Post
      You need one observation per unit per time period. At the moment you don't have that, and you'll need to do some aggregation
      Hi Jared,


      Thanks you for your response.
      Below is an example from my dataset.

      I want to create two variables (aggregate data) from my data. I want to calculate rates at the state level (variable state).
      1. Variable 1 (monthlyrate): Percentage of women giving birth in a particular month (e.g. Jan 2011, March 2015, October 2018, Feb 2020, and so on...) in each state who received quality care.
      2. Variable 1 (yearlyrate): Percentage of women giving birth in a particular year (e.g., 2010, 2012, 2013, 2014, and so on ) in each state who received quality care.

      . dataex caseid date month year district45 state quality

      ----------------------- copy starting from the next line -----------------------
      [CODE]
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str15 caseid long date byte month int year long district45 float(state quality)

      " 19240150 02" 18294 2 2010 172 8 0
      " 19201106 02" 18294 2 2010 525 8 0
      " 02097658 04" 18294 2 2010 505 5 0
      " 19006936 04" 18294 2 2010 590 8 0
      " 20046984 02" 18294 2 2010 166 4 1
      " 19192875 02" 18294 2 2010 254 8 0
      " 19091611 06" 18294 2 2010 246 8 1
      " 19095627 02" 18294 2 2010 587 8 0
      " 19104880 04" 18294 2 2010 155 8 1
      " 04019661 02" 18294 2 2010 168 3 0
      " 35005994 02" 18295 2 2010 336 6 0
      " 19124124 06" 18295 2 2010 425 8 0
      " 19213604 04" 18295 2 2010 26 8 0
      " 35003652 02" 18295 2 2010 432 6 1
      " 19097162 04" 18295 2 2010 66 8 0
      " 19226824 02" 18295 2 2010 587 8 0
      " 19095878 04" 18295 2 2010 425 8 0
      " 19122894 02" 18295 2 2010 172 8 0
      " 19116733 02" 18296 2 2010 237 8 0
      " 19014508 02" 18296 2 2010 237 8 0
      " 20064555 06" 18296 2 2010 449 4 0
      " 19153509 03" 18296 2 2010 408 8 0
      " 19133189 02" 18296 2 2010 26 8 0
      " 35081695 02" 18296 2 2010 518 6 0
      " 02042822 02" 18296 2 2010 693 5 0
      " 35064062 07" 18296 2 2010 55 6 0
      " 20010370 02" 18296 2 2010 263 4 0
      " 19186410 02" 18297 2 2010 231 8 0
      " 20007563 02" 18297 2 2010 450 4 0
      " 19101320 02" 18297 2 2010 123 8 0
      " 35016656 02" 18297 2 2010 403 6 0
      " 19083610 02" 18297 2 2010 590 8 1
      " 02065345 02" 18297 2 2010 22 5 0
      " 35034109 02" 18297 2 2010 336 6 0
      " 20074239 02" 18297 2 2010 511 4 1
      " 35050882 02" 18297 2 2010 60 6 1
      " 35039368 02" 18297 2 2010 514 6 1
      " 19083393 02" 18297 2 2010 571 8 0
      " 35009087 02" 18297 2 2010 235 6 0
      " 35079614 02" 18298 2 2010 490 6 1
      " 19066564 02" 18298 2 2010 231 8 0
      " 20016648 04" 18298 2 2010 88 4 0
      " 19085867 02" 18298 2 2010 601 8 0
      " 19056985 03" 18298 2 2010 277 8 1
      " 19158378 02" 18298 2 2010 425 8 1
      " 19029081 02" 18299 2 2010 326 8 0
      " 20009671 02" 18299 2 2010 116 4 0
      " 19033764 02" 18299 2 2010 590 8 0
      " 19086149 02" 18299 2 2010 523 8 1
      " 20023723 02" 18299 2 2010 454 4 0
      " 19057717 02" 18299 2 2010 408 8 0
      " 19068829 04" 18299 2 2010 551 8 0
      " 19094803 03" 18300 2 2010 319 8 0
      " 19097422 02" 18300 2 2010 159 8 1
      " 20079479 02" 18300 2 2010 202 4 0
      " 19160917 02" 18300 2 2010 587 8 0
      " 19120758 02" 18300 2 2010 41 8 0
      " 35037421 02" 18300 2 2010 432 6 0
      " 04031847 02" 18300 2 2010 232 3 1
      " 19080103 04" 18301 2 2010 26 8 0
      " 19203080 02" 18301 2 2010 326 8 0
      " 02007104 02" 18301 2 2010 228 5 1
      " 19102395 02" 18301 2 2010 523 8 1
      " 04041167 02" 18301 2 2010 163 3 1
      " 20092590 01" 18301 2 2010 202 4 1
      " 19050231 03" 18301 2 2010 123 8 0
      " 02075779 02" 18301 2 2010 182 5 0
      " 02095739 02" 18301 2 2010 712 5 1
      " 35031797 02" 18302 2 2010 94 6 1
      " 19194635 02" 18302 2 2010 147 8 1
      " 19090211 02" 18302 2 2010 227 8 0
      " 19059499 02" 18302 2 2010 601 8 0
      " 19020684 02" 18302 2 2010 26 8 0
      " 19151640 02" 18302 2 2010 319 8 0
      " 19159709 02" 18302 2 2010 601 8 0
      " 35012128 02" 18302 2 2010 60 6 1
      " 19240395 04" 18302 2 2010 231 8 0
      " 19106796 02" 18302 2 2010 26 8 0
      " 19165037 02" 18302 2 2010 26 8 0
      " 02007556 03" 18302 2 2010 693 5 0
      " 19081256 02" 18302 2 2010 246 8 1
      " 19207687 02" 18302 2 2010 227 8 1
      " 19223454 08" 18303 2 2010 147 8 0
      " 20066079 02" 18303 2 2010 88 4 0
      " 19122266 02" 18303 2 2010 11 8 0
      " 04028892 04" 18303 2 2010 657 3 0
      " 19251098 02" 18303 2 2010 408 8 1
      " 35079147 03" 18304 2 2010 490 6 0
      " 19090416 02" 18304 2 2010 673 8 0
      " 35065679 02" 18304 2 2010 403 6 0
      " 19165525 10" 18304 2 2010 453 8 0
      " 19165810 04" 18304 2 2010 590 8 1
      " 19129768 02" 18305 2 2010 325 8 0
      " 19237222 02" 18305 2 2010 485 8 0
      " 19077418 02" 18305 2 2010 231 8 0
      " 19001127 02" 18305 2 2010 172 8 0
      " 20103854 02" 18305 2 2010 511 4 0
      " 19083154 02" 18305 2 2010 580 8 0
      " 19087137 02" 18305 2 2010 523 8 0
      " 04087418 02" 18305 2 2010 445 3 0

      Comment


      • #4
        This isn't on the menu for you. Not in the same way, anyways. You need to have one row per unit per year (or per month). You can't have two panel variables in one dataset and analyze it the same way, it just doesn't work like that.

        You need the total population of your group and the numerator for the group (which you have).

        Comment


        • #5
          Originally posted by Jared Greathouse View Post
          This isn't on the menu for you. Not in the same way, anyways. You need to have one row per unit per year (or per month). You can't have two panel variables in one dataset and analyze it the same way, it just doesn't work like that.

          You need the total population of your group and the numerator for the group (which you have).
          Hi Jared,


          I read the paper by Clarke et al., again. Based on the datatset used in one of the example. I am using the following approach

          gen my = ym(year, month)
          label variable my "Month & Year of Sterilization"
          format my %tm
          sort date


          // CALCULATE RATES

          assert month == month(date)
          assert year == year(date)

          // CALCULATE RATES
          by state month year, sort: egen monthly_quality_rate = mean(quality)
          by state year, sort: egen yearly_quality_rate = mean(quality)

          // CONVERT TO PERCENTAGE
          foreach v of varlist *_quality_rate {
          replace `v' = 100*`v'
          }

          sort state my

          table ( my ) ( state ) (), statistic(mean monthly_quality_rate)

          collect export "Monthly Rates", as(xlsx) sheet(Sheet1) cell(A1) replace


          I got the following results.


          ------------------------------------------------------------------------------------------------------------------------------------------------------
          | States
          | CG Odisha Assam Maharashtra Andra Pradesh WB Jharkhand MP Telangana Total
          ------------------------------+-----------------------------------------------------------------------------------------------------------------------
          Month & Year of Sterilization |
          2010m2 | 41.17647 13.51351 25 39.13044 19.07895 0 21.72131
          2010m3 | 37.5 15.15152 40 27.77778 25.75758 27.27273 25.34247
          2010m4 | 50 24 40 41.66666 34.14634 25 33.01887
          2010m5 | 37.5 12.5 0 33.33334 29.26829 12.5 22
          2010m6 | 66.66667 14.28572 18.75 25 30.55556 14.28572 26.80412
          2010m7 | 55.55556 14.81481 55.55556 10 24.44444 0 24.76191
          2010m8 | 57.14286 13.33333 9.090909 20 35.29412 22.22222 26.54867
          2010m9 | 37.5 16.12903 43.75 26.66667 26.78571 12.5 25.35211
          2010m10 | 20 17.64706 17.64706 30 23.07692 20 20.91503
          2010m11 | 22.22222 16 35.71429 33.33334 28.57143 0 26.96079
          2010m12 | 36.36364 20.83333 10 42.85714 14.28572 0 16.94915
          2011m1 | 34.61539 20.51282 27.77778 46.15385 18.0791 16.66667 21.8638
          2011m2 | 36.7347 36.36364 62.5 9.090909 0 40.90909 28 20.96774 0 25.32751
          2011m3 | 34.375 20 44.44445 9.090909 20 37.93103 10.25641 25 12.5 23.04833
          2011m4 | 27.27273 20 33.33334 17.14286 20 28.57143 0 32.35294 20 24.11348
          2011m5 | 25 23.80952 40 15.78947 30 27.27273 25 27.90698 16.66667 25.19685
          2011m6 | 57.14286 31.81818 22.22222 16.66667 16.66667 37.5 25 27.90698 0 27.15232
          2011m7 | 33.33334 35.71429 80 25.80645 25 31.25 14.28572 35.13514 66.66667 33.11258
          2011m8 | 69.23077 30 22.22222 15 10 50 35.71429 18.42105 0 24.67533
          2011m9 | 20 46.15385 30 6.451612 7.142858 22.22222 0 20.75472 14.28572 20.57143
          2011m10 | 25.71429 19.23077 50 21.62162 0 33.33334 76.92308 22.97297 37.5 26.36364
          2011m11 | 28.57143 36.36364 30 15 0 21.42857 25 30.26316 0 26.79128
          2011m12 | 33.82353 19.14894 60 8.695652 25.92593 21.42857 17.77778 23.00469 0 22.41015
          2012m1 | 23.4375 29.78723 58.82353 12.82051 18.18182 0 16.98113 13.06533 0 18.16144
          2012m2 | 27.41936 43.39622 54.54546 26.19048 20 35.29412 24.4186 19.67213 0 26.05932
          2012m3 | 38.09524 36 77.77778 14.28572 25 60 20.58824 21.05263 0 28.34008
          2012m4 | 41.17647 34.78261 50 9.375 0 33.33334 25 27.02703 0 23.68421
          2012m5 | 42.85714 33.33334 77.77778 13.63636 23.80952 44.44445 14.28572 21.42857 16.66667 25.47771
          2012m6 | 50 41.17647 45.45455 31.03448 6.666667 0 33.33334 28.57143 0 31.25
          2012m7 | 41.17647 57.57576 37.5 10 14.28572 33.33334 25 18.18182 12.5 29.93197
          2012m8 | 37.5 33.33334 25 13.33333 26.66667 30 0 26.66667 15.38462 24.20382
          2012m9 | 35.29412 40 20 9.523809 21.05263 20 0 32.6087 0 25
          2012m10 | 38.46154 45.45455 50 17.24138 23.07692 25 44.44445 17.46032 33.33334 28.78049
          2012m11 | 24.24242 41.66666 57.14286 18.18182 12.5 50 27.27273 25 12.5 27.56184
          2012m12 | 24.24242 38.18182 36.36364 8.695652 0 50 10.20408 21.42857 0 21.23288
          2013m1 | 32.69231 33.33334 36.84211 15.51724 11.76471 20 16.17647 18.62069 16.66667 21.93995
          2013m2 | 31.74603 41.02564 33.33334 9.803922 7.692308 20 18.91892 28.02548 20 25.05801
          2013m3 | 57.89474 40 64.28571 9.375 25 40 16.12903 16.66667 0 28.62745
          2013m4 | 38.09524 42.10526 37.5 17.85714 7.692308 53.84616 12.5 30.23256 0 29.11392
          2013m5 | 25 43.75 28.57143 13.88889 18.75 55.55556 42.85714 28.57143 12.5 26.47059
          2013m6 | 33.33334 26.08696 55.55556 14.81481 16.66667 30.76923 25 27.27273 11.11111 25.51724
          2013m7 | 22.22222 42.30769 42.85714 15.15152 0 20 28.57143 48.27586 28.57143 30.06993
          2013m8 | 53.33334 47.82609 61.53846 13.63636 0 40 22.22222 23.07692 20 31.69014
          2013m9 | 27.77778 42.85714 50 18.18182 18.18182 18.18182 28.57143 12.90322 0 22.97297
          2013m10 | 31.25 42.85714 12.5 15.38462 30.76923 33.33334 45.45455 30 20 28.49741
          2013m11 | 50 41.37931 40 14.28572 5.555556 10 18.51852 32.65306 12.5 27.92453
          2013m12 | 25.39683 34 25 11.42857 11.76471 28.57143 17.77778 30.85714 0 25.83732
          2014m1 | 20.40816 48.48485 57.14286 25.71429 37.5 23.52941 22.53521 16.37427 0 23.09582
          2014m2 | 35.18518 56.25 65.21739 24.67533 14.81481 40 19.23077 21.23288 28.57143 28.48485
          2014m3 | 21.42857 47.82609 81.25 23.07692 12 25 8 23.21428 20.93023 25.64935
          2014m4 | 36.36364 46.15385 46.15385 33.75 14.28572 26.66667 30.76923 30 33.33334 31.75966
          2014m5 | 14.28572 33.33334 47.36842 16.85393 11.53846 25 0 27.58621 16.66667 21.13821
          2014m6 | 50 36.84211 68.18182 38.88889 9.090909 57.14286 16.66667 30 22.85714 35.71429
          2014m7 | 30 53.84616 62.5 20.68966 14.28572 32.14286 50 27.77778 21.21212 30
          2014m8 | 37.5 37.5 56.25 23.8806 16.66667 40.90909 27.27273 30.43478 18.86793 28.22581
          2014m9 | 37.5 42.85714 50 22.35294 17.14286 40 25 26.19048 17.64706 26.07004
          2014m10 | 34.78261 40 85.71429 29.06977 0 47.05882 53.84616 32.87671 21.42857 32.05575
          2014m11 | 46.42857 40.47619 46.66667 16.86747 15.78947 32 9.090909 27.69231 23.07692 26.65037
          2014m12 | 43.90244 43.10345 40 23.80952 15.15152 34.78261 28.57143 19.90291 29.41177 27.07182
          2015m1 | 27.27273 51.06383 60 28.08989 7.692308 48.27586 13.84615 21.38728 24.13793 28.07018
          2015m2 | 52.63158 45.61403 46.66667 28.16902 18.51852 25.64103 22.81879 36.57407 22.58064 33.23486
          2015m3 | 63.63636 61.11111 65 29.82456 6.25 35.71429 32.43243 40.44944 16.12903 37.5
          2015m4 | 62.5 54.05405 57.14286 30.15873 11.53846 15.38462 23.07692 54 33.33334 39.49275
          2015m5 | 33.33334 62.06896 56.25 26.38889 11.11111 46.66667 8.333334 43.75 29.03226 34.95935
          2015m6 | 58.33333 52.5 50 22.64151 16 57.14286 28.57143 46.66667 22.72727 37.15596
          2015m7 | 48.27586 60 46.66667 37.14286 23.07692 35 46.66667 53.33334 19.23077 44.11765
          2015m8 | 57.14286 56.52174 53.84616 19.44444 27.77778 0 7.142858 66.66667 25.92593 44
          2015m9 | 58.82353 58.13953 53.33334 26.31579 7.692308 20 33.33334 40.47619 29.41177 40.77253
          2015m10 | 50 48.88889 73.68421 23.25582 36.36364 33.33334 48.27586 50 25.80645 43.43066
          2015m11 | 64.58333 53.52113 57.14286 35.71429 0 47.36842 30.95238 43.13726 24.13793 44.11765
          2015m12 | 42.30769 56.70103 66.66667 31.91489 14.28572 41.66666 12.94118 39.21569 23.68421 36.66667
          2016m1 | 50.68493 43.75 41.66666 26.47059 11.11111 21.42857 26.44628 36.42384 25 35.82375
          2016m2 | 60 44 57.14286 24.32433 16.66667 17.64706 28.30189 51.30435 33.33334 40.30132
          2016m3 | 42.85714 48.3871 58.33333 28.94737 0 44.44445 33.84615 45.09804 32 38.51351
          2016m4 | 75 47.36842 40 38.46154 14.28572 22.22222 50 43.33333 34.61539 42.32804
          2016m5 | 56.25 31.25 75 21.42857 0 57.14286 29.41177 43.47826 44.44445 34.91124
          2016m6 | 69.23077 80 66.66667 45.83334 0 27.27273 25 59.25926 26.92308 44.5946
          2016m7 | 90.9091 68.42105 41.66666 44 8.333334 23.52941 35.71429 57.14286 12.5 43.50649
          2016m8 | 68.18182 60 100 42.85714 15.38462 50 42.10526 51.02041 36.36364 48.92473
          2016m9 | 53.33334 69.23077 53.84616 20.51282 21.05263 0 41.66666 64.44444 43.75 42.54144
          2016m10 | 77.77778 68.18182 50 37.2549 33.33334 25 27.27273 38.77551 21.73913 43.26923
          2016m11 | 78.57143 53.125 54.54546 33.33334 12.5 14.28572 39.39394 45.45455 23.80952 44.12812
          2016m12 | 73.07692 75.75758 66.66667 45.23809 9.090909 17.64706 27.02703 46.51163 17.85714 44.44445
          2017m1 | 73.33334 54.83871 63.63636 25 20 0 23.52941 42.85714 41.17647 41.68865
          2017m2 | 84.61539 52.27272 66.66667 25 14.28572 17.3913 32.39437 43.26923 26.66667 41.50418
          2017m3 | 73.33334 63.63636 77.77778 32 0 29.41177 38.46154 41.02564 37.5 43.01075
          2017m4 | 78.94737 70.58823 57.14286 32 12.5 23.07692 33.33334 50 31.25 43.94905
          2017m5 | 57.14286 58.33333 83.33333 30.43478 7.692308 33.33334 28.57143 60 33.33334 41.6
          2017m6 | 88.88889 30 42.85714 25.92593 20 42.85714 50 56.25 42.30769 42.58065
          2017m7 | 76.92308 50 72.72727 38.23529 33.33334 14.28572 50 61.90476 39.13044 48.93617
          2017m8 | 75 56.25 25 40.90909 13.33333 27.77778 37.5 47.61905 40 41.95402
          2017m9 | 86.95652 50 100 35.71429 30 63.63636 50 58.33333 37.93103 52.5641
          2017m10 | 78.57143 47.82609 0 30.55556 6.25 40 22.22222 36.17021 48 37.96791
          2017m11 | 78.26087 67.5 57.14286 30.23256 0 44.44445 34.48276 51.45631 27.27273 46.7128
          2017m12 | 76.19048 58.06451 75 32.25806 9.090909 23.07692 30.30303 43.75 35.48387 42.38806
          2018m1 | 52.77778 65.625 50 45.94595 42.85714 24 39.53489 44.09938 27.27273 44.26667
          2018m2 | 68.42105 57.69231 33.33334 33.33334 16.66667 35 31.08108 52.74726 27.27273 43.76997
          2018m3 | 62.06896 75 66.66667 42.85714 16.66667 37.5 28.57143 34.28572 34.61539 41.71429
          2018m4 | 83.33333 50 28.57143 48 16.66667 33.33334 27.27273 65 14.28572 43.51145
          2018m5 | 78.57143 72.72727 60 31.42857 8.333334 28.57143 22.22222 43.47826 28.57143 39.41606
          2018m6 | 75 55.55556 66.66667 20 0 40 42.85714 53.33334 40.90909 41.58416
          2018m7 | 72.72727 45.45455 30.76923 56.52174 14.28572 30 50 58.62069 28.57143 45.86466
          2018m8 | 58.82353 72.72727 75 29.41177 14.28572 0 60 41.93548 25.92593 40.25157
          2018m9 | 58.82353 41.66666 57.14286 33.33334 11.11111 16.66667 62.5 50 33.33334 41.13475
          2018m10 | 84.21053 46.15385 66.66667 41.86047 25 31.57895 45.45455 52.38095 23.33333 44.71154
          2018m11 | 61.90476 73.68421 33.33334 23.25582 9.090909 7.692308 33.33334 44.44445 28.57143 38.51852
          2018m12 | 77.77778 76 75 38.63636 26.66667 25 13.51351 44.13793 27.27273 42.47788
          2019m1 | 70 65.21739 83.33333 31.57895 12.5 31.57895 39.21569 47.33333 30.76923 45.29914
          2019m2 | 59.375 64.51613 80 33.33334 25 33.33334 30 50 14.28572 43.93939
          2019m3 | 67.64706 46.66667 50 28.57143 13.33333 36.36364 27.58621 46.15385 25.80645 38.70968
          2019m4 | 88.2353 50 60 32.14286 11.11111 60 28.57143 31.57895 51.6129 46.21212
          2019m5 | 71.42857 87.5 83.33333 24.13793 0 12.5 33.33334 42.10526 40.90909 40.74074
          2019m6 | 69.23077 69.23077 62.5 35.71429 33.33334 20 37.5 50 30 46.15385
          2019m7 | 45.45455 57.89474 73.33334 44.44445 10 33.33334 25 45.83334 22.72727 42.22222
          2019m8 | 80 57.89474 37.5 42.10526 25 0 22.22222 50 27.77778 43.10345
          2019m9 | 71.42857 54.54546 100 45.45455 16.66667 66.66667 0 50 38.46154 50
          2019m10 | 75 64.28571 66.66667 42.85714 0 8.333334 46.51163 20 45.91837
          2019m11 | 81.25 64.28571 66.66667 0 25 42 47.61905
          2019m12 | 68.42105 54.83871 32.43243 45.64103 47.84053
          2020m1 | 84.21053 37.03704 35.89744 47.85714 47.55555
          2020m2 | 75 71.42857 41.30435 49.27536 54.76191
          2020m3 | 66.66667 75 22.22222 51.42857 51.25
          2020m4 | 60 100 0 66.66667 60.71429
          2020m5 | 100 60 100 62.5 68
          2020m6 | 50 83.33333 50 30 50
          2020m7 | 100 71.42857 20 50
          2020m8 | 75 100 28.57143 57.14286 57.14286
          2020m9 | 50 71.42857 100 52 56.75676
          2020m10 | 50 50 60 39.28571 45.28302
          2020m11 | 77.77778 88.88889 30 57.14286 59.34066
          2020m12 | 100 53.84616 30.76923 47.36842 45.97701
          2021m1 | 57.14286 52.63158 34.375 50.48544 47.82609
          2021m2 | 66.66667 50 56.25 46.80851 50
          2021m3 | 50 40 66.66667 57.89474
          2021m4 | 0 0
          Total | 50.81803 48.88889 52.56087 24.61134 15.76687 32.1519 27.06956 34.36101 25.528





          I arranged the quality rate of all the nine states in one single column in the excel file. The imported the data into Stata and used the following command

          drop if year <2011 // coz the panel data was unbalanced
          drop if year >2019 // coz the panel data was unbalanced
          encode state, generate(states2)
          gen treated =0
          replace treated =1 if (states2==3 | states2==7) & year>=2016 (Indicating the State of Intervention and the Period of Intervention)
          sort states2 my
          gen month = monthly(my, "YM")
          format month %tm

          . sdid rate states2 month treated, vce(bootstrap) graph


          Bootstrap replications (50). This may take some time.
          ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
          .................................................. 50


          Synthetic Difference-in-Differences Estimator

          -----------------------------------------------------------------------------
          rate | ATT Std. Err. t P>|t| [95% Conf. Interval]
          -------------+---------------------------------------------------------------
          treated | 8.89383 2.72724 3.26 0.001 3.54855 14.23911
          -----------------------------------------------------------------------------
          95% CIs and p-values are based on Large-Sample approximations.
          Refer to Arkhangelsky et al., (2020) for theoretical derivations.



          IS THIS APPROACH CORRECT?


          Comment


          • #6
            Possibly

            Comment


            • #7
              Thank you very much.

              Comment


              • #8
                Originally posted by Jared Greathouse View Post
                Possibly
                Hi Jared,

                Just one more question- is there a package or command for balancing the panel data? Or a statistical methodology for balancing a panel data?

                Comment


                • #9
                  No this is basic data cleaning. All you need to do is likely average by state or follow my advice in post 4, you wouldn't wanna use (or make) something specifically designed to balance a panel dataset

                  Comment


                  • #10
                    Originally posted by Jared Greathouse View Post
                    No this is basic data cleaning. All you need to do is likely average by state or follow my advice in post 4, you wouldn't wanna use (or make) something specifically designed to balance a panel dataset
                    Hi Jared,

                    Which method would you recommend for an unbalanced panel data?

                    Comment


                    • #11
                      SCM isn't possible with unbalanced panels.

                      Comment


                      • #12
                        Anyways, just average over your state and time period. And this should be the solution

                        Comment

                        Working...
                        X