Announcement

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

  • mixed model - interaction term between independent variable and time?

    Dear Statalist,

    I am fitting linear mixed models to assess the prospective associations of a categorical independent variable with a continuous dependent variable.

    TV viewing is the categorical independent variable: <1 (reference), 1, 2, 3, 4+ hours/day. This was assessed at baseline. IQ score is the continuous dependent variable: a score in units ranging from 0 to 13 (Higher scores on this test indicates better cognitive function). This was assessed at both baseline and follow-up (~ 5 years later).

    I am interested in understanding:

    (a) whether TV viewing is associated with IQ score?
    (b) whether IQ score changes over time?
    (c) the association between TV viewing and change in IQ score (i.e. is there a change in the strength of the association over time)

    In order to answer (a) and (b) I first fit the following linear mixed model in Stata/MP 14.0:

    * linear mixed model 1
    mixed fluid_intelligence age0 i.sex i.TVsed0 t, || ID:, level(99)


    Note:
    • Data were in panel (i.e. long) format.
    • Participant ID was included as a random effect.
    • ‘time (in years [at baseline: 0, and at follow-up: no. of follow-up years])’ was included as a continuous variable (denoted as ‘t’ in the model).
    • The model was also adjusted for baseline age and sex.

    Output:

    Click image for larger version

Name:	linear mixed model 1.png
Views:	1
Size:	35.7 KB
ID:	1383185



    From the model, if my understanding is correct, I know that:
    • the beta coefficient for TV viewing tells us the association between TV viewing and IQ score (i.e. answers my part a)). Here, higher levels of TV viewing are associated with lower IQ scores.
    • the beta coefficient for ‘time’ tells us whether the IQ score changes over time (i.e. answers my part b)). Here, IQ scores decrease over time.

    In order to try and answer (c), I fitted a further model where I included an interaction term between TV viewing and time:

    * linear mixed model 2
    mixed fluid_intelligence age0 i.sex i.TVsed0 t i.TVsed0##c.t, || ID:, level(99)


    Output:

    Click image for larger version

Name:	linear mixed model 2.png
Views:	1
Size:	42.8 KB
ID:	1383186




    The problem

    Now I am having trouble understanding and interpreting this interaction term between the TV viewing and time (and whether this interaction term really answers my question or not – or is it even needed to answer it?!).

    I have tried the margins command to shed some light here:

    * margins TVsed0, dydx(t)

    Output:

    Click image for larger version

Name:	margins1.png
Views:	1
Size:	12.8 KB
ID:	1383187


    My understanding is that these are the slopes associated with different levels of TV viewing? A linear combination of the time term and the interaction terms in the linear mixed model 2?

    Could anyone please shed some light here on whether an interaction term is needed to answer the question, and if yes, how it should be interpreted?

    Thank you so much in advance for your help,

    Best wishes,

    Kishan


  • #2
    My understanding is that these are the slopes associated with different levels of TV viewing? A linear combination of the time term and the interaction terms in the linear mixed model 2?
    What you are looking at in that -margins- output is, for each level of TV viewing, how much the expected value of your outcome variable changes per unit of time. So for those who are in TV category 0, their expected outcomes decrease on average .12 units per year, adjusted for age and sex. They are effects of time, conditional on TV viewing.

    They are not effects of TV viewing conditional on time. You have not stated which way you want it. If what you want is the effects of TV viewing conditional on time, then the margins command would be

    Code:
    margins, dydx(TVsed0) at(t = (list_of_interesting_values_of_time))
    You would need to decide at which values of the continuous variable time you are most interested in seeing the conditional marginal effects of TVsed0 and specify them in that command. If there are no values of t that are of special interest, you might just pick a half a dozen values that relatively evenly span the range of observed values. It is usually a good idea, also, to graph this information with the -marginsplot- command: those pictures are usually easier to understand than the tables.

    Could anyone please shed some light here on whether an interaction term is needed to answer the question, and if yes, how it should be interpreted?
    The stated question is whether the effect of TVsed0 varies over time. And yes, you need an interaction to answer that question. As for how to interpret it, I think the answer is: it's too complicated, don't even try. The interaction term between a polychotomous variable and a continuous variable is just a big mess to unravel. Better, in my view, is to understand that the presence of the interactions in the model allows you to estimate the different effects of TVsed0 at different points in time and separately estimate the effect of time at different levels of TVsed0. Those estimates come out of the -margins- command which does all the messy work of figuring out which coefficients to add and multiply by what for you. I think if you more or less forget about the regression output and just focus on the -margins- output you already have (plus the other one that I show just above in this post), you will get a good understanding of what your model says. The regression coefficients themselves have complicated interpretations that are, in any case, of no real use to anybody except as ingredients for calculating the results that -margins- gives you.

    The one thing that you might want to get directly from the regression itself is whether or not you really need an interaction, or whether there the non-interaction model is just as good a description of your data. (Otherwise put, whether the data are just as consistent with the effect of TVsed0 being the same at all times.) For that the regression can be followed by -testparm i.TVsed0#c.t- to get a p-value. I don't actually recommend doing this, but I know that some people really want to see that p-value. If you do, that is how you get it. Other than that, the main use of the regression output is as a prelude to using -margins- when you're running an interaction model.

    Comment


    • #3
      Clyde - thank you very much for your comprehensive and insightful response. This has certainly helped me a lot with my understanding and I am more confident in exploring these interaction terms (the ‘marginsplot’ worked out well too!). Thank you.

      RE: the -margins- command, I am interested in change in outcome per year for each level of TV viewing. I.e. the effects of time, conditional on TV viewing (the third output shown in my original post). Is there any way of observing whether the changes at levels 1, 2, 3 and 4 are (statistically) different to level 0?

      Many thanks,

      Kishan

      Comment


      • #4
        Is there any way of observing whether the changes at levels 1, 2, 3 and 4 are (statistically) different to level 0?
        Well, you can pull this off of the regression output itself. The coefficients 1.TVsed0#c.t, 2.TVsed0#c.t, etc. are the estimates of the difference between the time effect at that level and at level 0 because level 0 is your reference (base) category for TVsed0.

        That said, do you really want to look at statistical significance in a data set with a quarter of a million observations? The mind boggles imagining a difference so small that it would not be statistically significant here. Really, I think it would be better to ignore p-values and focus on whether the differences are large enough to be of any practical importance here.

        Comment


        • #5
          I might add here, are you sure it is tv watching that causes fluid IQ to change, or is the time in front of the TV the dependent variable here. Just an observation.

          Comment

          Working...
          X