Announcement

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

  • log rank test of 1 variable with multiple groups

    what would be the code to carry out a log rank test of 1 variable with multiple groups, e.g. i want to compare the survival of caucasians vs. african-americans or caucasians vs. asians all captured within 1 variable called ethnicity. thanks

  • #2
    -help sts test-

    More generally, if you are going to work with survival data, it is best that you first acquaint yourself with Stata's approach to it. Run -help st- and click on the link near the top of the page to the -st- chapter of the [ST] volume of the PDF documentation that comes installed with Stata. Read that chapter. It will familiarize you with the overall scheme that Stata uses as well as several commands that will prove helpful.
    Last edited by Clyde Schechter; 16 Sep 2017, 19:07.

    Comment


    • #3
      .
      Last edited by manjusha hurry; 16 Sep 2017, 19:13.

      Comment


      • #4
        certainly had a check through the help file, by creating other variables and hence using the strata function. except i think i am just going in circles. i am trying to run the log rank test in var1, if var1=1 vs. var1=4 or var1=1 vs. var1=2. apology if this is a basic question. just can't figure it out.

        Comment


        • #5
          Code:
          label define Race 1 "african-americans" 2 asians 3 caucasians
          encode ethnicity, generate(race) label(Race) noextend
          tabulate race, generate(race)
          
          stset time, failure(fail=1)
          sts test race1 if inlist(race, 1, 2)
          display in smcl as text "Pr>chi2 = " as result %06.4f min(chi2tail(1, r(chi2)) * 3, 1)
          sts test race2 if inlist(race, 2, 3)
          display in smcl as text "Pr>chi2 = " as result %06.4f min(chi2tail(1, r(chi2)) * 3, 1)
          sts test race3 if inlist(race, 1, 3)
          display in smcl as text "Pr>chi2 = " as result %06.4f min(chi2tail(1, r(chi2)) * 3, 1)

          Comment


          • #6
            Thank you Joseph. I'll have a go at this!

            Comment


            • #7
              Manjusha:
              probably the first line of Joseph's helpful code should be re-written as:
              Code:
              label define Race 1 "african-americans" 2 "asians" 3 "caucasians"
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                Thanks for the follow-up Carlo, certainly helped. worked out well

                Comment

                Working...
                X