Announcement

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

  • Pre and Post treatment repeated measures- linear mixed effect model?

    Hello, thanks for reading this and any advice. I'm using STATA 16.

    My questions relates to whether a linear mixed effect model is appropriate and how to set up the model accordingly. I'm familiar with using these models and the mixed command. However, the question I'm asking about is different to previous times I've used mixed effects models.

    I have a data set of repeated measures of a blood test in patients who start drug A at time 0. They then have further repeated blood tests done at scheduled times- time 1, time 2, time 3, time 4, time 5. Not every patient had blood taken at every scheduled time (eg some died before time 5 or missed a test but had the next scheduled one). In-between the scheduled blood taking times, all patients started another drug (drug B). I have the time to starting drug B in days from the start of the study. The day of starting drug B falls between different scheduled blood tests for different patients (eg time 0 = study day 1, time 1 = study day 28, time 2 = study day 42, time 3 = study day 70 and drug B could have been started on day 15, day 23, day 44, day 67 for patients A, B, C, D respectively).

    I want to examine whether there was a change in the blood test values before and after starting drug B, eg were repeated blood test values rising before starting drug B and falling after?

    Is a linear mixed effects model appropriate here?

    How do I set up the model so that the repeated measures are organised into before or after the day drug B was started?

    Hope that is clear. Any help is greatly appreciated, thanks,

    James


  • #2
    Yes, you can do this with a linear mixed effects model. Here's the difference. You no longer have a pre-post time indicator because different participants make that transition at different times. So it is not done with the simple difference-in-differences estimator you are familiar with. Instead you need to create a variable that is 1 for observations in which the participant has begun taking the drug, and 0 for all other observations. It is a variable that might appropriately be called on_treatment. There is no "treatment vs control" variable and there is no "pre-post" variable: the on_treatment variable subsumes the role of both of those. In addition, since your goal is specifically to look at a change in the slope of the blood_test_value:time curve, you would interact the on_treatment variable with continuous time. So, since you do not show example data, you will need to modify this suggested code to suit your actual data set:

    Code:
    mixed blood_test_value i.on_treatment##c.time  || person:
    margins on_treatment, dydx(time)
    Some other thoughts about this. If everybody in the study received the drug at some point, then what you really should be looking at is a purely within-person effect, and this would be better done with a fixed-effects model:

    Code:
    xtset person // IF person IS NOT NUMERIC, -encode- IT SO YOU CAN USE IT WITH -xtset-
    xtreg blood_test_values i.on_treatment##c.time, fe
    margins on_treatment, dydx(time)
    Also, if some people received the drug and others didn't, but the assignment was not randomized, then I think you would also be better off using the fixed-effects model, as the between-person effect may well be confounded with other measured or unmeasured attributes of the people: a fixed-effects model will eliminate those and give you a purely within-person effect estimate.

    Comment


    • #3
      Clyde, many thanks, invaluable advice. Can I take it the code - margins on_treatment, dydx(time) - gives the expected rate/slope of change in the blood test value either side of starting the drug?

      If alternatively you were to look at the absolute expected values of the blood test either side of starting drugB and their difference, the coding would be (1) - margins on_treatment - and then (2)- margins, dydx(on_treatment) - giving (1) the expected absolute blood test values either side of starting drugB and (2) their difference. Is this correct?

      If to extend this to report graphically the blood test values either side of starting the drug, how would you suggest coding for it? I have the following, using the absolute values rather then rate of change-

      gen studyday_bloods = 1 if bloods_time == 1
      replace studyday_bloods = 28 if bloods_time == 2
      replace studyday_bloods = 96 if bloods_time == 3
      replace studyday_bloods = 104 if bloods_time == 4
      replace studyday_bloods = 270 if bloods_time == 5

      gen time = studyday_bloods - studyday_drugBstarted

      mixed bloodtest_ c.time || id:time, cov(unstr)
      margins , at(time = (-400(100)400))
      marginsplot

      Which would give a graph with time in days on the x axis (all minus values from -400 days on are before drugB started and all positive values are after drugB started up until +400 days), and on the y axis the predicted absolute values of the blood test.

      Is this accurate?

      Many thanks again,

      James


      Comment


      • #4
        Code:
        Can I take it the code - margins on_treatment, dydx(time) - gives the expected rate/slope of change in the blood test value either side of starting the drug?
        
        If alternatively you were to look at the absolute expected values of the blood test either side of starting drugB and their difference, the coding would be (1) - margins on_treatment - and then (2)- margins, dydx(on_treatment) - giving (1) the expected absolute blood test values either side of starting drugB and (2) their difference. Is this correct?
        So far, so good.

        mixed bloodtest_ c.time || id:time, cov(unstr)
        This is not an appropriate model for your purpose. You are specifically interested in seeing a change in the direction of the bloodtest_results movement over time after starting the drug. That model cannot capture any such change. That model requires fitting a single straight line through the values of bloodtest over time. If the data change direction, say increasing before drug and then decreasing afterward, the result will be more or less a flat line, or perhaps a slightly upsloping or slightly downsloping line, depending on which is more pronounced, the initial increase or the subsequent decline. That model is incapable of recognizing any change in direction. So you would need to have the interaction of c.time with on_treatment in the regression to get what you are looking for.




        Comment


        • #5
          Ok many thanks, yes should have included an interaction term

          gen studyday_bloods = 1 if bloods_time == 1
          replace studyday_bloods = 28 if bloods_time == 2
          replace studyday_bloods = 96 if bloods_time == 3
          replace studyday_bloods = 104 if bloods_time == 4
          replace studyday_bloods = 270 if bloods_time == 5

          gen time = studyday_bloods - studyday_drugBstarted
          gen on_treatment = 0 if time < 0
          recode on_treatment .= 1
          mixed bloodtest_ i.on_treatment##c.time || id:time, cov(unstr)

          How could you code to plot this on a graph? Representing absolute values (or slope of change) of the blood test before and after starting drugB.

          Thanks again, your explanations are very helpful

          James

          Comment


          • #6
            Originally posted by James Curtain View Post
            How could you code to plot this on a graph? Representing absolute values (or slope of change) of the blood test before and after starting drugB.
            If I understand you correctly about what you're looking for, then this has come up on the list before. See, for example, #3 and #4 in this thread.

            Comment


            • #7
              Thanks Joseph. So to put this together-

              gen studyday_bloods = 1 if bloods_time == 1
              replace studyday_bloods = 28 if bloods_time == 2
              replace studyday_bloods = 96 if bloods_time == 3
              replace studyday_bloods = 104 if bloods_time == 4
              replace studyday_bloods = 270 if bloods_time == 5

              gen time = studyday_bloods - studyday_drugBstarted
              gen on_treatment = 0 if time < 0
              recode on_treatment .= 1
              mixed bloodtest_ i.on_treatment##c.time || id:time, cov(unstr)
              margins on_treatment
              margins, dydx(on_treatment)
              margins , at(time = (-500(100)500))
              marginsplot

              Will provide

              (1) the expected absolute blood test values either side of starting drugB (already discussed as per #3 and #4 above)
              (2) their difference (already discussed as per #3 and #4 above)
              (3) the absolute blood test values per 100 day intervals from 500 days before starting drugB to 500 days after
              (4) a graph of those values, with the blood test value range on the y axis and time in days before and after along the x axis

              Is this correct?

              James

              Comment

              Working...
              X