[R] How to turn individual consecutive information into survival objects?
Guido van Steen
gvsteen at yahoo.com
Thu Oct 29 18:21:23 CET 2009
Dear R List,
I have a dataset with the following structure:
"""personal_id, p_0, p_1, p_2, .... , p_36, p_37
1, NA, 1, 4, .... , 1, NA
2, NA, NA, NA, .... , 4, NA
6020, NA, 3, 3, ...., NA, NA
6021, NA, 2, 2, ...., 4, NA
I used some made-up data. It is just meant to show the structure of the dataset.
The variables of interest are p_0, ... p_37. They represent types of activity of the 6021 persons interviewed in 38 consecutive period.
The values for p_0 and p_37 are coded as follows:
1 = self-employed
2 = employed
3 = in training
4 = unemployed
NA = no information available
p_0 is the period before p_1. This period was just before the survey, so that none of the individuals were interviewed in this period.
p_37 is the period after p_36. This period was just after the survey, so that none of the individuals were interviewed in this period.
I would like to transform this dataset into information on the lenght of the first spell of unemployment. (If there are multiple spells I would just like to use the first one.)
My question is how can I convert the records in this dataset into survivul objects - "Surv()" - so that they can be used with a function like "coxph()".
Could anyone give me a pointer to a function that performs this specific conversion?
Thanks in advance!
Get your new Email address!
Grab the Email name you've always wanted before someone else does!
More information about the R-help