Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Dummies for before, during and after treatment years


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Dummies for before, during and after treatment years
Date   Mon, 24 Mar 2014 00:33:51 +0000

I would always advise against labelling a question is "simple". If
it's simple, you should be able to answer it; if it's not, your
judgement is at fault. (I am half-joking here, but also half-serious:
just say that you have a problem you can't solve.)

Your problem yields immediately you have -tsset- the data, as each
indicator variable is based on a comparison of the present value and
either the previous or the next.

. tsset id year
       panel variable:  id (strongly balanced)
        time variable:  year, 1990 to 2006
                delta:  1 unit

. gen i1 = treated == 0 & F.treated == 1

. gen i2 = treated == 1 & L.treated == 0

. gen i3 = treated == 0 & L.treated == 1

Another way of approaching this is to create spells based on values of
-treated-. See -tsspell- from SSC and the results of

. tsspell treated

That could be useful for related purposes. The archives contain other
posts on -tsspell-.


Nick
[email protected]


On 23 March 2014 22:46, micono tzinbunoc <[email protected]> wrote:
> I have a simple question with regards to creating dummies to identify
> from 1 year before the treatment up to 1 year after the treatment.
>
> The -1 year dummy that I am trying to create should indicate the year
> before the treatments and it should equal 1 only in years 1991 and
> 1996.
>
> 0 year dummy should identify the year when the treatment begins and it
> should be equal 1 only in years 1992 and 1997.
> ...
>
> +1year dummy should  identify the year after the treatment ends and it
> should be equal to 1 only in years 1994 and 2005.
>
>
> id year treated
> 1 1990 0
> 1 1991 0
> 1 1992 1
> 1 1993 1
> 1 1994 0
> 1 1995 0
> 1 1996 0
> 1 1997 1
> 1 1998 1
> 1 1999 1
> 1 2000 1
> 1 2001 1
> 1 2002 1
> 1 2003 1
> 1 2004 1
> 1 2005 0
> 1 2006 0
>
>
> I tried searching for this in statalist but I couldn't honestly  find
> a correct search term  that would give me a solid answer to this
> problem. If you have any solution,  advice or a link to earlier
> discussion, I would greatly appreciate. Thanks very much in advance.
>
> Best wishes,
> Mehmet
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index