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

  • Lincom statement to understand interaction between two continuous variables while holding other co-varates at their mean values?


    I am running a model in SEM to look at predictors of weight velocity (using SEM for the mlmv feature) and I am trying to understand a statistically significant interaction between two continuous variables (care=main effect 1; morbidity=main effect 2, and morbcar=the interaction between these two main effects). I am trying to better understand what this interaction means (and I think I can do so in lincom), but I am having trouble setting the command up.

    sem (wslopemean14 <- bsex birthweight morbidity care morbcare) if wslopemean14~=., nocapslatent method (mlmv)

    Could anyone help me with how I might set up a post-estimation in lincom to compare different values of morbidity and care while holding other co-variates (birthweight and bsex) at their mean values?

    Thank you!


  • #2
    If you were not using the full-information maximum-likelihood estimation, I would recommend re-doing the model altogether in -gsem- and using factor variable notation, then doing the postestimation with -margins-.

    gsem (wslopemean14 <- bsex birthweight if wslopemean14~=.
    Then then assuming that the interesting values of morbidity and care are 1, 2, 3, 4 and 5, 6, 7, 8 respectively, for the purposes of illustrating the code, I would do
    margins, at(morbidity = (1 2 3 4) care = (5 6 7 8)) atmeans
    margins, dydx(morbidity) at(morbidity = (1 2 3 4) care = (5 6 7 8)) atmeans
    marginsplot, xdimension(morbidity)
    margins, dydx(care) at(morbidity = (1 2 3 4) care = (5 6 7 8)) atmeans
    marginsplot, xdimension(care)
    But -gsem- does not support full information estimation. So I guess you are concerned about dealing with missing data. Let's just back up one step. Full-information maximum likelihood, like multiple imputation, rests on the assumption that the data are missing at random (MAR). If this is a human weight loss study, I would really be surprised if the data are MAR, particularly MAR with so few predictors available. Of course, I don't know the circumstances and perhaps you can make a credible case for it. And maybe this is an animal study where MAR or even MCAR (in which case you don't need mlmv) would be credible. But with human clinical studies I would start from the assumption that the data are missing not at random (MNAR) and then try to provide a convincing case that this time is different, and this time MAR makes sense.


    • #3
      Thanks, Clyde! I appreciate your quick reply. I have additional predictors in the model, but I thought it might be easier if I simplified the model for the purposes of getting help.

      The full model I'm working with is:

      sem (wslopemean14 <- bsex birthweight vg2-vg9 se2-se3 primip vaccine exbf1-exbf2 morbidity care ///
      morbvac morbcare) if wslopemean14~=., nocapslatent method (mlmv)

      wslopemean14= weight velocity in the 1-4 month growth interval (continuous)
      bsex=infant sex
      birthweight=birthweight (continuous)
      vg2-vg9= dummies for 9 villages
      se2-se3= dummies for middle and upper class (vs. lower class)
      primip= primiparous or not
      vaccine= vaccinated or not
      exbf1-exbf2= dummies for no exclusive breastfeeding and some exclusive breastfeeding (vs. reference of all exclusive breastfeeding)
      morbidity=morbidity score (continuous)
      care= amount of time spent in childcare (continuous)
      morbvac= morbidity score* vaccine interaction
      morbcare= morbidity score* care interaction

      The study is a longitudinal study of infant growth, and I have built a case that MAR is applicable, which is why I was using the mvml method (I hope it is convincing!) Otherwise, I end up losing too much sample size.

      Would these same margins commands work after SEM? If not, is there a way to do this in lincom? You actually helped me previously with a lincom statement, and I tried to extend that example to this case, but couldn't get it to quite work!

      Thanks again!


      • #4
        Well, if you are interested in contrasting the marginal effects of morbid and care at different value of morbid and care, then the part about holding everything else at their means doesn't really matter because all of those terms would enter into both of things being contrasted, so they would drop out in the end, except for the fact that you have a morbid # vaccine interaction. But that's not too terrible. So, suppose you wanted to contrast the marginal effect of morbid when morbid = 1 and care = 0.25 with the marginal effect of morbid when morbid = 3 and care = 0.5. Then you could do this:

        summ vaccine, meanonly
        local mean_vacc = r(mean)
        lincom _b[morbid]*(3-1) +  _b[morbcare]*(3*0.5 - 1*0.25) ///
            + _b[morbvac]*(3-1)*(`mean_vacc')
        That will give you a correct estimate of the difference between those two marginal effects of morbid. But if you want the actual marginal effects at both of those points in morbidityXcare space, then you would do:
        lincom _b[morbid]*3 + _b[morbcare]*3*0.5 + _b[morbvac]*(3*`mean_vacc')
        and an analogous -lincom- for the other one.

        So if you have a bunch of different combinations of morbid and care you are interested in, you could write some nested loops over the values (or a single loop over pairs of the values) and get them all. It's messy but doable.

        If you want to explore the actual expected values, then the means of all the variables come into play, and, worse, you can't do it with -lincom-. It becomes a fairly complicated program, which is basically coding a customized version of -margins-. I don't understand why StataCorp has not upgraded -sem- so that it supports -margins-, just as -gsem- does.


        • #5
          Thank so much! Both of these codes seem to run smoothly. Also, just for curiosity sake, I ran the initial code that you suggested for GSEM, but after my code in SEM. It was a little slow, but it did work. Is that expected?


          • #6
            If you ran that block of code with -margins- and -marginsplot- commands after your -sem- command, it gave you incorrect results. -sem- does not allow factor variable notation, and without factor variable notation, -margins- has no way to know that morbcare is the interaction of morbidity and care. So when -margins- ran, it just treated morbcare as another variable, with no particular relationship to morbidity and care. Consequently the estimates -margins- gave you do not reflect the interaction effect in your model, and they are not usable.


            • #7
              I see..thank you for that explanation! Greatly appreciated!