Announcement

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

  • Producing an adjusted Kaplan Meier with a risk table and confidence intervals, and log-rank

    I'm struggling with producing a KM curve with its corresponding 95% CIs and risk table when I'm adjusting for a variable. Here is my data:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(No Genderm1 Age) int _intervention_date byte Calcification int length_calc byte lengthgrade int circ_calc byte(calcgrade interaction RIP) int(Timetodeath M)
     1 0 77 20598 1   0 1 150 2 3 0 2871 23469
     2 1 56 20517 1  10 1  60 1 1 1   22     .
     3 1 84 20033 1  45 1 220 3 5 1 3140     .
     4 0 70 20144 1   2 1  10 1 1 1  652     .
     6 1 73 20977 1  30 1 130 2 3 1  403     .
     7 1 74 21125 1   1 1 285 4 7 1 1677     .
     8 0 66 20116 0   0 0   0 0 0 1  107     .
     9 0 67 20518 0   0 0   0 0 0 1  107     .
    10 0 73 21321 1   5 1  60 1 1 1  957     .
    11 0 78 18738 1  40 1  40 1 1 1  556     .
    12 1 58 20142 0   0 0   0 0 0 1 1453     .
    13 0 76 22308 1   5 1  35 1 1 0 1161 23469
    14 0 82 20957 1  10 1 360 4 7 1 1682     .
    15 0 68 22650 1  80 2 290 4 8 0  819 23469
    16 0 58 21210 0   0 0   0 0 0 1 1174     .
    17 0 60 21676 0   0 0   0 0 0 1 1162     .
    18 0 74 22242 1  10 1  70 1 1 0 1227 23469
    19 1 76 20986 1  10 1  50 1 1 1  501     .
    20 1 73 20430 1   5 1  45 1 1 1  668     .
    21 0 58 19186 1  50 2 120 2 4 1  375     .
    22 1 81 19775 1 120 2 360 4 8 1  105     .
    23 1 46 18472 0   0 0   0 0 0 1 2494     .
    24 0 70 18993 1   1 1 210 3 5 1 1062     .
    25 0 70 18993 1   1 1 230 3 5 1 1062     .
    26 1 65 21628 0   0 0   0 0 0 1  755     .
    27 1 66 22133 0   0 0   0 0 0 1  250     .
    28 0 69 21474 0   0 0   0 0 0 0 1995 23469
    29 1 49 20161 0   0 0   0 0 0 0 3308 23469
    30 0 82 22791 1   1 1 290 4 7 1  142     .
    31 1 72 21663 1  40 1  65 1 1 0 1806 23469
    32 0 69 20908 1  30 1 320 4 7 1  643     .
    33 1 62 19073 0   0 0   0 0 0 0 4089 23469
    34 0 52 20611 0   0 0   0 0 0 0 2858 23469
    35 0 51 20966 0   0 0   0 0 0 0 2503 23469
    36 0 67 21055 0   0 0   0 0 0 0 1798 23469
    37 0 54 21151 0   0 0   0 0 0 0 2318 23469
    38 0 54 19977 0   0 0   0 0 0 1  262     .
    39 0 76 21805 1   1 1  60 1 1 1 1411     .
    40 0 55 20341 0   0 0   0 0 0 0 1766 23469
    41 1 67 21487 0   0 0   0 0 0 1   11     .
    42 1 78 20866 1  10 1 190 3 5 1 1232     .
    43 1 51 21759 0   0 0   0 0 0 0 1710 23469
    44 1 51 21759 0   0 0   0 0 0 0 1710 23469
    45 0 62 20241 0   0 0   0 0 0 0  475 23469
    46 0 61 22580 1  15 1  85 1 1 0  889 23469
    47 0 70 21375 0   0 0   0 0 0 0 1589 23469
    48 0 87 21898 1   4 1 190 3 5 1    2     .
    49 0 89 21047 1  56 2 360 4 8 1   36     .
    50 0 92 22552 1   7 1  70 1 1 0  917 23469
    51 0 62 21578 1   4 1  65 1 1 1 1119     .
    52 0 62 21578 0   0 0   0 0 0 1 1119     .
    53 0 79 20523 0   0 0   0 0 0 0 2582 23469
    54 0 68 22644 0   0 0   0 0 0 0  825 23469
    55 1 53 22245 0   0 0   0 0 0 0  805 23469
    56 0 50 18961 0   0 0   0 0 0 1 1880     .
    57 0 50 18961 0   0 0   0 0 0 1 1880     .
    58 0 51 21851 0   0 0   0 0 0 0 1618 23469
    59 1 66 21649 1   4 1  60 1 1 0 1820 23469
    60 1 66 21655 1   2 1  25 1 1 0 1814 23469
    61 1 54 20152 0   0 0   0 0 0 1    6     .
    62 1 59 18872 0   0 0   0 0 0 1 2236     .
    63 1 74 19625 1  55 2 360 4 8 1 2888     .
    64 1 74 19625 1  15 1 250 3 5 1 2888     .
    65 0 76 20548 1  17 1 360 4 7 1 2070     .
    66 0 50 20242 0   0 0   0 0 0 0 1938 23469
    67 0 75 20794 1  17 1 360 4 7 1  374     .
    68 0 76 20838 1  25 1 185 3 5 0 2631 23469
    69 0 77 20978 1   1 1 135 2 3 0 2491 23469
    70 0 48 21875 0   0 0   0 0 0 0  700 23469
    72 1 66 20969 1  25 1 320 4 7 0 2500 23469
    73 1 67 22257 1  35 1 275 4 7 1  654     .
    74 0 65 21187 0   0 0   0 0 0 0  541 23469
    75 0 83 22166 1   4 1 240 3 5 1   46     .
    76 1 37 22630 1   4 1  60 1 1 1  233     .
    77 0 63 19845 0   0 0   0 0 0 0 3624 23469
    78 0 74 21641 1  18 1 180 2 3 0 1828 23469
    79 1 72 21405 0   0 0   0 0 0 0 2064 23469
    94 0 70 22977 1  10 1 360 4 7 0  492 23469
    95 1 58 22902 0   0 0   0 0 0 0  567 23469
    end
    format %tdnn/dd/CCYY _intervention_date
    format %tdnn/dd/CCYY M


    I am investigating the effects of calcification of arteries on outcomes following intervention. The sample are grossly categorised by "Calcification" status- 1= calcified, 0= non calcified. I measured both the length ("length_calc" in mm) and circumference ("circl_calc" in degrees) of the calcification. Given the small sample size, I converted them from continuous to categorical variables- "lengthgrade"- 0= no calcification, 1= <50mm, 2= >=50mm, and "calcgrade" 0= none, 1= 1-90 degrees, 2=91-180 degrees, 181-270 degrees, 271-360 degrees.

    On Stata, I define the endpoint with the following:
    Code:
     stset Timetodeath, failure(RIP==1)
    I create the following KM curve:
    Click image for larger version

Name:	KM.jpg
Views:	1
Size:	35.6 KB
ID:	1752170


    with this code:
    Code:
     sts graph, by(Calcification) risktable ci


    I created an interaction term with the length and circumference of calcium ("lengthgrade#calcgrade") as they would be linked with the extent of calcification. I try to create a KM curve with a risk table and confidence intervals like above, however I'm returned with the following:
    Code:
     sts graph, strata(Calcification) adjustfor(lengthgrade#calcgrade) risktable ci
          
    options adjustfor() and ci may not be combined
    r(198);


    The only KM I can produce is like this (i.e. without a risk table or confidence intervals):
    Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	69.5 KB
ID:	1752171



    I've tried to manually produce an interaction term between length and circumference in then "interaction" column; a scale of 0-8 which is a combination of lengthgrade and calcgrade. Again, I'm unable to create a KM curve with a risk table and confidence interval, only a "plain" KM curve:

    Click image for larger version

Name:	Graph1.jpg
Views:	1
Size:	33.6 KB
ID:	1752172


    with the following code:
    Code:
    sts graph, by(Calcification) adjustfor(interaction)
    As you can see, this KM curve is very similar to the first one.
    1. Which curve is "correctly" adjusting for an interaction term- 2 or 3? They are very different despite adjusting for, I think (I may be wrong here!), the same variable
    2. How can I create an adjusted KM curve that has a risk table and confidence intervals like curve 1?
    3. The red lines on the KM curves all drop down to 0, implying that 100% of calcified patients have died at a certain point- which is not true. As you can see, 14 calcified patients did not die- many of which have survived for a long period. Why do the red lines drop to 0- is this something to do with interval-censoring? Is there a way to fix this? If this is something that needs fixing.
      • Subsequently are these KMs "correct"?
    Many thanks!


  • #2
    Similarly, I can easily perform a logrank test for the unadjusted model:
    Code:
    sts test Calcification, logrank
    However, if I try to adjust with the following:
    Code:
    sts test Calcification, strata(lengthgrade#calcgrade) logrank
    I am returned with
    interactions not allowed
    (error in option strata())
    r(101);

    Code:
    sts test Calcification, strata(interaction) logrank
    seems to work, however, given the antics with this "interaction" variable with the KM curve, I'm not convinced that it accurately represents the interaction between length and circumference in degrees (however, I could be wrong!)

    Comment

    Working...
    X