Please everyone I have this challenge with setting up my data for survival analysis to study under-5 mortality in Nigeria using 2018 Nigeria Demographic and Health Survey
I've tried to restructure some variables so as to stset, but I don't know if I'm on the right track, as I'm getting some funny results
b5-whether the child is alive or not
b7- age at death in months
b2-year of birth
b1-month of birth
setting ending time of observation
*gen mend=.
*replace mend=60 if b5==1
*replace mend=b7 if b5==0
*tab mend, missing
gen month of observation for each child from their birth to the ending time of observation
*gen mnobs= mend-((2018-b2)*12)+60
*tab mnobs, m
------------------ copy up to and including the previous line ------------------
And then I went ahead to expand using 'mend', at this stage I'm not sure if I'm supposed to expand on 'mnobs' or not, but then 'mnobs' values doesn't look right
Did I get the recoding of 'mnobs' wrong?
*expand mend
*bysort pid: gen t = _n
*lab var t "spell month identified, by child"
*bysort pid: gen death=died==1 & _n==_N
*lab var death "binary depvar for cox hazard model"
------------------ copy up to and including the previous line ------------------
Now, I'm not sure if I'm to stset on 'mend' or 't' or even to fix 'mnobs' and stset on it, because when I run 'stsum' it doesn't return any value on any of the survival time (25%, 50%, 75%)
*stset t, failure(death) id(pid) scale(1)
*stsum
Please can I be shown where I got it wrong and how to fix it?
Thank you.
I've tried to restructure some variables so as to stset, but I don't know if I'm on the right track, as I'm getting some funny results
b5-whether the child is alive or not
b7- age at death in months
b2-year of birth
b1-month of birth
setting ending time of observation
*gen mend=.
*replace mend=60 if b5==1
*replace mend=b7 if b5==0
*tab mend, missing
gen month of observation for each child from their birth to the ending time of observation
*gen mnobs= mend-((2018-b2)*12)+60
*tab mnobs, m
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float pid byte(b5 b7) int b2 byte b1 float(mnobs mend study_time) byte died 25179 0 0 2013 12 0 0 0 1 22150 0 0 2013 12 0 0 0 1 10370 0 0 2013 12 0 0 0 1 13506 0 0 2013 11 0 0 0 1 17263 0 0 2013 8 0 0 0 1 32260 0 0 2013 9 0 0 0 1 9448 0 0 2013 12 0 0 0 1 32497 0 0 2013 9 0 0 0 1 3326 0 0 2013 10 0 0 0 1 29995 0 0 2013 12 0 0 0 1 27518 0 0 2013 9 0 0 0 1 15818 0 0 2013 10 0 0 0 1 9859 0 0 2013 11 0 0 0 1 20111 0 0 2013 12 0 0 0 1 21223 0 0 2013 9 0 0 0 1 20049 0 0 2013 9 0 0 0 1 27006 0 0 2013 12 0 0 0 1 5753 0 0 2013 10 0 0 0 1 7821 0 0 2013 12 0 0 0 1 16552 0 0 2013 10 0 0 0 1 10284 0 0 2013 10 0 0 0 1 1838 0 0 2013 12 0 0 0 1 25525 0 0 2013 11 0 0 0 1 15634 0 0 2013 12 0 0 0 1 26936 0 1 2013 12 1 1 1 1 10116 0 2 2013 12 2 2 2 1 22586 0 3 2013 11 3 3 3 1 12088 0 3 2013 11 3 3 3 1 17176 0 4 2013 12 4 4 4 1 159 0 6 2013 12 6 6 6 1 23474 0 6 2013 12 6 6 6 1 26987 0 7 2013 11 7 7 7 1 7345 0 7 2013 12 7 7 7 1 21739 0 8 2013 12 8 8 8 1 32871 0 8 2013 12 8 8 8 1 6043 0 9 2013 11 9 9 9 1 9768 0 10 2013 10 10 10 10 1 20814 0 11 2013 12 11 11 11 1 20838 0 11 2013 12 11 11 11 1 11379 0 11 2013 12 11 11 11 1 29293 0 0 2014 6 12 0 0 1 18159 0 0 2014 5 12 0 0 1 3974 0 0 2014 3 12 0 0 1 15249 0 0 2014 12 12 0 0 1 15445 0 0 2014 2 12 0 0 1 10306 0 0 2014 12 12 0 0 1 28956 0 0 2014 5 12 0 0 1 30566 0 0 2014 9 12 0 0 1 30270 0 0 2014 3 12 0 0 1 10568 0 0 2014 9 12 0 0 1 3421 0 0 2014 3 12 0 0 1 11903 0 0 2014 5 12 0 0 1 20273 0 0 2014 11 12 0 0 1 21955 0 0 2014 1 12 0 0 1 4051 0 0 2014 2 12 0 0 1 696 0 0 2014 6 12 0 0 1 10032 0 0 2014 1 12 0 0 1 26908 0 0 2014 10 12 0 0 1 18958 0 0 2014 3 12 0 0 1 15780 0 0 2014 9 12 0 0 1 13537 0 0 2014 10 12 0 0 1 15270 0 0 2014 4 12 0 0 1 25151 0 0 2014 3 12 0 0 1 6042 0 0 2014 12 12 0 0 1 10402 0 0 2014 12 12 0 0 1 30722 0 0 2014 7 12 0 0 1 24305 0 0 2014 4 12 0 0 1 6965 0 0 2014 12 12 0 0 1 12837 0 0 2014 7 12 0 0 1 13820 0 0 2014 8 12 0 0 1 12525 0 0 2014 3 12 0 0 1 15668 0 0 2014 4 12 0 0 1 29537 0 0 2014 10 12 0 0 1 3835 0 0 2014 1 12 0 0 1 20794 0 0 2014 5 12 0 0 1 10905 0 0 2014 2 12 0 0 1 5652 0 0 2014 12 12 0 0 1 16259 0 0 2014 11 12 0 0 1 17840 0 0 2014 10 12 0 0 1 21892 0 0 2014 1 12 0 0 1 30999 0 0 2014 1 12 0 0 1 33031 0 0 2014 2 12 0 0 1 31073 0 0 2014 6 12 0 0 1 9518 0 0 2014 5 12 0 0 1 1002 0 0 2014 2 12 0 0 1 5591 0 0 2014 2 12 0 0 1 5442 0 0 2014 9 12 0 0 1 16071 0 0 2014 2 12 0 0 1 27152 0 0 2014 10 12 0 0 1 12100 0 0 2014 4 12 0 0 1 30411 0 0 2014 8 12 0 0 1 6882 0 0 2014 8 12 0 0 1 3573 0 0 2014 3 12 0 0 1 26882 0 0 2014 12 12 0 0 1 13092 0 0 2014 3 12 0 0 1 16399 0 0 2014 6 12 0 0 1 8145 0 0 2014 6 12 0 0 1 5075 0 0 2014 10 12 0 0 1 20223 0 0 2014 9 12 0 0 1 30956 0 0 2014 10 12 0 0 1 end label values b5 B5 label def B5 0 "0. no", modify
And then I went ahead to expand using 'mend', at this stage I'm not sure if I'm supposed to expand on 'mnobs' or not, but then 'mnobs' values doesn't look right
Did I get the recoding of 'mnobs' wrong?
*expand mend
*bysort pid: gen t = _n
*lab var t "spell month identified, by child"
*bysort pid: gen death=died==1 & _n==_N
*lab var death "binary depvar for cox hazard model"
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(pid mnobs mend t death) 1 108 60 1 0 1 108 60 2 0 1 108 60 3 0 1 108 60 4 0 1 108 60 5 0 1 108 60 6 0 1 108 60 7 0 1 108 60 8 0 1 108 60 9 0 1 108 60 10 0 1 108 60 11 0 1 108 60 12 0 1 108 60 13 0 1 108 60 14 0 1 108 60 15 0 1 108 60 16 0 1 108 60 17 0 1 108 60 18 0 1 108 60 19 0 1 108 60 20 0 1 108 60 21 0 1 108 60 22 0 1 108 60 23 0 1 108 60 24 0 1 108 60 25 0 1 108 60 26 0 1 108 60 27 0 1 108 60 28 0 1 108 60 29 0 1 108 60 30 0 1 108 60 31 0 1 108 60 32 0 1 108 60 33 0 1 108 60 34 0 1 108 60 35 0 1 108 60 36 0 1 108 60 37 0 1 108 60 38 0 1 108 60 39 0 1 108 60 40 0 1 108 60 41 0 1 108 60 42 0 1 108 60 43 0 1 108 60 44 0 1 108 60 45 0 1 108 60 46 0 1 108 60 47 0 1 108 60 48 0 1 108 60 49 0 1 108 60 50 0 1 108 60 51 0 1 108 60 52 0 1 108 60 53 0 1 108 60 54 0 1 108 60 55 0 1 108 60 56 0 1 108 60 57 0 1 108 60 58 0 1 108 60 59 0 1 108 60 60 0 2 108 60 1 0 2 108 60 2 0 2 108 60 3 0 2 108 60 4 0 2 108 60 5 0 2 108 60 6 0 2 108 60 7 0 2 108 60 8 0 2 108 60 9 0 2 108 60 10 0 2 108 60 11 0 2 108 60 12 0 2 108 60 13 0 2 108 60 14 0 2 108 60 15 0 2 108 60 16 0 2 108 60 17 0 2 108 60 18 0 2 108 60 19 0 2 108 60 20 0 2 108 60 21 0 2 108 60 22 0 2 108 60 23 0 2 108 60 24 0 2 108 60 25 0 2 108 60 26 0 2 108 60 27 0 2 108 60 28 0 2 108 60 29 0 2 108 60 30 0 2 108 60 31 0 2 108 60 32 0 2 108 60 33 0 2 108 60 34 0 2 108 60 35 0 2 108 60 36 0 2 108 60 37 0 2 108 60 38 0 2 108 60 39 0 2 108 60 40 0 end
Now, I'm not sure if I'm to stset on 'mend' or 't' or even to fix 'mnobs' and stset on it, because when I run 'stsum' it doesn't return any value on any of the survival time (25%, 50%, 75%)
*stset t, failure(death) id(pid) scale(1)
*stsum
Please can I be shown where I got it wrong and how to fix it?
Thank you.
Comment