[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

1. Spells are defined as contiguous blocks of 1s within each panel. 2. Then gaps within spells are allowed that include one or two 0s or that are shorter than 21 days. How to do things like this is detailed in the paper. Uneven spacing is immaterial here if it doesn't matter to you. Nick n.j.cox@durham.ac.uk Clive Nicholas replied to Shantanu Nundy > I am working with panel data and am struggling to do manipulations with the data given that the time differences between ob[n] and ob[n-1] are not constant.Here is my specific problem at hand: I have a variable that is either 1 or 0. I want to define an "episode" of 1, where episode is defined the time between the first 1 and the last 1 that is followed by at least three 0s AND over at least 21 days. From my list of 1s and 0s, I would to define a "episode_start" variable that is 1 for the start of each episode and for a second variable "episode_day" to be 1 for all days of an episode. The trouble is that in some cases the three 0s may be over 5 days and other times over 25 days. If the three 0s are over 5 days, we need to checking more observations as long as the variable remains 0 until 21 days has been reached.I have found a solution but it is by no means elegant and consists of over 20 lines of the following (where codigo is my panel variable, giardia is the 1 or 0 vari ab! > le, giardia_i is the desire "episode_start" variable, and date is time):by codigo: replace giardia_i=1 if count_result==1 & giardia==1 & (date - date[_n-4] >= 21 | giardia[_n-4]==.) & giardia[_n-4]!=1by codigo: replace giardia_i=1 if count_result==1 & giardia==1 & (date- date[_n-5] >= 21 | date[_n-5]==.) & giardia[_n-4]!=1 & giardia[_n-5]!=1 The user-written -tsspell-, available from SSC, might be of use here. However, I haven't used this routine, so I can't give you examples of how to use it for your specific problem. * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**RE: st: re: working with panel data with time gaps** - Next by Date:
**st: AR test with weak instrument** - Previous by thread:
**[no subject]** - Next by thread:
**st: margeff with mlogit** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |