Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Survival Analysis using Nigeria Demographic and Health Survey data

    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




    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
    ------------------ 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"



    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
    ------------------ 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.






  • #2
    I'm not sure what you're trying to do with this data--it seems far more complicated than necessary.

    To -stset- your data, all you need are: a variable indicating whether the child died or is still alive (censored) and either:
    1. date of birth, date of death if dead, date of survey if alive, OR
    2. age at death if date, age at survey if alive.

    Unless you are going to have time-varying covariates (which your example data gives no evidence of) you only need a single observation per child.

    Now, I don't understand your data. In your example data. Every child has an age at death shown (b7). This suggests that all of the children in the survey died, and none survived. If that is true of your full data set, you cannot estimate child mortality from this data: you also need the same information about the children who didn't die in order to do that.

    So, if the data set does contain children who didn't die, please post back with a new data example that contains some of them as well. Also, include any variable(s) that show, or enable calculation of, their age at the time of the survey, or the date of the survey.

    Comment


    • #3
      Thank you very much Clyde for your response,

      I don't have time-varying covariates, as its a cross-sectional data. Looks like a discrete data, which made me think it needed to be expanded.

      The full dataset has 33,924 children, of which 3211 died, and their ages (in months) at the time of death are contained in b7

      b3_tm- date of birth
      v008_tm- date of survey
      b5- survival status (dead or alive)
      b7- age at death (in months)
      s220bm- month of death
      s220by- year of death

      *gen agemnth = v008_tm - b3_tm //my way of generating the age of the child at the time of survey, but it accumulates additional months for those children that died before the survey.


      Initially I generated the study_time and censoring status, which you helped me with previously with the codes below:

      gen study_time = cond(missing(b7), agemnth, b7)
      label variable study_time "Length of time exposed to risk of death"


      gen byte died = !missing(b7) //failure variable
      label variable died "Censoring status"


      It looked alright and I went ahead to stset thus:
      *stset study_time, id(uniqueid) failure(died==1)

      But then when I 'stsum' it doesn't return any value for the survival times, indicating that I'm still doing something wrong. Which I'm lost on.


      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(uniqueid b3_tm v008_tm) byte(b5 b7 s220bm) int s220by float(agemnth study_time) byte died
        1 691 704 1  .  .    . 13 13 0
        2 695 704 1  .  .    .  9  9 0
        3 687 704 1  .  .    . 17 17 0
        4 673 704 1  .  .    . 31 31 0
        5 665 704 1  .  .    . 39 39 0
        6 682 704 1  .  .    . 22 22 0
        7 680 704 1  .  .    . 24 24 0
        8 665 704 0  0  6 2015 39  0 1
        9 681 704 1  .  .    . 23 23 0
       10 692 704 1  .  .    . 12 12 0
       11 695 704 1  .  .    .  9  9 0
       12 669 704 1  .  .    . 35 35 0
       13 686 704 1  .  .    . 18 18 0
       14 684 704 1  .  .    . 20 20 0
       15 644 704 1  .  .    . 60 60 0
       16 686 704 1  .  .    . 18 18 0
       17 699 704 1  .  .    .  5  5 0
       18 658 704 1  .  .    . 46 46 0
       19 678 704 1  .  .    . 26 26 0
       20 650 704 1  .  .    . 54 54 0
       21 667 704 1  .  .    . 37 37 0
       22 653 704 1  .  .    . 51 51 0
       23 673 704 1  .  .    . 31 31 0
       24 649 704 1  .  .    . 55 55 0
       25 677 704 1  .  .    . 27 27 0
       26 689 704 1  .  .    . 15 15 0
       27 665 704 1  .  .    . 39 39 0
       28 698 704 1  .  .    .  6  6 0
       29 675 704 1  .  .    . 29 29 0
       30 689 704 0  0  6 2017 15  0 1
       31 695 704 1  .  .    .  9  9 0
       32 664 704 1  .  .    . 40 40 0
       33 681 704 1  .  .    . 23 23 0
       34 692 704 1  .  .    . 12 12 0
       35 669 704 1  .  .    . 35 35 0
       36 648 704 1  .  .    . 56 56 0
       37 690 704 1  .  .    . 14 14 0
       38 664 704 1  .  .    . 40 40 0
       39 647 704 1  .  .    . 57 57 0
       40 662 704 1  .  .    . 42 42 0
       41 699 704 1  .  .    .  5  5 0
       42 662 704 1  .  .    . 42 42 0
       43 665 704 1  .  .    . 39 39 0
       44 665 704 1  .  .    . 39 39 0
       45 650 704 1  .  .    . 54 54 0
       46 685 704 1  .  .    . 19 19 0
       47 652 704 1  .  .    . 52 52 0
       48 662 704 1  .  .    . 42 42 0
       49 700 707 1  .  .    .  7  7 0
       50 679 707 1  .  .    . 28 28 0
       51 654 707 1  .  .    . 53 53 0
       52 677 707 0  5 11 2016 30  5 1
       53 679 707 1  .  .    . 28 28 0
       54 694 707 1  .  .    . 13 13 0
       55 670 707 1  .  .    . 37 37 0
       56 652 707 0  0  5 2014 55  0 1
       57 684 707 1  .  .    . 23 23 0
       58 674 707 1  .  .    . 33 33 0
       59 680 707 1  .  .    . 27 27 0
       60 663 707 0 36  8 2018 44 36 1
       61 687 707 1  .  .    . 20 20 0
       62 683 707 1  .  .    . 24 24 0
       63 649 707 1  .  .    . 58 58 0
       64 673 707 1  .  .    . 34 34 0
       65 695 707 1  .  .    . 12 12 0
       66 663 707 1  .  .    . 44 44 0
       67 704 707 1  .  .    .  3  3 0
       68 672 706 1  .  .    . 34 34 0
       69 692 706 1  .  .    . 14 14 0
       70 701 706 1  .  .    .  5  5 0
       71 696 706 1  .  .    . 10 10 0
       72 666 706 1  .  .    . 40 40 0
       73 694 706 1  .  .    . 12 12 0
       74 670 706 1  .  .    . 36 36 0
       75 687 706 1  .  .    . 19 19 0
       76 648 706 1  .  .    . 58 58 0
       77 689 706 1  .  .    . 17 17 0
       78 666 706 1  .  .    . 40 40 0
       79 667 706 1  .  .    . 39 39 0
       80 648 706 1  .  .    . 58 58 0
       81 653 706 1  .  .    . 53 53 0
       82 653 706 1  .  .    . 53 53 0
       83 705 706 1  .  .    .  1  1 0
       84 656 706 1  .  .    . 50 50 0
       85 704 706 1  .  .    .  2  2 0
       86 678 706 1  .  .    . 28 28 0
       87 682 706 1  .  .    . 24 24 0
       88 693 706 1  .  .    . 13 13 0
       89 693 706 1  .  .    . 13 13 0
       90 656 706 1  .  .    . 50 50 0
       91 660 706 1  .  .    . 46 46 0
       92 660 706 1  .  .    . 46 46 0
       93 687 706 1  .  .    . 19 19 0
       94 700 706 1  .  .    .  6  6 0
       95 674 706 1  .  .    . 32 32 0
       96 647 706 1  .  .    . 59 59 0
       97 697 706 1  .  .    .  9  9 0
       98 676 706 1  .  .    . 30 30 0
       99 676 706 1  .  .    . 30 30 0
      100 663 706 1  .  .    . 43 43 0
      end
      format %tmNN-CCYY b3_tm
      format %tmNN-CCYY v008_tm
      label values b5 B5
      label def B5 0 "0. no", modify
      label def B5 1 "1. yes", modify
      label values s220bm S220BM
      label def S220BM 5 "5. may", modify
      label def S220BM 6 "6. june", modify
      label def S220BM 8 "8. august", modify
      label def S220BM 11 "11. november", modify
      label values s220by S220BY
      ------------------ copy up to and including the previous line ------------------


      Thanks again for your help.

      Comment


      • #4
        What you did looks right to me.

        And I would not expect -stsum- to show you any results other than total time at risk, incidence rate, and number of subjects. As for the survival time for percentages dead outputs of -stsum- bear in mind that your total mortality probability is around 10%. So there is no time at which 25%, 50%, or 75% of the babies will have died. That's why those are shown as missing values.

        The only concern I have about this is that there are a few babies who died in the same month they were born. Because time is only measured in months, these babies are considered to have 0 survival time, which means they are not counted in the analysis at all. That's a problem. The only perfect solution would be to have exact dates and times of birth and death. But I'm guessing that information at that level of refinement is not available to you. So I would suggest that you do this, before you -stset- the data:

        Code:
        replace study_time = study_time + 0.01 if died & study_time == 0
        That way these babies will be counted. The 0.01 month corresponds to about 8 hours of life. Of course, they might have even lived four weeks or so, but this is a conservative modification, and it will not affect the survival probabilities beyond that point in time.

        Comment


        • #5
          Thanks much Clyde for your help,

          Now I understand better what those survival times mean, I've been thinking they mean survivals at those percentage points.

          I also updated the code for study_time to capture the babies that died in the first month of birth like you suggested, but then after -stseting-, I observed it excluded the babies that were born in the month of the interview and were still living (censored), whose study_time was also 0, so I edited the code to

          *replace study_time = study_time + 0.01 if study_time == 0

          And then I have this after -stset- with 0 exclusions.

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input float(pid b3_tm v008_tm) byte(b5 b7 s220bm) int s220by float(agemnth study_time) byte(died _st _d) double _t byte _t0
          25179 647 704 0  0 12 2013 57 .01 1 1 1 .009999999776482582 0
          22150 647 704 0  0 12 2013 57 .01 1 1 1 .009999999776482582 0
          10370 647 706 0  0 12 2013 59 .01 1 1 1 .009999999776482582 0
          13506 646 706 0  0 11 2013 60 .01 1 1 1 .009999999776482582 0
          17263 643 703 0  0  8 2013 60 .01 1 1 1 .009999999776482582 0
          32260 644 704 0  0  9 2013 60 .01 1 1 1 .009999999776482582 0
           9448 647 704 0  0 12 2013 57 .01 1 1 1 .009999999776482582 0
          32497 644 704 0  0  9 2013 60 .01 1 1 1 .009999999776482582 0
           3326 645 704 0  0 10 2013 59 .01 1 1 1 .009999999776482582 0
          29995 647 705 0  0 12 2013 58 .01 1 1 1 .009999999776482582 0
          27518 644 704 0  0  9 2013 60 .01 1 1 1 .009999999776482582 0
          15818 645 704 0  0 10 2013 59 .01 1 1 1 .009999999776482582 0
           9859 646 705 0  0 11 2013 59 .01 1 1 1 .009999999776482582 0
          20111 647 704 0  0 12 2013 57 .01 1 1 1 .009999999776482582 0
          21223 644 704 0  0  9 2013 60 .01 1 1 1 .009999999776482582 0
          20049 644 704 0  0  9 2013 60 .01 1 1 1 .009999999776482582 0
          27006 647 705 0  0 12 2013 58 .01 1 1 1 .009999999776482582 0
           5753 645 704 0  0 10 2013 59 .01 1 1 1 .009999999776482582 0
           7821 647 706 0  0 12 2013 59 .01 1 1 1 .009999999776482582 0
          16552 645 704 0  0 10 2013 59 .01 1 1 1 .009999999776482582 0
          10284 645 704 0  0 10 2013 59 .01 1 1 1 .009999999776482582 0
           1838 647 705 0  0 12 2013 58 .01 1 1 1 .009999999776482582 0
          25525 646 706 0  0 11 2013 60 .01 1 1 1 .009999999776482582 0
          15634 647 706 0  0  1 2014 59 .01 1 1 1 .009999999776482582 0
          26936 647 705 0  1  1 2014 58   1 1 1 1                   1 0
          10116 647 706 0  2  2 2014 59   2 1 1 1                   2 0
          22586 646 705 0  3  2 2014 59   3 1 1 1                   3 0
          12088 646 705 0  3  2 2014 59   3 1 1 1                   3 0
          17176 647 705 0  4  4 2014 58   4 1 1 1                   4 0
            159 647 704 0  6  6 2014 57   6 1 1 1                   6 0
          23474 647 707 0  6  6 2014 60   6 1 1 1                   6 0
          26987 646 704 0  7  6 2014 58   7 1 1 1                   7 0
           7345 647 705 0  7  7 2014 58   7 1 1 1                   7 0
          21739 647 706 0  8  8 2014 59   8 1 1 1                   8 0
          32871 647 704 0  8  8 2014 57   8 1 1 1                   8 0
           6043 646 704 0  9  8 2014 58   9 1 1 1                   9 0
           9768 645 705 0 10  8 2014 60  10 1 1 1                  10 0
          20814 647 706 0 11 11 2014 59  11 1 1 1                  11 0
          20838 647 706 0 11 11 2014 59  11 1 1 1                  11 0
          11379 647 704 0 11 11 2014 57  11 1 1 1                  11 0
          29293 653 704 0  0  6 2014 51 .01 1 1 1 .009999999776482582 0
          18159 652 703 0  0  5 2014 51 .01 1 1 1 .009999999776482582 0
           3974 650 704 0  0  3 2015 54 .01 1 1 1 .009999999776482582 0
          15249 659 707 0  0 12 2014 48 .01 1 1 1 .009999999776482582 0
          15445 649 707 0  0  2 2014 58 .01 1 1 1 .009999999776482582 0
          10306 659 704 0  0 12 2014 45 .01 1 1 1 .009999999776482582 0
          28956 652 705 0  0  6 2014 53 .01 1 1 1 .009999999776482582 0
          30566 656 705 0  0  9 2014 49 .01 1 1 1 .009999999776482582 0
          30270 650 704 0  0  3 2014 54 .01 1 1 1 .009999999776482582 0
          10568 656 707 0  0 10 2014 51 .01 1 1 1 .009999999776482582 0
           3421 650 705 0  0  3 2014 55 .01 1 1 1 .009999999776482582 0
          11903 652 707 0  0  5 2014 55 .01 1 1 1 .009999999776482582 0
          20273 658 704 0  0 11 2014 46 .01 1 1 1 .009999999776482582 0
          21955 648 706 0  0  1 2014 58 .01 1 1 1 .009999999776482582 0
           4051 649 704 0  0  2 2014 55 .01 1 1 1 .009999999776482582 0
            696 653 706 0  0  6 2014 53 .01 1 1 1 .009999999776482582 0
          10032 648 705 0  0  1 2014 57 .01 1 1 1 .009999999776482582 0
          26908 657 705 0  0 10 2014 48 .01 1 1 1 .009999999776482582 0
          18958 650 704 0  0  3 2014 54 .01 1 1 1 .009999999776482582 0
          15780 656 706 0  0  9 2014 50 .01 1 1 1 .009999999776482582 0
          13537 657 706 0  0 11 2014 49 .01 1 1 1 .009999999776482582 0
          15270 651 706 0  0  4 2014 55 .01 1 1 1 .009999999776482582 0
          25151 650 704 0  0  4 2014 54 .01 1 1 1 .009999999776482582 0
           6042 659 704 0  0 12 2014 45 .01 1 1 1 .009999999776482582 0
          10402 659 706 0  0 12 2014 47 .01 1 1 1 .009999999776482582 0
          30722 654 707 0  0  7 2014 53 .01 1 1 1 .009999999776482582 0
          24305 651 704 0  0  4 2014 53 .01 1 1 1 .009999999776482582 0
           6965 659 703 0  0 12 2014 44 .01 1 1 1 .009999999776482582 0
          12837 654 705 0  0  7 2014 51 .01 1 1 1 .009999999776482582 0
          13820 655 707 0  0  8 2014 52 .01 1 1 1 .009999999776482582 0
          12525 650 707 0  0  3 2014 57 .01 1 1 1 .009999999776482582 0
          15668 651 707 0  0  4 2014 56 .01 1 1 1 .009999999776482582 0
          29537 657 704 0  0 11 2014 47 .01 1 1 1 .009999999776482582 0
           3835 648 704 0  0  1 2014 56 .01 1 1 1 .009999999776482582 0
          20794 652 707 0  0  5 2014 55 .01 1 1 1 .009999999776482582 0
          10905 649 707 0  0  2 2014 58 .01 1 1 1 .009999999776482582 0
           5652 659 704 0  0 12 2014 45 .01 1 1 1 .009999999776482582 0
          16259 658 704 0  0 11 2014 46 .01 1 1 1 .009999999776482582 0
          17840 657 706 0  0 10 2014 49 .01 1 1 1 .009999999776482582 0
          21892 648 704 0  0  1 2014 56 .01 1 1 1 .009999999776482582 0
          30999 648 707 0  0 98 2014 59 .01 1 1 1 .009999999776482582 0
          33031 649 707 0  0  2 2014 58 .01 1 1 1 .009999999776482582 0
          31073 653 703 0  0  6 2014 50 .01 1 1 1 .009999999776482582 0
           9518 652 704 0  0  5 2014 52 .01 1 1 1 .009999999776482582 0
           1002 649 706 0  0  2 2014 57 .01 1 1 1 .009999999776482582 0
           5591 649 704 0  0  2 2014 55 .01 1 1 1 .009999999776482582 0
           5442 656 705 0  0  9 2014 49 .01 1 1 1 .009999999776482582 0
          16071 649 706 0  0  2 2014 57 .01 1 1 1 .009999999776482582 0
          27152 657 706 0  0 10 2014 49 .01 1 1 1 .009999999776482582 0
          12100 651 704 0  0  4 2014 53 .01 1 1 1 .009999999776482582 0
          30411 655 705 0  0  8 2014 50 .01 1 1 1 .009999999776482582 0
           6882 655 706 0  0  8 2014 51 .01 1 1 1 .009999999776482582 0
           3573 650 706 0  0  3 2014 56 .01 1 1 1 .009999999776482582 0
          26882 659 705 0  0 12 2014 46 .01 1 1 1 .009999999776482582 0
          13092 650 705 0  0  3 2014 55 .01 1 1 1 .009999999776482582 0
          16399 653 706 0  0  6 2014 53 .01 1 1 1 .009999999776482582 0
           8145 653 706 0  0  6 2014 53 .01 1 1 1 .009999999776482582 0
           5075 657 705 0  0 10 2014 48 .01 1 1 1 .009999999776482582 0
          20223 656 704 0  0  9 2014 48 .01 1 1 1 .009999999776482582 0
          30956 657 707 0  0 10 2014 50 .01 1 1 1 .009999999776482582 0
          end
          format %tmNN-CCYY b3_tm
          format %tmNN-CCYY v008_tm
          label values b5 B5
          label def B5 0 "0. no", modify
          label values s220bm S220BM
          label def S220BM 1 "1. january", modify
          label def S220BM 2 "2. february", modify
          label def S220BM 3 "3. march", modify
          label def S220BM 4 "4. april", modify
          label def S220BM 5 "5. may", modify
          label def S220BM 6 "6. june", modify
          label def S220BM 7 "7. july", modify
          label def S220BM 8 "8. august", modify
          label def S220BM 9 "9. september", modify
          label def S220BM 10 "10. october", modify
          label def S220BM 11 "11. november", modify
          label def S220BM 12 "12. december", modify
          label def S220BM 98 "98. don't know month", modify
          label values s220by S220BY
          ------------------ copy up to and including the previous line ------------------




          Please do you think everything looks good for further analysis (cox regression, and cox multilevel analysis)?

          Thanks again.
          Last edited by Love Umesi; 08 Apr 2021, 21:12.

          Comment


          • #6
            Yes, I think you are good to go now.

            Comment


            • #7
              Alright, thanks a lot Clyde

              Comment


              • #8
                Originally posted by Love Umesi View Post
                Thank you very much Clyde for your response,

                I don't have time-varying covariates, as its a cross-sectional data. Looks like a discrete data, which made me think it needed to be expanded.

                The full dataset has 33,924 children, of which 3211 died, and their ages (in months) at the time of death are contained in b7

                b3_tm- date of birth
                v008_tm- date of survey
                b5- survival status (dead or alive)
                b7- age at death (in months)
                s220bm- month of death
                s220by- year of death

                *gen agemnth = v008_tm - b3_tm //my way of generating the age of the child at the time of survey, but it accumulates additional months for those children that died before the survey.


                Initially I generated the study_time and censoring status, which you helped me with previously with the codes below:

                gen study_time = cond(missing(b7), agemnth, b7)
                label variable study_time "Length of time exposed to risk of death"


                gen byte died = !missing(b7) //failure variable
                label variable died "Censoring status"


                It looked alright and I went ahead to stset thus:
                *stset study_time, id(uniqueid) failure(died==1)

                But then when I 'stsum' it doesn't return any value for the survival times, indicating that I'm still doing something wrong. Which I'm lost on.
                Statistics are very helpful when trying to make predictions about the health situation in a particular area of the country. I read on https://samplius.com/free-essay-examples/health/ a lot of information about health and situation monitoring.

                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input float(uniqueid b3_tm v008_tm) byte(b5 b7 s220bm) int s220by float(agemnth study_time) byte died
                1 691 704 1 . . . 13 13 0
                2 695 704 1 . . . 9 9 0
                3 687 704 1 . . . 17 17 0
                4 673 704 1 . . . 31 31 0
                5 665 704 1 . . . 39 39 0
                6 682 704 1 . . . 22 22 0
                7 680 704 1 . . . 24 24 0
                8 665 704 0 0 6 2015 39 0 1
                9 681 704 1 . . . 23 23 0
                10 692 704 1 . . . 12 12 0
                11 695 704 1 . . . 9 9 0
                12 669 704 1 . . . 35 35 0
                13 686 704 1 . . . 18 18 0
                14 684 704 1 . . . 20 20 0
                15 644 704 1 . . . 60 60 0
                16 686 704 1 . . . 18 18 0
                17 699 704 1 . . . 5 5 0
                18 658 704 1 . . . 46 46 0
                19 678 704 1 . . . 26 26 0
                20 650 704 1 . . . 54 54 0
                21 667 704 1 . . . 37 37 0
                22 653 704 1 . . . 51 51 0
                23 673 704 1 . . . 31 31 0
                24 649 704 1 . . . 55 55 0
                25 677 704 1 . . . 27 27 0
                26 689 704 1 . . . 15 15 0
                27 665 704 1 . . . 39 39 0
                28 698 704 1 . . . 6 6 0
                29 675 704 1 . . . 29 29 0
                30 689 704 0 0 6 2017 15 0 1
                31 695 704 1 . . . 9 9 0
                32 664 704 1 . . . 40 40 0
                33 681 704 1 . . . 23 23 0
                34 692 704 1 . . . 12 12 0
                35 669 704 1 . . . 35 35 0
                36 648 704 1 . . . 56 56 0
                37 690 704 1 . . . 14 14 0
                38 664 704 1 . . . 40 40 0
                39 647 704 1 . . . 57 57 0
                40 662 704 1 . . . 42 42 0
                41 699 704 1 . . . 5 5 0
                42 662 704 1 . . . 42 42 0
                43 665 704 1 . . . 39 39 0
                44 665 704 1 . . . 39 39 0
                45 650 704 1 . . . 54 54 0
                46 685 704 1 . . . 19 19 0
                47 652 704 1 . . . 52 52 0
                48 662 704 1 . . . 42 42 0
                49 700 707 1 . . . 7 7 0
                50 679 707 1 . . . 28 28 0
                51 654 707 1 . . . 53 53 0
                52 677 707 0 5 11 2016 30 5 1
                53 679 707 1 . . . 28 28 0
                54 694 707 1 . . . 13 13 0
                55 670 707 1 . . . 37 37 0
                56 652 707 0 0 5 2014 55 0 1
                57 684 707 1 . . . 23 23 0
                58 674 707 1 . . . 33 33 0
                59 680 707 1 . . . 27 27 0
                60 663 707 0 36 8 2018 44 36 1
                61 687 707 1 . . . 20 20 0
                62 683 707 1 . . . 24 24 0
                63 649 707 1 . . . 58 58 0
                64 673 707 1 . . . 34 34 0
                65 695 707 1 . . . 12 12 0
                66 663 707 1 . . . 44 44 0
                67 704 707 1 . . . 3 3 0
                68 672 706 1 . . . 34 34 0
                69 692 706 1 . . . 14 14 0
                70 701 706 1 . . . 5 5 0
                71 696 706 1 . . . 10 10 0
                72 666 706 1 . . . 40 40 0
                73 694 706 1 . . . 12 12 0
                74 670 706 1 . . . 36 36 0
                75 687 706 1 . . . 19 19 0
                76 648 706 1 . . . 58 58 0
                77 689 706 1 . . . 17 17 0
                78 666 706 1 . . . 40 40 0
                79 667 706 1 . . . 39 39 0
                80 648 706 1 . . . 58 58 0
                81 653 706 1 . . . 53 53 0
                82 653 706 1 . . . 53 53 0
                83 705 706 1 . . . 1 1 0
                84 656 706 1 . . . 50 50 0
                85 704 706 1 . . . 2 2 0
                86 678 706 1 . . . 28 28 0
                87 682 706 1 . . . 24 24 0
                88 693 706 1 . . . 13 13 0
                89 693 706 1 . . . 13 13 0
                90 656 706 1 . . . 50 50 0
                91 660 706 1 . . . 46 46 0
                92 660 706 1 . . . 46 46 0
                93 687 706 1 . . . 19 19 0
                94 700 706 1 . . . 6 6 0
                95 674 706 1 . . . 32 32 0
                96 647 706 1 . . . 59 59 0
                97 697 706 1 . . . 9 9 0
                98 676 706 1 . . . 30 30 0
                99 676 706 1 . . . 30 30 0
                100 663 706 1 . . . 43 43 0
                end
                format %tmNN-CCYY b3_tm
                format %tmNN-CCYY v008_tm
                label values b5 B5
                label def B5 0 "0. no", modify
                label def B5 1 "1. yes", modify
                label values s220bm S220BM
                label def S220BM 5 "5. may", modify
                label def S220BM 6 "6. june", modify
                label def S220BM 8 "8. august", modify
                label def S220BM 11 "11. november", modify
                label values s220by S220BY
                ------------------ copy up to and including the previous line ------------------


                Thanks again for your help.
                Thank you very much for your help.

                Comment

                Working...
                X