Announcement

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

  • Survival Analysis using Nigeria Demographic and Health Survey data

    Hello everyone,

    Please how do I create the 'study time/time variable', which is the months to death or date of interview for those that were right-censored, to be used in survival analysis using DHS data?

    I understand I need to use the id, date of birth (b3_tm), age at death in months (b7), and date of interview (v008_tm) variables to create the time variable needed for the analysis.

    Below is the dataex code
    Thank you for your help.




    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str16 id float b3_tm byte b7 float v008_tm
    "        1  2  21" 566  . 583
    "        1  2  22" 538  . 583
    "        1  4  21" 559  . 583
    "        1  4  22" 559  . 583
    "        1  4  23" 535  . 583
    "        1 36  21" 581  . 583
    "        1 36  22" 557  . 583
    "        1 38  21" 572  . 583
    "        1 38  71" 574  . 583
    "        1 38  72" 533  . 583
    "        1 55  21" 537  . 583
    "        1 57  21" 564  . 583
    "        1 57  22" 527  . 583
    "        1 63  41" 576  . 583
    "        1 63  42" 536  . 583
    "        1 67  71" 533  . 583
    "        1 69  21" 580  . 583
    "        1 73  21" 573  . 583
    "        1 73  22" 553  . 583
    "        1 75  21" 575  . 583
    "        1 75  22" 558  2 583
    "        1 78  21" 581  . 583
    "        1 78  22" 546  . 583
    "        1 81  11" 580  . 583
    "        1 81  12" 546  . 583
    "        1 82  21" 563  . 583
    "        1 82  22" 545  4 583
    "        1 82  71" 564  . 583
    "        1 82  72" 533  . 583
    "        1 84  21" 577  . 583
    "        1 86  21" 558  . 583
    "        1 86  22" 533  . 583
    "        2  2  21" 573  0 581
    "        2  2  22" 561  . 581
    "        2  4  21" 553  . 581
    "        2  4  22" 528 36 581
    "        2  7  21" 529  . 581
    "        2  7  31" 565  . 581
    "        2  7  32" 537  . 581
    "        2 14  21" 551  . 581
    "        2 14  22" 527 13 581
    "        2 19  21" 578  . 581
    "        2 19  22" 544  . 581
    "        2 19  23" 531 36 581
    "        2 22  31" 579  . 581
    "        2 22  32" 557  . 581
    "        2 22  33" 529  . 581
    "        2 24  21" 555  . 581
    "        2 27  21" 555  . 581
    "        2 27  31" 572  . 581
    "        2 27  32" 528  . 581
    "        2 27 171" 529  8 581
    "        2 29  21" 571  . 581
    "        2 29  22" 529  . 581
    "        2 32  31" 567  . 581
    "        2 32  32" 544  . 581
    "        2 34  21" 573  . 581
    "        2 34  22" 546  . 581
    "        2 34  31" 572  . 581
    "        2 34  32" 540  . 581
    "        2 41  21" 523  . 581
    "        2 44  21" 576  . 581
    "        2 49  21" 558  . 581
    "        2 56  21" 566  . 581
    "        2 56  22" 541 19 581
    "        2 61  61" 546  . 581
    "        2 61  62" 535  . 581
    "        2 64  21" 569  . 581
    "        2 64  31" 530  . 581
    "        2 71  21" 567 12 581
    "        2 71  22" 557 10 581
    "        2 76  21" 580  . 581
    "        2 88  21" 564  . 581
    "        2 88  22" 546 20 581
    "        2 88  31" 548  . 581
    "        2 93  21" 560  . 581
    "        2 93  22" 532  . 581
    "        2 96  21" 580  . 581
    "        2 96  22" 529  . 581
    "        2 98  21" 564  . 581
    "        2 98  22" 534  . 581
    "        2101  21" 574  . 581
    "        3  1  21" 528  . 581
    "        3  3  21" 580  . 581
    "        3  3  22" 560  . 581
    "        3  3  23" 527  . 581
    "        3  5  21" 544  . 581
    "        3  8  21" 557  . 581
    "        3  8  22" 533  . 581
    "        3 14  21" 549  . 581
    "        3 17  21" 557  . 581
    "        3 17  22" 537  . 581
    "        3 21  21" 558  . 581
    "        3 23  21" 552  . 581
    "        3 25  21" 557  . 581
    "        3 30  61" 526 21 581
    "        3 32  21" 562  . 581
    "        3 32  22" 540  . 581
    "        3 34  21" 545  . 581
    "        3 37  21" 563  . 581
    end
    format %tmNN-CCYY b3_tm
    format %tmNN-CCYY v008_tm

  • #2
    Code:
    gen age_at_interview = v008_tm - b3_tm
    gen study_time = cond(missing(b7), age_at_interview, b7)
    gen byte died = !missing(b7)
    stset study_time, failure(died == 1)

    Comment


    • #3
      Hello Clyde,

      Many thanks for your response.
      Much appreciated.

      Comment


      • #4
        Hello Clyde,

        Please I will like to further ask how I can reshape the data from wide to long

        Thank you.

        Comment


        • #5
          The example data in #2 looks to me to already be long. What exactly do you want the result to look like?

          Comment


          • #6
            To be honest its quite confusing to me.

            However, I read that the data set (for discrete time hazard models) has to be re-organised so that, for each child, there are as many data rows as there are time intervals at risk of death occurring for each child. Going from one row of data per child, to another data set in which each child contributes Ti rows, where Ti is the number of time periods (e.g. months) the child was at risk of death till the event occurred or child was censored.

            Comment


            • #7
              Isn't that what you already have? It looks like it to me.

              Comment


              • #8
                That's not what I have now.

                Now the data gives one row per child per study time, but if I understand correctly it should be converted or split to give for each child the number of rows, equivalent to the number of months, the child was observed in the study. For instance, if a child lived for 2 months before dying, then he will have 2 rows...the first will have '0' in the 'died' column, while the second row will have '1' in the 'died' column, signifying exit from the study.

                Comment


                • #9
                  No, you do not need an observation in every time period. At most, you need an observation every time something changes.

                  Actually, in your case, I don't think you need more than one observation per child. You have not mentioned any time-varying predictors or covariates in your model. So if there aren't any of those, you can reduce your data to a single observation per child containing the child's age at death, or the final time observed in the study for those who did not die, and an indicator of which of those situations applies, along with the values of any predictor variables.

                  Comment


                  • #10
                    Alright Clyde, thanks for your help.

                    Comment


                    • #11
                      But I have time-varying predictor such as 'level of education'

                      Comment


                      • #12
                        That's different, then. So you need an observation every time one of the time-varying predictors changes.

                        Comment


                        • #13
                          Okay, thank you.

                          Comment

                          Working...
                          X