Message/Author 

Zahi B posted on Monday, December 10, 2012  8:47 am



Hello, I am attempting to test a mediation model: tl (level 2)> ap (level 1)> ca ma (level 1)> cr (level 2) the model also include tc (level 1) which moderates the relationship between tl & ap. I scanned the threads, and attempted various suggestions in order to incorporate the moderation effect (I use the commands XWITH and DEFINE but nothing seems to work). I would love to hear any suggestions. TITLE: moderated mediation model DATA: FILE IS c:/mydata6.csv; VARIABLE: NAMES ARE group tl tc ap ca ma cr; MISSING ARE ALL (999); USEVARIABLES ARE group tl tc ap ca ma cr; BETWEEN ARE tl cr; CLUSTER IS group; CENTERING = GRANDMEAN (tc ap ca ma); ANALYSIS: TYPE IS TWOLEVEL RANDOM; MODEL: %WITHIN% ca ON ap(s1); ma ON ap(s2); %BETWEEN% tl cr; ca ON tl(b1); ma ON tl(b2); ap ON tl(b3); cr ON ca (b4); cr ON ma (b5); cr ON ap (b6); cr ON tl (b7); MODEL CONSTRAINT: NEW(abw1 abw2 abw3 abw4); abw1 = b3*s1; abw2 = b3*s2; abw3 = s1*b4; abw4 = s2*b5; OUTPUT: TECH1 TECH8 CINTERVAL; 


You say that you want tc (level 1) to moderate the relationship tl (level 2)> ap (level 1) The meaning of that relationship must be that tl influences the level2 part of ap (which in turn influences the observed ap score). Therefore moderation must be a level2 matter and if tc moderates this, it must be the level2 part of tc that does the moderation. I don't know if this is in line with your thinking. If it is, read on. So on level 2 (between) you have an observed tl predictor of a latent (betweenpart of) ap DV where you have an interaction (due to moderation) between tl and the latent (betweenpart of) tc. So a latent tc interacting with an observed tl. This calls for XWITH, but I am not sure if you can directly use the latent tc or have to first represent it as a factor. 

Zahi B posted on Tuesday, December 11, 2012  11:33 pm



Dear Bengt, Thank you for kind replay. What you described is exactly what I had in mind. I adopted your suggestion to apply the XWITH command in the %BETWEEN% section (interaction  tl XWITH tc) but the program produced an error message. So instead I used the DEFINE command, the code is attached below. USEVARIABLES ARE group tl tc ap interact; BETWEEN ARE tl; CLUSTER IS group; CENTERING = GRANDMEAN (tc ap); DEFINE: interact = tl*tc; ANALYSIS: TYPE IS TWOLEVEL RANDOM; MODEL: %WITHIN% %BETWEEN% tl; ap ON tl interact; OUTPUT: TECH3 CINTERVAL; 


The DEFINE command does not handle latent variable  you want the latent betweenlevel part of tc. Please send your failed output to Support so we can see what happened. 


I am having difficulty creating an interaction term for a moderation. I have a two level indirect model and would like to test for a moderating variable at the within level. This is my syntax: USEVARIABLES ARE ID PVs PPs Zvig Cs Vgs Te Os Ss; WITHIN ARE Cs Zvig Ss; Between are Vgs Te Os; CLUSTER IS ID; DEFINE: CENTER Cs Zvig (GROUPMEAN); !groupmean center predictor variables CsxSs  Cs XWITH Ss; !interaction term ANALYSIS: TYPE IS TWOLEVEL; MODEL: %WITHIN% PVs on Zvig; PPs on Zvig; PVs; PPs; !add controls %BETWEEN% PVs on Vgs; PPs on Vgs; PVs on Te; PPs on Te; PVs on Os; PPs on Os; PVs PPs; Vgs Te Os; MODEL INDIRECT: PVs IND Zvig Cs; PPs IND Zvig Cs; ANALYSIS: TYPE=RANDOM; ALGORITHM=INTEGRATION; MODEL: !add moderator Zvig on Cs Ss CsxSs; I got an error message saying that I needed to add ALGORITHM=INTEGRATION, so I did. I was getting back an error stating that to declare interaction, TYPE=RANDOM must be specified. So I did that, and now the error message is about how the interaction term is defined, but no suggestions for fixing. Can you please help? Thank you! 


XWITH is not used in the DEFINE command. It is used in the MODEL command. It appears that cs and ss are observed variables so XWITH should not be used. It is for latent variable interactions. You can create the interaction as follows: DEFINE: CsxSs = Cs * Ss; Put csxss at the end of the USEVARIABLES list. 


Linda, Thanks for the quick reply. Actually, Cs and Ss are latent variables (Control scale and Stress scale). Should I still use the DEFINE: CsxSs = Cs*Ss; command? Thank you again, Johnna 


They can't be latent variables if they are on the USEVARIABLES list. Latent variables are created using the BY option in the MODEL command. If you mean they are factor scores, these are treated as observed variables. 


I see  My apologies. Thank you again! Johnna 

Nathan posted on Monday, March 06, 2017  9:26 pm



Hi Team, Thanks for all of your work. I’m been scrolling through the board and this thread is the closest I think to my issue. Same as Zahi it is a leadership question. Leadership (level 2) (X) Mediator (M) Outcome (Y) and the level1 moderator (w) is on the ‘a’ path (interaction term is XW). USEVARIABLES ARE Team X W XW M Y; Between are Xclus XW; Within are ; Cluster is Team; DEFINE: Xclus = CLUSTER_Mean(X); MODEL: %WITHIN% Y ON M W; %BETWEEN% M ON Xclus W XW; Y ON Xclus; The issue I am getting is that the W and WX are coming up as having clusters as well. Also, not sure that I am doing this correct at all. Thanks – Nathan. 


Although X is level 2, W is level 1 so if you create their product you get a variable that varies not only across clusters but also within clusters, so you can't declare it as Between. Instead, use a crosslevel approach with a random slope for X>M: MODEL: %WITHIN% s  M on W1; Y on M W1; %BETWEEN% s ON Xclus; M ON Xclus W2; Y ON Xclus W2; where w1 is defined (in Define) as a groupcentered version of w and w2 is the clustermean version of w. This implies that the random slope s brings in a product of Xclus and W1 in the influence of W on M. 

Nathan posted on Tuesday, March 07, 2017  9:10 pm



Hi Bengt, Fantastic. Thank you so much for your help  really appreciate it. Thanks, Nathan 

Nathan posted on Saturday, July 29, 2017  3:56 pm



Hi Bengt, Thank you so much for your help last time. I just want to ask an extension question. I am wanting to provide the indirect effect at the different levels of the moderator for multiple DVs. I believe I am off track on the code and was hoping you might be able to help me get back on the right path. Thanks, Nathan ANALYSIS: TYPE = TWOLEVEL RANDOM; DEFINE: W1 = ZMed; W2 = CLUSTER_MEAN(ZMed); IVClus = CLUSTER_MEAN(zIV); MODEL: %WITHIN% s  ZMed ON W1; ZDV1 ZDV2 ON ZMed w1; %BETWEEN% s ON IVclus (b2); ZMed ON IVclus w2; ZDV1 ON IVclus w2 (b3); ZDV2 ON IVclus w2 (b4); [s] (b1) MODEL CONSTRAINT: New(SSminus SSmean SSplus); SSminus = (b1+b2*(1))*b3; SSmean = (b1+b2*0)*b3; SSplus = (b1+b2*(1))*b3; New(SS2minus SS2mean SS2plus); SSminus = (b1+b2*(1))*b4; SSmean = (b1+b2*0)*b4; SSplus = (b1+b2*(1))*b4; 


It looks like your mediation is on the Within level so I don't understand why you have parameter labels on the Between level. Check the Preacher and Zyphur articles on multilevel mediation. 

Back to top 