Announcement

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

  • Time varying analysis

    Hello.
    I have a question on time varying analysis in stata (more specifically using the tvc function in Cox proportional hazard model).

    I have a group of patients who I followup for an outcome (a cardiovascular event) over a period of time. The variable I am examining is an exposure (peritonitis) which does not happen at the start but rather at some point during followup. I am hoping to use time to exposure as a time varying covariate.

    The variables are

    Outcome (the cardiovascular event)
    Time (Time from start to outcome or censoring)
    Exposure (Peritonitis)
    TimeExp (Time to peritonitis)

    Im assuming the code is as follows

    stset Time, failure(Outcome) scale(1)
    stcox Exposure, tvc(TimeExp) texp(_t)


    Is this the correct code?
    The other question is what do I put in TimeExp for patients who did not have an exposure. Do I leave it as blank? or do I set some other value?

    Thank you for guiding me with this.


  • #2
    Welcome to Stata list. You will increase your chances of useful answer by following the FAQ on asking questions – provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    I have not done much survival time analysis, so I can't help you with your specifics.

    If you look at the PDF documentation, it has a lot of very good examples.

    Comment


    • #3
      Hassan:
      welcome to this forum.
      As an aside to Phil's helpful advice, you may want to take a look at Example 3, -stcox- entry, Stata .pdf manual.
      That said, I find pretty unusual that you have one predictor only (peritonitis yes/no).
      What about gender, age (and its squared term), BMI, non-cardiovascular comorbidities, cardiovascular concomitant conditions (say, hypertension; atrial fibrillation), previous cardiac procedures (such as PTCA; CABG)?
      Kind regards,
      Carlo
      (Stata 18.0 SE)

      Comment


      • #4
        It seems that your problem is very similar to that in the Standford heart transplant data. This is one of the data sets used in the Stata help, notably in -stcox- with time-varying covariates.

        In these data, transplant is the binary exposure that occurs during follow-up (analogous to peritonitis in your study if I understand correctly).

        The exposure variable is postrans (the person-time following transplant). The unexposed patients contribute just one observation whereas the exposed contribute two observations, one representing the unexposed person-time and one the exposed person-time. You can use -stsplit- to split at the date of peritonitis and create the data in this form.

        In the example below, patient id 4 had a transplant at time 36 and experienced the event at time 39.

        Code:
        . webuse stan3
        (Heart transplant data)
        
        . list id stime transplant posttran _t0 _t _d in 1/10
        
             +---------------------------------------------------+
             | id   stime   transp~t   posttran   _t0    _t   _d |
             |---------------------------------------------------|
          1. |  1      50          0          0     0    50    1 |
          2. |  2       6          0          0     0     6    1 |
          3. |  3      16          1          0     0     1    0 |
          4. |  3      16          1          1     1    16    1 |
          5. |  4      39          1          0     0    36    0 |
             |---------------------------------------------------|
          6. |  4      39          1          1    36    39    1 |
          7. |  5      18          0          0     0    18    1 |
          8. |  6       3          0          0     0     3    1 |
          9. |  7     675          1          0     0    51    0 |
         10. |  7     675          1          1    51   675    1 |
             +---------------------------------------------------+
        
        . stcox age posttran surg year
        You need to be aware of issues with immortal-time bias and analyse your data accordingly. Google that term for more information, but the crux of the problem is that if your primary exposure occurs during follow-up then patients who are exposed are effectively immortal up until the date of exposure. Modelling a time-dependent exposure is one approach to dealing with this but I suggest you read up on the assumptions and relative merits of different modelling approaches.

        Note that there is a big difference between "using time to exposure as a time varying covariate" and "using exposure as a time varying covariate". I am assuming you want to do the latter (you are interested in the effect of peritonitis and not the effect of time to peritonitis).

        Comment


        • #5
          Thanks everyone for the suggestions and help.

          Carlo: Thanks for your comment. Will definitely be adding other covariates. But for the sake of the query wanted to keep it confined on how to do the time varying analysis. I have around 15 covariates and will be employing a backward selection model (in addition to including variables historically known to be associated such as history of cardiovascular disease).

          Paul: Thanks for the suggestion. You are right I am trying to look at the effect of peritonitis. I am learning more about stsplit (and looks like I will have to use it). I was hoping to use the tvc function if anyone knows much about it. Reason is I hope to also do a competing risk analysis (noncardiovascular death as a competing risk to cardiovascular death). In stata it seems I could do a competing risk analysis with tvc function.

          Does anyone know how to use the tvc function. Or will I be using it in the wrong setting if applied here.
          If tvc can be used what value do I place for patients who do not have an exposure (peritonitis)? Would I leave it blank? or place a value higher than the biggest censoring value as some sites suggested (such as 10,000)?

          In the interim ill read up on stsplit and how to use as many have suggested.

          Thanks to everyone for their kind suggestions

          Hicham

          Comment


          • #6
            Hicham:
            if you're still focused on -peritonitis- -tvc- option has no role, as -peritonitis- is a discrete (yes/no) event.
            Kind regards,
            Carlo
            (Stata 18.0 SE)

            Comment


            • #7
              Attached ( q125.pdf ) is a teaching exercise illustrating how to use -stset- for these type of data. it's a cohort study of elderly married couple where the binary exposure (that occurs during follow-up) is death of spouse. Outcome is all-cause mortality. Hypothesis is that the all-cause mortality of the remaining partner is affected by death of the spouse, and that the magnitude (maybe even the direction) of the change depends on the gender of the surviving partner, it also addresses the question of whether the effect of exposure is immediate and constant.

              The data used in the exercise are available at http://pauldickman.com/survival/brv.dta

              Comment


              • #8
                Hello Carlo;

                Its time to peritonitis that I need to add as a time varying covariate.

                Any idea how the code should be written using the tvc function?

                Thanks Paul for the reference. Ill look it up. It still uses the stsplit function (while I was hoping to learn more about tvc function and how it can be used in this setting.).

                I think im resigning myself more and more to using stsplit for this analysis.

                Thanks for everyones helpful tips and suggestions. If anyone knows how the tvc code should be written in this scenario I would really appreciate any input

                Regards.

                Comment


                • #9
                  Hickman:
                  as -peritonitis- is a categorical (and not a continuous) variable, I still fail to get why you shoud model it as a time-varying covariate (but it may well be my fault).
                  That said, you may want to take a look at Example 4 under -stcox- entry, Stata .pdf manual.
                  Kind regards,
                  Carlo
                  (Stata 18.0 SE)

                  Comment


                  • #10
                    I'm with Carlo. It's possible one may be able to trick tvc() into analysing data of the type you have, but the standard way of analysing such data is by splitting (as in the Stanford heart transplant data in the -stcox- manual entry). Splitting is a much more transparent and general approach to analysis; I don't see why you want to use tvc(). I'm always keen to learn new tricks so if you can reproduce the Stanford heart transplant data example without splitting then I will be delighted, but I have not seen it done.

                    You will find that setting up the data for a competing risks analysis may also lead to multiple observations per individuals.

                    It's possible tvc() may be relevant if you want to relax the assumption that the effect of exposure is immediate and constant over time. Yo'll still have to split to separate the exposed from the unexposed person time.

                    Comment


                    • #11
                      Thanks everyone for clarifying.

                      I have used the stsplit function. It is giving me consistent results (and was easier to use than I first anticipated).

                      Carlo: To clarify

                      A patient may start peritoneal dialysis at time zero and have a peritonitis after 3 years and a cardiac event 3 months after a peritonitis

                      Another patient may start peritoneal dialysis, have no peritonitis episode, and have a cardiac event after 3.3 years of starting.

                      If I treated peritonitis as a categorical variable then it would have an equal weight in both cases.

                      It is the time from a peritonitis to cardiac event i am interested in including in the analysis. Which is why im leaning towards a time varying covariate analysis using time to peritonitis.

                      Happy to hear more if this is not the right approach (I will be the first to admit I am not a statistician, I have some experience but constantly learning thanks to numerous sources and help from places such as this forum)

                      Comment

                      Working...
                      X