[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Multiple spells: -ltable- to graph hazards by age rather than by duration?
I have a dataset where each row corresponds to one labour-market
spell of a particular person. Among the variables are person ID, spell
start date, spell end date, labour market-status, interview date, and
date of birth. I use these variables to generate age at spell start date
(ageatbeg) and age at spell end date (ageatend). The data are recorded
in monthly intervals.
Is there any way of using the -ltable- command (or any other existing
command) to graph hazards by age rather than by duration? I don't want
to stratify the hazards by age group, but rather have age itself on the
abscissa to be able to see whether certain labour-market transitions
occur mainly at certain key ages.
As far as I can see I get erroneous results with -ltable- since in the
logic of this command a failure time of 780 (ie, a certain labour-market
transition at exact age 65, since 780/12=65) implies that the person was
at risk for 65 years, which is of course not correct. In mortality
studies, the distinction between age and duration does not matter since
you can only die once, but in my case it does matter. In other words, my
problem seems to be caused by the multiple spell structure, which
implies that age!=duration+x since people have different numbers of
spells of different lengths.
I know what I would like to do in terms of simple Stata commands:
sort pid ageatbeg
count if ageatbeg<780 & ageatend>=780 & ageatend!=. & status==1
returns the number of people in status "1" at exact age 65, therefore my
risk set, and
count if ageatend==780 & status==1 & status[_n+1]==3 & pid==pid[_n+1]
then returns the number of people who have made a transition from status
"1" to status "3" within the first month after exact age 65, therefore
my failure set.
The problem is that even if I use loops to calculate these numbers using
the latter two command lines for each monthly age, there's no easy way
of tabulating and/or exporting the data.
My question therefore is whether there's any way of getting the
calculations I want nicely tabulated, for instance reorganising my data
somehow? I am of course aware of the option of modifying the ltable.ado
file but maybe somebody else has already dealt with this or a similar
problem so that I don't have to do that.
I would be very grateful for any hint and appreciate your time and
Mr David A M Haardt <email@example.com>
Institute for Social and Economic Research
University of Essex, Colchester CO4 3SQ, UK
Tel: +44 (0)1206 873569; Fax: +44 (0)1206 873151
* For searches and help try: