Announcement

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

  • Replace with _n+1 by group

    Hello Everyone,

    So I want to run a version of parallel trends but with continuous treatment variable. i have treatment information at the province level and treatment dosage varies from 1 to 4. I have survey data from before the treatment and I want to assign provinces to placebo treatment groups before treatment based on the survey information post-treatment. My code is as follows :

    Code:
    bys state province surveyyear : gen placebotreat =treat[_n+1]
    the goal is that for observations before the treatment period, I can assign post-treatment dosage values of 1 to 4. So if the province was in group 1 pre-treatment and group 4 post-treat in the survey year 2014, how do I assign post-treatment value of 4 to observations in the pre-treat years. However, it makes no difference in the way the new placebo variable is recorded.
    Thanks!

  • #2
    Just bumping this up since I have not managed to resolve the issue.

    Comment


    • #3
      I, at least, still find your question unclear - a data example, including what you want as the result, would be helpful; please use -dataex- for the example and post the result in CODE blocks; the FAQ will explain these as well as giving advice on how to ask questions that can be answered

      Comment


      • #4
        Hi Rich,

        Thanks for the response. I have added the -dataex- sample hereunder. My treatment year is 2004 and I have survey information from 2003, 2008 and 2015. I have a treatment variable that is continuous ranging from 1 to 4. I want to assign provinces that were in for example treatment stage = 2 the same treatment assignment for observations before 2004. Similarly for those in 1,3 and 4. Thanks.

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input byte state float(province year) byte treat
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        28 1 2003 1
        end
        label values state labels0
        label def labels0 28 "WY", modify

        Comment


        • #5
          Is there a possibility to use
          Code:
          egen placebo = min(treat) if year >2004, by(prov state) // OR
          egen, fill(numlist)
          Essentially, I want to take a year after 2004 and replace treatment assignments with post-treatment values which were all 1 in the pre-treatment period.

          Comment


          • #6
            The data example doesn't help much, unfortunately. There are no observations for any years but 2003. In fact all the observations are the same, so there is no more information than is given by the first observation alone.

            Incidentally, how can a variable that takes values 1, 2, 3, 4 be regarded as continuous? Also, this may seem trivial, but in what sense can states and provinces receive dosage and a placebo or other treatment? These are standard terms for patients in medical statistics....

            I think we need a better example, one in which years are 2003, 2004, 2008, 2015 and you show what you have and what you want instead.

            Comment


            • #7
              Hello Nick,

              To answer your questions:
              1, With regard to the treatment variable, I intended categorical variables not continuous.
              2. I am looking specifically at a coverage of a policy, split into quartiles, so those provinces with less than 1st quartile coverage are in a way considered less treated which is equivalent to control.

              I have tried to attach a dataex example that is more illustrative

              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input float year long state float province byte treat
              2003 21  8 1
              2003 31  5 1
              2003 22  3 1
              2003 26 19 1
              2003  .  1 1
              2003 31  6 1
              2003 17 11 1
              2003 18 13 1
              2003  5 30 1
              2003 10  6 1
              2003 33 60 1
              2003 29 15 1
              2003 35  6 1
              2003  5 25 1
              2003 33  9 1
              2003  5 29 1
              2003 12 18 1
              2003 25  6 1
              2003 17 21 1
              2003 29 23 1
              2003 13 18 1
              2003 31 23 1
              2003 17 16 1
              2003 25  6 1
              2003 26 14 1
              2003 13 10 1
              2003 12 24 1
              2003 31  3 1
              2003 28  2 1
              2003 15  2 1
              2003 17 13 1
              2003  3  8 1
              2008 16 2003 1
              2008 16 2004 1
              2008 16 2004 1
              2008 16 2004 1
              2008 28  302 1
              2008 28  301 1
              2007 33  922 1
              2008 17 2902 1
              2008 28  302 1
              2008 33  929 1
              2008 28  301 1
              2008  3 1211 1
              2008  3 1211 1
              2008 28  302 1
              2008 16 2004 1
              2008 28  302 1
              2007 33  929 1
              2007 33  929 1
              2008 33  932 1
              2008 28  301 1
              2008 17 2902 1
              2008 28  302 1
              2007 33  922 1
              2008 17 2906 1
              2008 33  929 1
              2008 28  301 1
              2008 28  302 1
              2008  3 1211 1
              2008  3 1213 1
              2007 16 2003 1
              2008 28  301 1
              2008 16 2003 1
              2008 16 2003 1
              2008 28  301 1
              2008 33  968 1
              2007 33  922 1
              2008 28  302 1
              2007 33  922 1
              2007 33  929 1
              2008 16 2003 1
              2008 28  301 1
              2007 33  922 1
              2008 28  302 1
              2008 33  929 1
              2008 28  302 1
              2008 33  932 1
              2008 16 2013 1
              2008 28  301 1
              2008 16 2003 1
              2008 16 2013 1
              2008 16 2004 1
              2008 16 2013 1
              2008 28  301 1
              2008 33  968 1
              2008 33  932 1
              2008 17 2903 1
              2008 28  302 1
              2008 16 2013 1
              2008 33  929 1
              2008  3 1211 1
              2008 16 2013 1
              2008 33  968 1
              2008 28  301 1
              2008 28  301 1
              2008  3 1211 1
              2008 33  929 1
              2008 28  302 1
              2008 28  301 1
              2008 28  301 1
              2008 16 2003 1
              2008 16 2003 1
              2008  3 1211 1
              2008 16 2004 1
              2008 33  932 1
              2007 33  922 1
              2015 21 500 2
              2015 21 505 2
              2016 12 482 2
              2015 13  89 2
              2015 21 500 2
              2015 21 523 2
              2015 21 500 2
              2015 13  89 2
              2015 21 517 2
              2015 21 500 2
              2015 13  69 2
              2015  1 639 2
              2015 21 500 2
              2015 21 500 2
              2015 21 500 2
              2015 21 500 2
              2015 21 500 2
              2015 21 500 2
              2015 27 634 2
              2015 21 525 2
              2016  3 255 2
              2015 21 525 2
              2015 21 500 2
              2015  2 537 2
              2015 21 500 2
              2015 17 570 2
              2016 12 492 2
              2015  2 537 2
              2015 13  82 2
              2016 14  31 2
              2015 17 555 2
              2015 21 521 2
              2015  1 640 2
              2015 21 500 2
              2015 21 500 2
              2015  2 540 2
              2015  2 552 2
              2016 12 480 2
              2015 21 501 2
              2015 21 500 2
              2016 12 474 2
              2015 21 500 2
              2015 21 500 2
              2015 13  89 2
              2016 14  32 2
              2015 21 509 2
              2015 21 502 2
              2016 12 476 2
              2015 21 500 2
              2015 21 506 2
              2015 13  81 2
              2015 21 500 2
              2015 21 525 2
              2015  2 532 2
              2015  2 553 2
              2016  3 245 2
              2015 17 572 2
              2015 21 516 2
              2015 13  85 2
              2015 23 295 2
              2015 21 524 2
              2015 21 523 2
              2016 10  96 2
              2015 21 500 2
              2016 28  35 2
              2015  1 639 2
              2016 12 471 2
              2015  1 640 2
              2016  . 496 2
              2016 12 474 2
              2016 12 468 2
              2015 17 570 2
              2015 21 505 2
              2016 10  93 2
              2016  3 260 2
              2016 28  53 2
              2015 13  87 2
              2015 13  75 2
              2016 14  23 2
              2015 21 500 2
              2015  1 639 2
              2016 28  53 2
              2016 28  53 2
              2015 13  82 2
              2016 10  96 2
              2015 21 523 2
              2015 21 500 2
              2015 21 498 2
              2015 21 500 2
              2016 12 491 2
              2016 28  53 2
              2015 13  75 2
              2016 12 479 2
              2015 13  75 2
              2016 18 588 2
              2015 21 500 2
              2015 21 501 2
              2015  1 640 2
              end
              label values state state

              Comment


              • #8
                That is more detail, for which thanks, but I can't yet follow what it is that you want that you don't have. Someone else may be able to help.

                Comment


                • #9
                  Hi Nick,

                  I essentially want to assign provinces values from after 2004. So, all provinces have a treatment value equal to 1 before the policy i.e. before 2004. And then the policy coverage was staggered after 2004, some had values equal to 1 while others had values equal to 2,3 or 4. I want to reassign these provinces post-treatment values in the pre-treatment period. So if I am in province 21 in 2003 and the treatment value for the same province was 2 in 2008, I want to reassign treat = 2 in 2003. This would help me test parallel trends thus helping me test if provinces' characteristics were trending parallelly before treatment. I am still quiet lost with how to code this. Thanks.

                  Comment

                  Working...
                  X