Dear All,
I have a 32-month patient-level panel data, which I want to use to estimate the impact of COVID-19 infection (coded as binary variable "tvc") on time-to-event 'Y'. There is also the competing risk of death ("dead") that my preclude observing "Y". There is variation across patients in when they have COVID-19 during the 32 month period (variation in timing of treatment), and, of course, not all patient's have COVID-19 during the study period (control arm). Here is how my data is stset and looks:
To capture the effect of the time variant treatment "COVID", on "Y" with a competing risk of "dead" I estimate a competing risk regression, followed by an attempt to generate a cumulative incidence graph as follows :
I tried to follow the "tvc note" but I can't figure out how to produce it manually... Will be grateful for any guidance you may be able to offer.
Sincerely,
Sumedha
I have a 32-month patient-level panel data, which I want to use to estimate the impact of COVID-19 infection (coded as binary variable "tvc") on time-to-event 'Y'. There is also the competing risk of death ("dead") that my preclude observing "Y". There is variation across patients in when they have COVID-19 during the 32 month period (variation in timing of treatment), and, of course, not all patient's have COVID-19 during the study period (control arm). Here is how my data is stset and looks:
Code:
. stset stop, id(ID) enter(start) failure(d=1) time0(start) Survival-time data settings ID variable: ID Failure event: d==1 Observed time interval: (start, stop] Enter on or after: time start Exit on or before: failure -------------------------------------------------------------------------- 700,185 total observations 0 exclusions -------------------------------------------------------------------------- 700,185 observations remaining, representing 26,147 subjects 4,072 failures in single-failure-per-subject data 700,185 total analysis time at risk and under observation At risk from t = 0 Earliest observed entry t = 0 Last observed exit t = 31 . dataex date ID Female age80plus x1 x2 z1 z2 z3 z4 z5 start Y dead COVID d t0 failtime stop _st _d _t _t0 ----------------------- copy starting from the next line ----------------------------------------- copy up to and including the previous line ------------------ Listed 100 out of 700185 observations Use the count() option to list moreCode:* Example generated by -dataex-. For more info, type help dataex clear input float(date ID) byte(Female age80plus) float(x1 x2 z1) double z2 float(z3 z4 z5 start Y dead COVID d t0 failtime stop) byte(_st _d _t _t0) 714 1 0 0 0 1 0 108734 0 0 0 0 0 . 0 0 0 31 1 1 0 1 0 715 1 0 0 0 1 0 116834 0 0 0 1 0 . 0 0 0 31 2 1 0 2 1 716 1 0 0 0 1 0 120565 0 0 0 2 0 . 0 0 0 31 3 1 0 3 2 717 1 0 0 0 1 0 115212 0 0 0 3 0 . 0 0 0 31 4 1 0 4 3 718 1 0 0 0 1 0 112542 0 0 0 4 0 . 0 0 0 31 5 1 0 5 4 719 1 0 0 0 1 0 125570 0 0 0 5 0 . 0 0 0 31 6 1 0 6 5 720 1 0 0 0 1 0 143446 0 0 0 6 0 . 0 0 0 31 7 1 0 7 6 721 1 0 0 0 1 0 130334 0 0 0 7 0 . 0 0 0 31 8 1 0 8 7 722 1 0 0 0 1 0 103759 .24440205 .24440205 0 8 0 . 0 0 0 31 9 1 0 9 8 723 1 0 0 0 1 0 78091 5.556073 5.311671 0 9 0 . 0 0 0 31 10 1 0 10 9 724 1 0 0 0 1 .8333333 82506 12.77408 7.218007 0 10 0 . 0 0 0 31 11 1 0 11 10 725 1 0 0 0 1 .8333333 86526 16.896328 4.122248 0 11 0 . 0 0 0 31 12 1 0 12 11 726 1 0 0 0 1 .8333333 87483 21.26298 4.36665 0 12 0 . 0 0 0 31 13 1 0 13 12 727 1 0 0 0 1 .8333333 88849 26.4443 5.181324 0 13 0 . 0 0 0 31 14 1 0 14 13 728 1 0 0 0 1 .8333333 89153 35.145016 8.700713 0 14 0 . 0 0 0 31 15 1 0 15 14 729 1 0 0 0 1 .8333333 92720 50.34682 15.201808 0 15 0 . 0 0 0 31 16 1 0 16 15 730 1 0 0 0 1 .8333333 85388 64.8643 14.517482 0 16 0 . 0 0 0 31 17 1 0 17 16 731 1 0 0 0 1 .8333333 103097 95.91966 31.055355 1.28795 17 0 . 0 0 0 31 18 1 0 18 17 732 1 0 0 0 1 .8333333 104865 116.92194 21.002283 8.336668 18 0 . 0 0 0 31 19 1 0 19 18 733 1 0 0 0 1 .8333333 96550 136.58817 19.66622 20.84593 19 0 . 0 0 0 31 20 1 0 20 19 734 1 0 0 0 1 .8333333 97024 146.26648 9.678321 41.1382 20 0 . 0 0 0 31 21 1 0 21 20 735 1 0 0 0 1 .8333333 99512 150.60054 4.334063 64.93627 21 0 . 0 0 0 31 22 1 0 22 21 736 1 0 0 0 1 .8333333 127138 157.65562 7.055073 76.24552 22 0 . 0 0 0 31 23 1 0 23 22 737 1 0 0 0 1 .8333333 125215 161.61493 3.959313 83.28538 23 0 . 0 0 0 31 24 1 0 24 23 738 1 0 0 0 1 .8333333 127337 167.98567 6.370747 89.34604 24 0 . 0 0 0 31 25 1 0 25 24 739 1 0 0 0 1 .8333333 131623 183.6437 15.658025 96.881 25 0 . 0 0 0 31 26 1 0 26 25 740 1 0 0 0 1 .8333333 127392 198.65 15.006286 102.72098 26 0 . 0 0 0 31 27 1 0 27 26 741 1 0 0 0 1 .8333333 134953 208.18167 9.53168 111.11894 27 0 . 0 0 0 31 28 1 0 28 27 742 1 0 0 0 1 .8333333 131271 253.08647 44.9048 120.57523 28 0 . 0 0 0 31 29 1 0 29 28 743 1 0 0 0 1 .8333333 137164 264.32898 11.242495 131.78543 29 0 . 0 0 0 31 30 1 0 30 29 744 1 0 0 0 1 .8333333 0 283.84854 19.519577 138.48784 30 0 0 0 0 0 31 31 1 0 31 30 714 227 0 0 0 0 0 105688 0 0 0 0 0 . 0 0 0 31 1 1 0 1 0 715 227 0 0 0 0 0 109137 0 0 0 1 0 . 0 0 0 31 2 1 0 2 1 716 227 0 0 0 0 0 112341 0 0 0 2 0 . 0 0 0 31 3 1 0 3 2 717 227 0 0 0 0 0 107216 0 0 0 3 0 . 0 0 0 31 4 1 0 4 3 718 227 0 0 0 0 0 103992 0 0 0 4 0 . 0 0 0 31 5 1 0 5 4 719 227 0 0 0 0 0 113248 0 0 0 5 0 . 0 0 0 31 6 1 0 6 5 720 227 0 0 0 0 0 128925 0 0 0 6 0 . 0 0 0 31 7 1 0 7 6 721 227 0 0 0 0 0 115043 0 0 0 7 0 . 0 0 0 31 8 1 0 8 7 722 227 0 0 0 0 0 93962 1.1867286 1.1867286 0 8 0 . 0 0 0 31 9 1 0 9 8 723 227 0 0 0 0 0 68791 10.558118 9.371388 0 9 0 . 0 0 0 31 10 1 0 10 9 724 227 0 0 0 0 0 73578 19.015913 8.457796 0 10 0 . 0 0 0 31 11 1 0 11 10 725 227 0 0 0 0 0 77321 25.97617 6.960258 0 11 0 . 0 0 0 31 12 1 0 12 11 726 227 0 0 0 0 0 76899 34.6035 8.627329 0 12 0 . 0 0 0 31 13 1 0 13 12 727 227 0 0 0 0 0 77769 51.85816 17.254658 0 13 0 . 0 0 0 31 14 1 0 14 13 728 227 0 0 0 0 0 76386 64.6202 12.762042 0 14 0 . 0 0 0 31 15 1 0 15 14 729 227 0 0 0 0 0 79724 73.36997 8.749769 0 15 0 . 0 0 0 31 16 1 0 16 15 730 227 0 0 0 0 0 73021 86.63119 13.261222 0 16 0 . 0 0 0 31 17 1 0 17 16 731 227 0 0 0 0 0 81521 99.72288 13.09169 .7078648 17 0 . 0 0 0 31 18 1 0 18 17 732 227 0 0 0 0 0 80023 129.76784 30.044956 8.607889 18 0 . 0 0 0 31 19 1 0 19 18 733 227 0 0 0 0 0 74881 157.8255 28.057655 19.51934 19 0 . 1 0 0 31 20 1 0 20 19 734 227 0 0 0 0 0 71290 173.9876 16.162113 36.316338 20 0 . 1 0 0 31 21 1 0 21 20 735 227 0 0 0 0 0 76012 184.26317 10.275563 59.3938 21 0 . 1 0 0 31 22 1 0 22 21 736 227 0 0 0 0 0 90849 190.06496 5.801785 71.21994 22 0 . 1 0 0 31 23 1 0 23 22 737 227 0 0 0 0 0 87359 195.2357 5.170746 79.33001 23 0 . 1 0 0 31 24 1 0 24 23 738 227 0 0 0 0 0 88531 197.5809 2.3452017 84.21228 24 0 . 1 0 0 31 25 1 0 25 24 739 227 0 0 0 0 0 86848 207.2725 9.691617 91.53414 25 0 . 1 0 0 31 26 1 0 26 25 740 227 0 0 0 0 0 85626 237.5718 30.299253 100.5245 26 0 . 1 0 0 31 27 1 0 27 26 741 227 0 0 0 0 0 90028 264.07538 26.503607 108.14006 27 0 . 1 0 0 31 28 1 0 28 27 742 227 0 0 0 0 0 88215 276.7809 12.70553 116.46112 28 0 . 1 0 0 31 29 1 0 29 28 743 227 0 0 0 0 0 92667 285.21988 8.438959 125.56448 29 0 . 1 0 0 31 30 1 0 30 29 744 227 0 0 0 0 0 0 298.5376 13.317733 131.98718 30 0 0 1 0 0 31 31 1 0 31 30 714 737 0 1 0 0 0 49437 0 0 0 0 1 . 0 0 0 14 1 1 0 1 0 715 737 0 1 0 0 0 49238 0 0 0 1 1 . 0 0 0 14 2 1 0 2 1 716 737 0 1 0 0 0 51998 0 0 0 2 1 . 0 0 0 14 3 1 0 3 2 717 737 0 1 0 0 0 49558 0 0 0 3 1 . 0 0 0 14 4 1 0 4 3 718 737 0 1 0 0 0 48611 0 0 0 4 1 . 0 0 0 14 5 1 0 5 4 719 737 0 1 0 0 0 55345 0 0 0 5 1 . 0 0 0 14 6 1 0 6 5 720 737 0 1 0 0 0 60259 0 0 0 6 1 . 0 0 0 14 7 1 0 7 6 721 737 0 1 0 0 0 53299 .01313216 .01313216 0 7 1 . 0 0 0 14 8 1 0 8 7 722 737 0 1 0 0 0 38747 2.967868 2.954736 0 8 1 . 0 0 0 14 9 1 0 9 8 723 737 0 1 0 0 .3 28353 10.794636 7.826768 0 9 1 . 0 0 0 14 10 1 0 10 9 724 737 0 1 0 0 1.3 30530 14.786813 3.992177 0 10 1 . 0 0 0 14 11 1 0 11 10 725 737 0 1 0 0 1.3 32364 17.50517 2.718357 0 11 1 . 0 0 0 14 12 1 0 12 11 726 737 0 1 0 0 1.3 32721 21.70746 4.2022915 0 12 1 . 0 0 0 14 13 1 0 13 12 727 737 0 1 0 0 1.3 31891 26.290586 4.583124 0 13 1 0 0 1 0 14 14 1 1 14 13 714 26657 0 1 0 0 0 61743 0 0 0 0 0 . 0 0 0 31 1 1 0 1 0 715 26657 0 1 0 0 0 63705 0 0 0 1 0 . 0 0 0 31 2 1 0 2 1 716 26657 0 1 0 0 0 64712 0 0 0 2 0 . 0 0 0 31 3 1 0 3 2 717 26657 0 1 0 0 0 63334 0 0 0 3 0 . 0 0 0 31 4 1 0 4 3 718 26657 0 1 0 0 0 61209 0 0 0 4 0 . 0 0 0 31 5 1 0 5 4 719 26657 0 1 0 0 0 66799 0 0 0 5 0 . 0 0 0 31 6 1 0 6 5 720 26657 0 1 0 0 0 76538 0 0 0 6 0 . 0 0 0 31 7 1 0 7 6 721 26657 0 1 0 0 0 68623 0 0 0 7 0 . 0 0 0 31 8 1 0 8 7 722 26657 0 1 0 0 0 56262 .42729115 .42729115 0 8 0 . 0 0 0 31 9 1 0 9 8 723 26657 0 1 0 0 0 42645 4.7390475 4.311756 0 9 0 . 0 0 0 31 10 1 0 10 9 724 26657 0 1 0 0 0 44820 9.594629 4.855581 0 10 0 . 0 0 0 31 11 1 0 11 10 725 26657 0 1 0 0 0 46741 14.3531 4.7584696 0 11 0 . 0 0 0 31 12 1 0 12 11 726 26657 0 1 0 0 0 45964 33.251022 18.897923 0 12 0 . 0 0 0 31 13 1 0 13 12 727 26657 0 1 0 0 0 46146 52.82872 19.577703 0 13 0 . 0 0 0 31 14 1 0 14 13 728 26657 0 1 0 0 0 46625 65.60862 12.77989 0 14 0 . 0 0 0 31 15 1 0 15 14 729 26657 0 1 0 0 0 49075 76.42685 10.818235 0 15 0 . 0 0 0 31 16 1 0 16 15 730 26657 0 1 0 0 0 44179 85.08921 8.662357 0 16 0 . 0 0 0 31 17 1 0 17 16 731 26657 0 1 0 0 0 57722 102.86063 17.771427 .9761273 17 0 . 0 0 0 31 18 1 0 18 17 732 26657 0 1 0 0 0 51584 136.77202 33.91138 8.536908 18 0 . 0 0 0 31 19 1 0 19 18 733 26657 0 1 0 0 0 51467 165.9832 29.21118 21.10333 19 0 . 0 0 0 31 20 1 0 20 19 734 26657 0 1 0 0 0 46464 177.6366 11.653396 41.76697 20 0 . 0 0 0 31 21 1 0 21 20 735 26657 0 1 0 0 0 59542 184.45383 6.817236 62.96244 21 0 . 0 0 0 31 22 1 0 22 21 736 26657 0 1 0 0 0 66349 189.09576 4.641936 73.31761 22 0 . 0 0 0 31 23 1 0 23 22 737 26657 0 1 0 0 0 66952 190.7078 1.612053 81.38069 23 0 . 0 0 0 31 24 1 0 24 23 end format %tm date
Code:
. stcrreg Female age80plus, tvc(z1 z2 z3 z4 z5 COVID) compete(dead) Failure _d: d==1 Analysis time _t: stop Enter on or after: time start ID variable: ID Iteration 0: Log pseudolikelihood = -40484.897 Iteration 1: Log pseudolikelihood = -40418.002 Iteration 2: Log pseudolikelihood = -40417.681 Iteration 3: Log pseudolikelihood = -40417.681 Competing-risks regression No. of obs = 700,185 No. of subjects = 26,147 Failure event: d == 1 No. failed = 4,072 Competing events: dead nonzero, nonmissing No. competing = 2,357 No. censored = 19,718 Wald chi2(8) = 1484.28 Log pseudolikelihood = -40417.681 Prob > chi2 = 0.0000 (Std. err. adjusted for 26,147 clusters in ID) ------------------------------------------------------------------------------ | Robust _t | SHR std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- main | Female | 1.102109 .0351884 3.05 0.002 1.035254 1.173281 age80plus | 3.086966 .0967383 35.97 0.000 2.903068 3.282514 -------------+---------------------------------------------------------------- tvc | z1 | .9950684 .0017935 -2.74 0.006 .9915595 .9985898 z2 | 1 1.13e-08 2.27 0.023 1 1 z3 | 1.0001 .0000206 4.83 0.000 1.000059 1.00014 z4 | 1.000123 .0001134 1.08 0.279 .9999004 1.000345 z5 | 1.000227 .0000315 7.22 0.000 1.000165 1.000289 COVID | 1.014416 .0040336 3.60 0.000 1.006541 1.022353 ------------------------------------------------------------------------------ Note: Variables in tvc equation interacted with _t. . end of do-file . stcurve, cif at(COVID=(0 1)) this post-estimation command is not allowed after estimation with tvc(); see tvc note for an alternative to the tvc() option r(198);
Sincerely,
Sumedha
Comment