28
Stata Technical Bulletin
STB-22
Now, after creating dummies for the time period ...
. tabulate period, generate(per)
Time period I |
Freq. |
Percent |
Cum. |
-SO I |
14 |
42.42 |
— 42.42 |
[80-90 I |
11 |
33.33 |
75.76 |
[90- I |
8 |
24.24 |
100.00 |
Total I |
33 |
100.00 |
— |
and a censoring variable ...
. censor id age = activity==l ∣ activity==2, generate(jobi)
we can estimate a Cox regression model:
. cox Tjobl per2 per3, tvid(id) dead(jobl)
We suppress the output of cox because our example data are too artificial to make the results meaningful. We have, however,
illustrated the process of preparing data for Cox regression; you can apply it to authentic data of your own.
Combining files by time
tmerge is a utility to combine two files each containing ordered observations on one or more individuals. The syntax of
tmerge is
tmerge ident~var filenameA(time.varA) filenameB (time-varlT) new filename (new Jime _var)
tmerge combines filenameA and filenameB and stores the result in new filename (and in the current data set). Observations are
matched according to the values of time-varA and time-varB, which must be expressed in the same scale.
As with the commands described above, tmerge is best understood by looking at an example. Suppose you have two files
containing different event histories for the same individual. One file, job.dta, contains the individual’s employment history:
. use job, clear
. list
id |
birth |
Tjob |
prof | |
1. |
2 |
63 |
80 |
3 |
2. |
2 |
63 |
84 |
1 |
3. |
2 |
63 |
85 |
2 |
4. |
2 |
63 |
89 |
1 |
The other file, mar.dta, contains the individual’s marriage history:
. use mar, clear
. list
id |
birth |
carl |
Tmar |
car2 | |
1. |
2 |
63 |
1 |
78 |
4 |
2. |
2 |
63 |
2 |
89 |
3 |
Time variables—Tjob in job.dta, Tmar in mar.dta—must be expressed in the same scale (here, in years). In each file the
censoring time is 89. tmerge will be interrupted and an error message will appear if the times at censoring are not the same in
both files. To combine the files, type
. drop _all
. tmerge id job(Tjob) mar(Tmar) job-mar(time)
set maxvar 19 width 29
Please wait...
More intriguing information
1. Population ageing, taxation, pensions and health costs, CHERE Working Paper 2007/102. Benefits of travel time savings for freight transportation : beyond the costs
3. The name is absent
4. Industrial Employment Growth in Spanish Regions - the Role Played by Size, Innovation, and Spatial Aspects
5. Growth and Technological Leadership in US Industries: A Spatial Econometric Analysis at the State Level, 1963-1997
6. The name is absent
7. Initial Public Offerings and Venture Capital in Germany
8. The Folklore of Sorting Algorithms
9. The name is absent
10. Demographic Features, Beliefs And Socio-Psychological Impact Of Acne Vulgaris Among Its Sufferers In Two Towns In Nigeria