I am quite new to stata and using version 15.1 in mac. I have been trying to make Lexis Diagaram by setting up data and then following the instructions in https://www.stata.com/stb/stb45/gr31/grlexis2.hlp , but not able to get a complete form. I tried a lot but not able to make the parallelogram ( 45degree from the horizontal axis) for the cohort that are followed. I am putting a small dataset to show what I get and what I wanted.
Code:
clear input float(id ch_dob ch_died ch_exit) 1 14990 1 16451 2 15385 0 15706 3 15779 1 16531 4 16267 1 17287 5 16663 0 17045 6 15329 0 16437 7 15391 1 16865 8 15725 0 16816 9 16166 1 16896 10 16571 1 16940 end format %td ch_dob format %td ch_exit ** Setting dataset as survival Analysis stset ch_exit , failure(ch_died==1) origin(time ch_dob) enter(time ch_dob) scale(365.25) id(id) order _t , after (_t0) ** First split by age capture drop agecat stsplit agecat, at(0 1 2 3 4 5 )trim ** Then,split by time capture drop timeband stsplit timeband, at(0 1 2 3 4 5)trim after(time=ch_dob) ** Calculating the followup time for age and for period in each strata capture drop agefup gen agefup= _t-_t0 capture drop periodfup gen periodfup= (ch_exit- ch_dob)/ 365.25 ** Make Lexis Diagram grlexis2 _t0 _d agefup, /// update(ch_dob) /// xlab() /// ylab(1,2,3,4,5) /// ltitle(Age ) btitle(Calendar Year) title(Lexis Diagram) /// symbol(1)
Array
But, I am not able to get 2 requirements of the graph, inspite of trying other different ways as well. The requirements are as-
- Showing date of birth (ch_dob) in the date format in the x-axis.
- The lines lying at 45 degree from horizantal axis , making paralellograms, as should be in the lexis diagram. I am just posting one Lexis Diagram as an example to show what I actyally require to make ( not produced from this dataset).
Array
I am not able to figure out what is not going right here. Any help would be greatly appreciated.
Thank You
Seema
0 Response to Lexis Diagram- Not able to make Parallelograms to show follow up of cohort
Post a Comment