Announcement

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

  • Repeated Measures Mixed Effect Model

    Hello,

    using a mixed effect model I want to compare behavioral effects of a treatment in an intersubjective design at two different timepoints.
    I have two timepoints of interest, where the task with the dependent variable (task) was performed. The two timepoints are coded "0" und "1" and coded with the variable "time". At timepoint A subjects performed the task and I want to compare active vs. control treatment. Furthermore, at timepoint B subjects performed the same task and I want to compare active vs. control treatment again. Treatment is coded with 0 (control - timepoint A), 1 (active-timepoint A), 2 (control timepoint B) and 3 (active timepoint B). My goal is to compare treatment variables 0 vs. 1 on the dependent Variable "task", as well as the same with treatment variables 2 vs. 3. .

    Using this stata code:

    mixed c.task i.treatment#i.time || id:
    The output gives me values for an interaction for treatment#time:
    1#0: constant etc
    2#1: constant etc
    3#1: constant etc

    My question is: At timepoint A it seems like active vs. control are compared to explain the dependent variable. However, at timepoint B I´m not sure if treatment variables are compared only with control treatment at timepoint A for both treatment variables 2 and 3. Am I right? How would I be able to compare the treatment 2 vs. 3 for my dependent variable in the same model and keep the comparision of treatment variables 0 vs. 1 at the same time?

    Thank you!
    Jasper
    Last edited by Jasper Voeckel; 27 Jun 2023, 09:20.

  • #2
    Code:
    mixed c.task i.treatment#i.time || id:
    This is not the model you intended. (Edit: syntax is legal, but odd.)

    The typical way to fit a mixed model for repeated measures (MMRM) is by using

    Code:
    mixed task i.treatment##i.time || id: , noconstant resid(un, t(time)) reml dfmethod(kroger)
    This model fits a fixed and categorical effect of treatment, time, and their interaction. Traditionally, an MMRM models dependence in repeated measures by imposing some structure on the residuals (here it is set to unstructured) with respect to time. It will fit (n+1)/2 variance or covariance parameters among time points.

    The interaction term coefficients tell you the mean difference in change from one timepoint to baseline in one level of treatment compared to the reference treatment level. These are the coefficients you should examine.

    REML estimation is to contrast with ML estimation, but tends to provides less biased variance estimates. The -dfmethod(kroger)- specifies to use the Kenward-Rodger adjustment for small samples. Strictly speaking, these two options are not necessary, but are commonly used in medical literature.

    An example can be found in Example 9 in the PDF documentation following -help mixed-.

    If you wanted to compare treatment 2 vs 3, while keeping the reference as the control (level 0), you can use test. Something like this, where you would update your variable names and levels as appropriate.

    Code:
    test _b[3.trt#2.time] - _b[2.trt#2.time]
    Last edited by Leonardo Guizzetti; 27 Jun 2023, 09:37.

    Comment


    • #3

      Your regression seems to lack an outcome variable, unless task itself is the outcome, which is legal but sounds odd.

      Using the four level variable Treatment the way you have defined it, Treatment is, itself, already a treatment#time interaction. I don't see any coherent interpretation for the results of this way of doing it. I would simply use a two-valued time variable (A vs B) and a two-valued treatment variable (active vs control) and with these variables run
      Code:
      mixed outcome task i.treatment##i.time || id:
      margins time, dydx(treatment)
      to get the effect of Active vs Control treatment on the outcome at each time period.

      I also do not understand how task can be a continuous variable, but perhaps there is some explanation and my imagination is too limited.

      Comment


      • #4
        Thank you very much for your answers.

        Clyde Schechter In my model task was the dependent variable, but could also be named outcome. Using your code fits well. However the first row of the output of the table of the mixed effect model seems to be identical with the comparision of treatment vs. control at timepoint A. Shouldn´t the first row give me a main treatment effect of treatment at timepoint A+B compared to control at timepoint A+B?

        Leonardo Guizzetti Using the code leaves me with error message of "repeated t() values within lowest-level panels". I have tried to add another variable that distinguishes the individuals further, but could not solve the problem.

        Comment


        • #5
          You should not have repeated measures for subjects at the same time unless this was part of your design, in which case you have replicate assessments for all of your individuals.

          You can view which ones are repeated using -duplicates-. Something like this should work, but is not tested.

          Code:
          duplicates report id time
          duplicates tag id time , gen(dupe)
          list if dupe

          Comment


          • #6
            Shouldn´t the first row give me a main treatment effect of treatment at timepoint A+B compared to control at timepoint A+B?
            As you don't show the actual output, I can't know what the first row of your output is. Speaking in general terms, look first at the -margins- output and ignore the regression. There should be four rows of output from -margins-. Each one gives the expected outcome in one of the four combinations of treatment vs control and timepoint A vs B, and they will be clearly labeled in that table.

            The regression output is more complicated to interpret. THings are not what they appear to be. For example, you will have one row there that is labeled treatment. But it is not the treatment effect. (In fact, there is no such thing as "the treatment effect" in this model.) It is the effect of treatment at timepoint a only. Similarly the one that is labeled timepoint B is not the difference inn expected outcomes at time point B. It is that difference in outcome at timepoint B in the controls only. You will also find a row for the interaction term itself. There you will find the difference-in-differences estimate of the treatment effect. For a lucid discussion of interpreting interaction models, I recommend the excellent Richard Williams' https://www3.nd.edu/~rwilliam/stats2/l53.pdf.

            Comment

            Working...
            X