Announcement

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

  • Interaction Effects and Models

    Hello all,

    I have a question regarding interaction effects and models. I want to test the interaction of age (continuous variable) on metabolic syndrome (binary variable). I found an example which uses the following command to test the interaction between a binary and continuous variable:

    Code:
     regress low_MCS curmetsyn##c.agenew
    and then using the following command to get the graph:

    Code:
     predict fit
    Code:
     twoway (line fit2 agenew if curmetsyn==0, sort) (line fit2 agenew if curmetsyn==1, sort lp(-)), legend(lab(1
    >  "MetS -") lab(2 "MetS +") ring(0) pos(1))
    ...which results in graph 1 attached.

    So the only thing is that I am using melogit to run regression with these variables since this is a longitudinal analysis, and I want to know if I would run the same command to test the interaction effects; for instance:

    Code:
     melogit low_MCS curmetsyn##c.agenew || newid:, nolog
    However, when I predict fit after this command and run the same code above for the graph, I get the second graph attached (graph 2).
    Can someone tell me which is the correct one? I would say the first one since it looks a lot more acceptable, but I am not sure.
    Any feedback would be appreciated.
    Thank you in advance.
    Attached Files

  • #2
    Victoria:
    if you're dealing with a longitudinal study, (ie, you have repeated measures on the same sample units), you should -regress- with clustered standard errors (otherwise Stata considers observations as independent).
    Besides, I fail to get why you use -regress- (that implies that the dependent variable is continuios) in your first code but switch to -melogit- (which performs mixed model for binary dependent variable) in your second one.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      After -melogit- the default prediction is mu, the expected probability of low_MCS, and it incorporates the random intercepts in it. That is why when graphed against agenew you see such erratic fluctuations. The group (newid) level variance shows up in the graph as this kind of noise. If you want a graph of the more systematic relationship, specify the -xb- option of -predict-, and then you can transform it to the probability metric with the invlogit() function before graphing it.

      That said, I can't quite figure out what your outcome variable is. In your first block of code you analyzed it with -regress-, suggesting it is a continuous variable, or perhaps that you wanted a linear probability model if it is dichotomous. Why then in the next set of analyses are you using -melogit-? If it's continuous then using -melogit- is almost certainly a blunder. And if you are interested in a linear probability model the first time, why not the second? In other words, it seems you would want to use -mixed- in the second analysis, having used -regress- in the first. What am I missing here?

      Added: crossed with #2.

      Comment


      • #4
        I am using melogit since my dataset is longitudinal, but I got confused since I saw an example that used the regress command when testing the interaction between a binary and continuous variable. Since I want to see the interaction effect between age and low MCS, continuous and binary variables respectively, I followed the example.

        I did what you suggested about using the predict xb option, however, when I try to use invlogit(), it tells me that this command is unrecognized.
        Do you have an idea of why this must be?

        Thank you both again for your feedback!

        Comment


        • #5
          -invlogit()- is not a command, it's a function used with the -generate- and -replace- commands, as well as in other places where expressions can be evaluated. So something like:

          Code:
          predict xb, xb
          gen phat = invlogit(xb)
          graph twoway line phat agenew if....
          Last edited by Clyde Schechter; 27 Mar 2018, 15:11.

          Comment


          • #6
            Ok great, this worked.
            Thank you!

            Comment

            Working...
            X