Statalist


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

st: RE: Generating time-varying covariates in a multiple spell data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Generating time-varying covariates in a multiple spell data
Date   Tue, 8 Apr 2008 15:58:36 +0100

A spell includes at least one December if 

(12 * ceil(BEGIN/12)) <= END 

That's a Stata expression that will evaluate as 0 or 1. 

Nick
n.j.cox@durham.ac.uk 

Pyy-Martikainen Marjo


I have a data containing multiple spells per person. The spells are
measured in
months.
The data is in the following form:

PERSON    BEGIN   END     EVENT     DUR
1              (  0            1 ]        1              1
1              (  4          13 ]        1               9
2              (15          25 ]        0              10

where variables BEGIN and END are measured in calendar time (1 refers to
Jan
1995,
2 to Feb 1995 and so on until 60, Dec 1999).

I stset the data in the following way:

stset end, failure(event) time0(begin) exit(time .) origin(time begin)

which means I want to "set the clock to zero" at the start of each
spell.
Now I would like to include a dummy for December months 12, 24, 36 and
48.
It is thus a time-varying variable getting value 1 for the December
months and
0 for other months. A spell may include zero, one or many December
months.
I suppose I should use stsplit and do some kind of episode splitting,
but could
someone
help me and give me advice how I should do it with my data?


*
*   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/



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