Announcement

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

  • 4 Treatments, 3 Visits. Comparing change across visits between treatments

    Good Morning


    I was hoping that you would be able to offer some advice and guidance for a problem I am having.

    I am trying to compare 4 treatments (Placebo, A, B and C) that have been observed at 3 times (baseline, 6mths and 12mths). I am trying to answer the question around comparing the change for particular variables between 6mth and baseline, 12mth and Baseline and between 6 and 12 Mths.

    My question that I am aiming to answer is:
    Is there a difference in the differences in a given variable (Continuous) from baseline between the treatment groups? If so, which is providing the greatest benefit?

    In the past when addressing change in a variable across time I have used GEEs however this was for a binary Placebo/treatment scenario. I am just a little stuck with the multiple treatments.

    I appreciate the time you take to consider my questions.

    Kind Regards
    Sean

  • #2
    Sean, a standard DiD for your case would be

    Code:
    reg y c.dA#c.pM6 c.dA#c.pM12 c.dB#c.pM6 c.dB#c.pM12 c.dC#c.pM6 c.dC#c.pM12 dA dB dC pM6 pM12, vce(cluster subjectID)
    where dA, dB, dC are indicators (0 or 1) for grouping, pM6 and pM12 are indicators (0 or 1) for months. The coefficient of, say c.dB#c.pM6, means how y changes for subjects in group B from baseline to 6 months as compared with the changes for placebo-subjects.

    Comment


    • #3
      The model suggested by Fei is a good one, but you can take advantage of Stata factor variable notation to be more concise.

      Let group be a factor variable with placebo coded as 0, and groups A, B and C as 1, 2, 3, respectively. Let time also be a factor variable with baseline (0), 6 and 12 months coded as 0, 1 and 2, respectively.

      Then the model predictors can be coded as

      Code:
      i.group##i.time
      Which will expand to include the individual predictors and all pairwise interactions, using the lowest level as the default reference levels (i.e., baseline and placebo for treatment arm and time, respectively).

      If it were me, I would probably model this as a mixed model for repeated measures (using -mixed-). This model specifically uses an unstructured time and covariance structure, avoiding possible model misspecification, and is unbiased when outcomes are missing at random or missing completely at random. This is a popular choice in medical literature, though not the only one, for repeated measurements at (a few) specified timepoints.

      This would be that model, where it is estimated using REML with Kenward-Roger correction for degrees of freedom.

      Code:
      mixed outcome i.group##i.time || personid : , nocons residuals(unstructured, t(time)) reml dfmethod(kroger)

      Comment


      • #4
        Thank you both for the swift reply. Prior to posting the thread had been trying a model similar to that described by Leonardo.
        I am not completely certain of the interpretations from this model, and being able to obtain the required values.

        When using the mixed model.
        1. Am I correct in thinking that the contrast will indicate whether there is a difference between the groups?

        Code:
        Code:
        contrast i.group##i.time


        2. How would I obtain the estimates at particular groups and times? for example change in outcome at time==2 compared to its own baseline?

        3. Would I be required to include the baseline outcome as a covariate or is this variation already incorporated into the mixed model?

        Kind Regards
        Sean

        Comment


        • #5
          1) Yes, but that will also give you some unrelated margins as well.

          2) See the below example.

          3) In this layout, baseline measures are included as an outcome and are adjusted for in the model.

          For the following example to see syntax with a toy dataset, I borrowed data from the UCLA page on repeated measures.

          The example code is

          Code:
          clear *
          cls
          
          use https://stats.idre.ucla.edu/stat/data/repeated_measures, clear
          drop y4
          
          reshape long y, i(id) j(time)
          
          // Start here
          mixed y i.trt##i.time || id : , nocons resid(unstr, t(time)) reml dfmethod(kroger) nolog nolrtest
          
          // averages at each time within each treatment group
          margins i.time#i.trt
          
          // change from baseline within each treatment group
          margins r.time@trt, contrast(effect)
          
          // change between treatment arm (compared to a reference group) in changes from baseline.
          // Sometimes called difference-in-differences.
          margins i.trt#i.time, contrast(effects)
          The relevant output is shown below.

          Code:
          . mixed y i.trt##i.time || id : , nocons resid(unstr, t(time)) reml dfmethod(kroger) nolog nolrtest
          
          Mixed-effects REML regression                   Number of obs     =         24
          Group variable: id                              Number of groups  =          8
                                                          Obs per group:
                                                                        min =          3
                                                                        avg =        3.0
                                                                        max =          3
          DF method: Kenward–Roger                        DF:           min =       6.00
                                                                        avg =       6.00
                                                                        max =       6.00
                                                          F(5,     4.85)    =      29.38
          Log restricted-likelihood = -22.407258          Prob > F          =     0.0012
          
          ------------------------------------------------------------------------------
                     y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                 2.trt |       -2.5   .7905693    -3.16   0.020    -4.434453   -.5655466
                       |
                  time |
                    2  |        .25   .3818813     0.65   0.537    -.6844299     1.18443
                    3  |       3.25   .3818813     8.51   0.000      2.31557     4.18443
                       |
              trt#time |
                  2 2  |          1   .5400617     1.85   0.114    -.3214834    2.321483
                  2 3  |         .5   .5400617     0.93   0.390    -.8214834    1.821483
                       |
                 _cons |       4.25   .5590169     7.60   0.000     2.882135    5.617865
          ------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------
            Random-effects parameters  |   Estimate   Std. err.     [95% conf. interval]
          -----------------------------+------------------------------------------------
          id:                  (empty) |
          -----------------------------+------------------------------------------------
          Residual: Unstructured       |
                               var(e1) |       1.25   .7216874      .4031518    3.875709
                               var(e2) |   .6666666      .3849      .2150144    2.067045
                               var(e3) |         .5   .2886749      .1612608    1.550284
                            cov(e1,e2) |   .6666665   .4614787     -.2378152    1.571148
                            cov(e1,e3) |   .5833332   .4010976     -.2028037     1.36947
                            cov(e2,e3) |   .3333333   .2721653     -.2001008    .8667674
          ------------------------------------------------------------------------------
          
          .
          . // averages at each time within each treatment group
          . margins i.time#i.trt
          
          Adjusted predictions                                        Number of obs = 24
          
          Expression: Linear prediction, fixed portion, predict()
          
          ------------------------------------------------------------------------------
                       |            Delta-method
                       |     Margin   std. err.      z    P>|z|     [95% conf. interval]
          -------------+----------------------------------------------------------------
              time#trt |
                  1 1  |       4.25   .5590169     7.60   0.000     3.154347    5.345653
                  1 2  |       1.75   .5590169     3.13   0.002      .654347    2.845653
                  2 1  |        4.5   .4082483    11.02   0.000     3.699848    5.300152
                  2 2  |          3   .4082483     7.35   0.000     2.199848    3.800152
                  3 1  |        7.5   .3535534    21.21   0.000     6.807048    8.192952
                  3 2  |        5.5   .3535534    15.56   0.000     4.807048    6.192952
          ------------------------------------------------------------------------------
          
          .
          . // change from baseline within each treatment group
          . margins r.time@trt, contrast(effect)
          
          Contrasts of adjusted predictions                           Number of obs = 24
          
          Expression: Linear prediction, fixed portion, predict()
          
          ------------------------------------------------
                       |         df        chi2     P>chi2
          -------------+----------------------------------
              time@trt |
           (2 vs 1) 1  |          1        0.43     0.5127
           (2 vs 1) 2  |          1       10.71     0.0011
           (3 vs 1) 1  |          1       72.43     0.0000
           (3 vs 1) 2  |          1       96.43     0.0000
                Joint  |          4      203.27     0.0000
          ------------------------------------------------
          
          ------------------------------------------------------------------------------
                       |            Delta-method
                       |   Contrast   std. err.      z    P>|z|     [95% conf. interval]
          -------------+----------------------------------------------------------------
              time@trt |
           (2 vs 1) 1  |        .25   .3818813     0.65   0.513    -.4984736    .9984736
           (2 vs 1) 2  |       1.25   .3818813     3.27   0.001     .5015264    1.998474
           (3 vs 1) 1  |       3.25   .3818813     8.51   0.000     2.501526    3.998474
           (3 vs 1) 2  |       3.75   .3818813     9.82   0.000     3.001526    4.498474
          ------------------------------------------------------------------------------
          
          .
          . // change between treatment arm (compared to a reference group) in changes from baseline.
          . // Sometimes called difference-in-differences.
          . margins i.trt#i.time, contrast(effects)
          
          Contrasts of adjusted predictions                           Number of obs = 24
          
          Expression: Linear prediction, fixed portion, predict()
          
          ------------------------------------------------
                       |         df        chi2     P>chi2
          -------------+----------------------------------
              trt#time |          2        3.45     0.1778
          ------------------------------------------------
          
          ------------------------------------------------------------------------------------------
                                   |            Delta-method
                                   |   Contrast   std. err.      z    P>|z|     [95% conf. interval]
          -------------------------+----------------------------------------------------------------
                          trt#time |
          (2 vs base) (2 vs base)  |          1   .5400617     1.85   0.064    -.0585015    2.058502
          (2 vs base) (3 vs base)  |         .5   .5400617     0.93   0.355    -.5585015    1.558501
          ------------------------------------------------------------------------------------------
          I highlighted where margins will return estimates that are the same as the estimated coefficients (red and pink text). The blue text is the overall effect that there are any differences in drugs at any time, should that be of interest.

          Comment


          • #6
            Many thanks Leonardo for such a detailed and considerate response. It is greatly appreciated.

            I have made pleasing progress since receiving your feedback. I have a few additional queries :

            1. If I would like to compare time 3 vs time 2 could I use the code below to isolate this time point comparison:
            Code:
             margins r.time@trt if time!=1, contrast(effect)
            2. Similarly, if I want to observe the difference in difference at particular time is it ok to restrict the code to exclude one of the 3 time points. For example the code below to look at the difference in differences from Baseline at Visit 2 only.

            Code:
             margins i.trt#i.time if time!=3, contrast(effects)
            3. Final question, would the approach to analysing a binomial variable be similar albeit using the mixed logistic pathway?

            Kind Regards
            Sean

            Comment

            Working...
            X