Updated08/13/111Mplussyntaxfilesforsingle-andmultilevelmediationmodels,toaccompany:Preacher,K.J.,Zyphur,M.J.,&Zhang,Z.(2010).AgeneralmultilevelSEMframeworkforassessingmultilevelmediation.PsychologicalMethods,15,209-233.Preacher,K.J.,Zhang,Z.,&Zyphur,M.J.(2011).Alternativemethodsforassessingmediationinmultileveldata:TheadvantagesofmultilevelSEM.StructuralEquationModeling,18,161-182.Note:InmodelsinwhichtheBetweenandWithincomponentsofa1→1pathareestimatedseparatelyandtheWithincomponentisrandom,theBetweencomponentisestimatedasthecontextualeffectratherthanastheBetweenslopeinMplus(seeMplusUser'sGuide,Ex.9.2).InExamplesFandJthishasbeenaddressedbyaddingtheWithinslopetothecontextualeffecttoyieldthecorrectBetweenslopecomponentbeforecomputingtheindirecteffect.A.simplemediationTITLE:simplemediationDATA:FILEISmydata.dat;!textfilecontainingrawdatainlongformatVARIABLE:NAMESARExmy;USEVARIABLESARExmy;ANALYSIS:BOOTSTRAPIS5000;!bootstrapisrecommendedforsimplemediationMODEL:!modelspecificationfollowsmONx;!regressmediatoronindependentvariableyONxm;!regressoutcomeonbothmediatorandindependentvariableMODELINDIRECT:!requestsignificancetestforindirecteffectofxonyviamyINDmx;!indirecteffectofinterest(endinginyandstartingwithx)OUTPUT:CINTERVAL(BCBOOTSTRAP);!requestbias-correctedbootstrap!confidenceintervalsB.2-2-1modelwithlatentvariables(MSEM)TITLE:2-2-1mediation(similarcodeusedinexample2)DATA:FILEISmydata.dat;!textfilecontainingrawdatainlongformatVARIABLE:NAMESAREgroupx1x2x3m1m2m3m4m5y1y2y3y4y5;MISSINGARE*;!missingdatadenoted*inmydata.datUSEVARIABLESAREgroupx1x2x3m1m2m3m4m5y1y2y3y4y5;BETWEENAREx1x2x3m1m2m3m4m5;!identifyvariableswithonlyBetweenvariance;!variablesthatarenotclaimedasBETWEENAREorWITHINAREcanhave!bothWithinandBetweenvarianceCLUSTERISgroup;!Level-2groupingidentifierANALYSIS:TYPEISTWOLEVELRANDOM;!tellMplustoperformmultilevelmodelingUpdated08/13/112MODEL:!modelspecificationfollows%WITHIN%!ModelforWithineffectsfollowsywBYy1y2y3y4y5;!ywisafactordefinedbyy1,y2,y3,y4,andy5%BETWEEN%!ModelforBetweeneffectsfollowsmbBYm1m2m3m4m5;!mbisafactordefinedbym1,m2,m3,m4,andm5xbBYx1x2x3;!xbisafactordefinedbyx1,x2,andx3ybBYy1y2y3y4y5;!ybisafactordefinedbyy1,y2,y3,y4,andy5mbONxb(a);!regressmbonxb,calltheslopeaybONmb(b);!regressybonmb,calltheslopebybONxb;!regressybonxb,tooMODELCONSTRAINT:!sectionforcomputingindirecteffectNEW(ab);!nametheindirecteffectab=a*b;!computetheindirecteffectOUTPUT:TECH1TECH8CINTERVAL;!requestparameterspecifications,startingvalues,!optimizationhistory,andconfidenceintervalsforalleffectsC.2-1-1model(traditionalMLM)TITLE:2-1-1mediation(traditionalMLM)DATA:FILEISmydata.dat;!textfilecontainingrawdatainlongformatVARIABLE:NAMESAREgroupxmy;USEVARIABLESAREgroupxmy;BETWEENISx;!identifyvariableswithonlyBetweenvariance;!variablesthatarenotclaimedasBETWEENISorWITHINIScanhave!bothWithinandBetweenvarianceCLUSTERISgroup;!Level-2groupingidentifierANALYSIS:TYPEISTWOLEVELRANDOM;MODEL:!modelspecificationfollows%WITHIN%!ModelforWithineffectsfollowsmy;!estimateLevel-1(residual)variancesformandyyONm(b);!regressyonm,calltheslopeb%BETWEEN%!ModelforBetweeneffectsfollowsxmy;!estimateLevel-2(residual)variancesforx,m,andymONx(a);!regressmonx,calltheslopeayONm(b);!regressyonm,constraintheslopeequaltobyONx;!regressyonxMODELCONSTRAINT:!sectionforcomputingindirecteffectNEW(indb);!nametheindirecteffectindb=a*b;!computetheBetweenindirecteffectOUTPUT:TECH1TECH8CINTERVAL;!requestparameterspecifications,startingvalues,!optimizationhistory,andconfidenceintervalsforalleffectsUpdated08/13/113D.2-1-1model(unconflatedMLM)TITLE:2-1-1mediation(unconflatedMLM)DATA:FILEISmydata.dat;!textfilecontainingrawdatainlongformatVARIABLE:NAMESAREgroupxmymmean;USEVARIABLESAREgroupxmymmean;BETWEENARExmmean;!identifyvariableswithonlyBetweenvariance;!variablesthatarenotclaimedasBETWEENAREorWITHINAREcanhave!bothWithinandBetweenvarianceWITHINAREm;!identifyvariableswithonlyWithinvarianceCENTERINGISGROUPMEAN(m);!group-meancentermCLUSTERISgroup;!Level-2groupingidentifierANALYSIS:TYPEISTWOLEVELRANDOM;MODEL:!modelspecificationfollows%WITHIN%!ModelforWithineffectsfollowsmy;!estimateLevel-1(residual)variancesformandyyONm;!regressyonm[m@0];!mwasgroup-meancentered,sofixitsmeantozero%BETWEEN%!ModelforBetweeneffectsfollowsymmean;!estimateLevel-2(residual)variancesforyandmmeanmmeanONx(a);!regressmmeanonx,calltheslopeayONmmean(b);!regressyonmmean,calltheslopebyONx;!regressyonxMODELCONSTRAINT:!sectionforcomputingindirecteffectNEW(indb);!nametheindirecteffectindb=a*b;!computetheBetweenindirecteffectOUTPUT:TECH1TECH8CINTERVAL;!requestparameterspecifications,startingvalues,!optimizationhistory,andconfidenceintervalsforalleffectsE.2-1-1model(MSEM)TITLE:2-1-1mediation(MSEM)DATA:FILEISmydata.dat;!textfilecontainingrawdatainlongformatVARIABLE:NAMESAREgroupxmy;USEVARIABLESAREgroupxmy;BETWEENISx;!identifyvariableswithonlyBetweenvariance;!variablesthatarenotclaimedasBETWEENISorWITHINIScanhave!bothWithinandBetweenvarianceCLUSTERISgroup;!Level-2groupingidentifierANALYSIS:TYPEISTWOLEVELRANDOM;MODEL:!modelspecif