Announcement

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

  • Moderation in Structural equation model (SEM)

    Hi,

    i am modeling a SEM and I want to add a moderation. I have a variable with four values (education) and a variable with 7 values (life satisfaction). I assume that education influences the willingness to move abroad (coded from 1 to 7). However, I hypothesize that this relationship (education and moving abroad) is moderated by life satisfaction. How can I model this without modeling generalized SEM?

    Thanks for your support
    Lisa

  • #2
    Hi Lisa,

    You have to create the categories and interactions manually in SEM.
    Code:
    sysuse auto
    
    tab rep78, gen(rep78c)        // create 0/1 for each rep value
    tab headroom                      // treat as continuous
    
    foreach n of numlist 2/5 {
        gen rep`n'Xhead = rep78c`n'*headroom   // generate interactions
    }
    
    sem (price <- rep78c2-rep78c5 headroom rep2Xhead rep3Xhead rep4Xhead rep5Xhead)
    Edit: I assumed that you were treating life satisfaction as continuous. if not you would need to create a set of 0/1 indicators for it, and then manually calculate the interactions with the 0/1 indicators for education,
    Last edited by Erik Ruzek; 27 Sep 2024, 10:00.

    Comment


    • #3
      Hey, thanks for the quick answer. Dont I have to standardize the continuous variable?

      Best
      Lisa

      Comment


      • #4
        And, why are you not integrating rep1Xhead in your model?

        Best
        Lisa

        Comment


        • #5
          Also: wouldnt it make sense to also integrate the original rep78 variable into the model?

          Comment


          • #6
            The model does not converge when i do the dummy oprtion. Is the dummy neccessary or can I also just do it as in regressions (i.e. integrating the interaction term into the model which is calculated by education*standardized life satisfaction)?

            Comment


            • #7
              Lisa,

              The sem syntax I showed in #2 has the original rep78 variable, except that it is coded into separate 0/1 variables (rep78c2-rep78c5). I leave out all but the first of these in both the main effect for rep78 and in the interaction. It is necessary to leave out one category of rep78 in both its main effect and its interaction for the model to converge. You could omit the constant, but you will still need to leave out at least one term for the model to converge.

              Compare the results of what I showed you in #2 with what is produced by the equivalent gsem, which allows you to use Stata's i. and c. factor notation:
              Code:
              gsem (price <- i.rep78##c.headroom)
              margins rep78, at(headroom = (1.5(.5)5))        // unlike sem, you can follow the command up with margins
              marginsplot, xdimension(headroom)                // and plot it
              In terms of standardizing the continuous variable, you can do that if you like, but it is not necessary. It is probably field specific. I personally prefer to keep variables in their native metric if they are at all meaningful.

              It is hard to diagnose what is happening with your model without example data (use dataex) and the syntax for your model.
              Last edited by Erik Ruzek; 30 Sep 2024, 09:55. Reason: Grammatical fixes

              Comment


              • #8
                Hello, thanks for your reply. I understand that the original variable is integrated as binary variables. However, the resulting coefficients do not tell me the effect of that variable in the model but only the effect of the binary coded variables. That's why I was wondering why this binary-coded strategy is used instead of just interacting with the categorical variable with the moderator. Is there a mathematical reason why this binary coding is neccessary?

                Comment


                • #9
                  This would be the code with the interaction if I would do it as in normal regressions:
                  sem (move_abroad <- education life_satisfaction education*life_satisfaction)

                  According to your strategy, it would be
                  sem (move_abroad <- education_c1-c5 life_satisfaction education2Xlife-education7Xlife

                  In the second, I would not get the path coefficient for the direct path from education to move_abroad

                  Comment


                  • #10
                    Ah, I see. I assumed that you wanted to treat education as categorical given only four values and the fact that you called it categorical. When you treat it as continuous, you are assuming that the slope is best represented as linear. Maybe that is true, but I would want to check it both graphically using the raw data and the look to see if the education_c1-education_c5 slopes show a similar trend.

                    With the categorical version, you do not get a single coefficient for the "effect" of education. You get a series of contrasts for the cases of ed2 vs ed1, ed3 vs. ed1, etc. From this model, you could run a testparm command to get a test of the overall "effect" of education:
                    Code:
                    sem (price <- rep78c2-rep78c5 headroom rep2Xhead rep2Xhead rep3Xhead rep4Xhead rep5Xhead)
                    testparm rep78c2-rep78c5

                    Comment

                    Working...
                    X