Announcement

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

  • Second stage moderated mediation in STATA using SEM

    Hi all,

    I am trying to run Hayes' PROCESS Model 14 in STATA using SEM and I am getting stuck on how to interpret the results. PROCESS throws out a 'ModMedIndex' which in essence is a single beta coefficient (with std. error and p-value) that tells us if the moderation is significant.

    I tried following the instructions on STATA's webpage: https://stats.oarc.ucla.edu/stata/fa...tion-in-stata/ and it runs fine, just that I am unable to interpret if the moderation is significant. For context, I am running multiple such moderated mediations and trying to summarize them in excel so having a 'ModMedIndex' similar to SPSS would be fantastic. Mike Crowson has a youtube video with a STATA do file on model 7 (https://www.youtube.com/watch?v=i1NaI3FbLCk) but I could not figure out how to replicate this for Model 14.

    Any help would be much appreciated! Here is my current code.

    *********************
    Code:
    foreach dv in dv1 dv2 dv3 { //three DVs
                foreach iv in iv1 iv2 iv3 { //three IVs
                            foreach mod in mod1 mod2 { //two moderators 
                                        quietly summarize `mod'
                                        global m=r(mean)
                                        global s=r(sd)
                                        local i=1
                                        foreach med in med1 med2 {  //two mediators
                                                                            generate s2int=`med'*`mod'   //*   mediator by moderator  interaction * s2int is short for stage 2 interaction
                                                                            sem (`med' <- `iv')(`dv' <- `med' `iv' `mod' s2int)     
                                                                            nlcom (ints2low`i':_b[`med':`iv']*(_b[`dv':`med']+($m-$s)*_b[`dv':s2int])) (ints2mid`i':_b[`med':`iv']*(_b[`dv':`med']+($m)*_b[`dv':s2int]))(ints2high`i':_b[`med':`iv']*(_b[`dv':`med']+($m+$s)*_b[`dv':s2int])), post //post estimation calculates the total conditional indirect effect at three levels of the moderator
                                                                            local i=`i'+1
                                                                            drop s2int
                                        }
                            }
                            estout . using sample.xls, cells(b(star fmt(3)) se(par fmt(2))) append unstack drop($cntrl, relax)
                }
    }
    Last edited by Neal Jha; 01 Sep 2022, 17:45.

  • #2
    Hi Neal
    On Hayes's website, he notes that this index is only available when no higher-order interactions or nonlinear effects are implied by a model. Because you only have 'Stage 2' moderation in your model, it looks like the index would merely be the conditional part of each indirect effect. You should be able to code for this and estimate it as the implied conditional part of each indirect effect. I don't use process so thanks for mentioning this Hayes index, which I hadn't heard of previously.

    In case it's relevant, Instats is offering a series of seminars on Stata's sem command including bootstrapped CIs for indirect effects and conditional indirect effects. All seminars are combined in a Structured Course in case it's of interest.

    Best wishes
    Mike

    Comment


    • #3
      Hi Mike,

      Thanks again!

      You are right - I was evnetually able to figure out that what I am looking for, is simply the difference between two conditional indirect effects. Posting it here incase someone else finds use for this.

      I used the Model 3 (PROCESS Model 14) on this webpage (https://stats.oarc.ucla.edu/stata/fa...tion-in-stata/). I just added an additional step where I calculate the difference between the conditional indirect effect at high versus low level of my moderator. Then, I used William's advice on my 'how to run a program within a loop in STATA' post to first write a program then run a forloop with it.

      Code:
      //program to calculate stage 2 moderated mediation
      program Stage2_ModeratedMediation, rclass
      syntax varlist(min=4 max=4) [if] [in]
      local dv : word 1 of `varlist'
      local iv : word 2 of `varlist'
      local mod : word 3 of `varlist'
      local med : word 4 of `varlist'
      gen s2int = `mod' * `med' //creating the interaction term b/w the mediator and the moderator
      quie sum `mod'
          local mod_mean=r(mean) //mean level of moderator
          local mod_sd=r(sd) //sd of moderator
      quie sem (`iv' $controls ->`med')(`med' `iv' `mod' s2int $controls -> `dv')
        return scalar lowmod = _b[`med':`iv']*(_b[`dv':`med']+(`mod_mean'-`mod_sd')*_b[`dv':s2int]) //(A) is not needed - just shows us the conditional indirect effect at low level of moderator
        return scalar highmod = _b[`med':`iv']*(_b[`dv':`med']+(`mod_mean'+`mod_sd')*_b[`dv':s2int]) //(B) is not needed - just shows us the conditional indirect effect at high level of moderator
        return scalar index = (_b[`med':`iv']*(_b[`dv':`med']+(`mod_mean'+`mod_sd')*_b[`dv':s2int]))-(_b[`med':`iv']*(_b[`dv':`med']+(`mod_mean'-`mod_sd')*_b[`dv':s2int]))  //gives us the index we are looking for - calculates whether B-A is significant
        drop s2int
      end
      
      //running a loop with multiple DVs, IVs, mediators and moderators.
      estimates drop _all
      clear results
      foreach dv in dv1 dv2 dv3 dv4 {
          foreach iv in iv1 iv2 iv3 iv4 {
              foreach mod in mod1 mod2 mod3 mod4 {
                  foreach med in med1 med2 med3{
                      bootstrap index`mod'_`med'=r(index), seed(1) reps(500) nodots: Stage2_ModeratedMediation `dv' `iv' `mod' `med'
      eststo index_`mod'_`med'
                  }
              }
          estout index_* using output.xls, title("DV:`dv' IV:`iv'") cells(b(star fmt(3))) append unstack
          }
      }
      Last edited by Neal Jha; 14 Sep 2022, 19:30.

      Comment


      • #4
        Hi Neal,

        Were you able to show the interaction plots for Process Macro Model 14??

        Comment

        Working...
        X