Announcement

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

  • Graphing Interaction of Time-Varying Covariate and Dummy Variable in a Growth Curve Model using MIxed

    Greetings. I have a longitudinal data set (set up in long form), and I am trying to graph a significant interaction of a time-varying predictor (ValueW, which is a continuous variable measured at 4 different time points) by a non-time varying predictor (female, a dichotomous measure of sex (male = 0, female = 1)). The outcome/dependent variable is a continuous measure of condom negotiation efficacy, also measured at the same 4 time points (cndngW).

    The “mixed” command/syntax that I am using works fine, this is the command (relevant variables are bolded):

    mixed cndngW c.valueW expecW i.female gpa clsmast clsext clsavd i.female##c.valueW || ID_STUDENT: year, cov(unstructured)

    The output indicates that there is a significant interaction of female X valueW (p<.001).

    I am trying to generate a graph to visualize this interaction. I usually use “margins” followed by “marginsplot,” but given that there is a time-varying predictor (valueW), I cannot get this to work. I am hoping that you can tell me how I can generate this graph (or some type of graph that will allow this to be visualized). So essentially I want to see how this interaction of a time-varying predictor (valueW) by a time-invariant dummy variable (female) predict a dependent variable measured at 4 time points (condngW).

    Any insights would be greatly appreciated.
    Last edited by Eric Anderman; 14 Nov 2020, 12:00.

  • #2
    You are fitting a wrong model. You need 'year' in the main part of the model and interaction of female, year and valueW. Year as random effect and not having fixed effect is meaningless. You did not show any data example so assuming valueW ranges from 0 to 4 The syntax should be:

    Code:
    mixed cndngW c.valueW##i.year##i.female expecW gpa clsmast clsext clsavd || ID_STUDENT: i.year, cov(unstructured)
    
    margins i.female#i.year, at(valueW=(0/4))
    marginsplot, xdim(year) by(female)
    Roman

    Comment


    • #3
      I actually did have year in the main model (I just left that out of the sample code that I had posted), but I did not specify the interaction the way that you suggested. ValueW ranges from 1 through 5. I will try that. Many thanks.

      Comment

      Working...
      X