Message/Author 

Oli Christ posted on Thursday, August 25, 2005  3:15 am



I have a multilevel example where I expect the relationship between two individuallevel variables to be moderated by a grouplevel variable (one that varies only betweengroups). Can I test this hypothesis using MPlus? The handbook seems to suggest that currently MPlus cannot handle crosslevel interactions. However, I would like to take advantage of MPlus's groupmean centering options to decide whether I am dealing with a crosslevel interaction or a betweengroup interaction. 


I think you will get the results you want by the following partial setup: WTIHIN = x; BETWEEN = w; MODEL: %WITHIN% s  y ON x; %BETWEEN% s ON w; 


I would like to estimate a path model with manifest variables in which a variable that varies within as well as between clusters (i.e., intelligence) is regressed on intelligence measured at an earlier time point and several other variables that vary ONLY between clusters (school classes) but are constant within clusters (i.e., variables such as class climate etc.). Furthermore, several of these clusterlevel variables are supposed to be connected to other cluster level variables via regression or covariance paths. I am not sure if and how such a model can be specified in Mplus? It would be great if you could provide an appropriate example input code. Thank you very much. 


Here is an example. Note that on the between level, y1 and y2 are the between parts of intelligence. Between = w1 w2 w3; Model: %within% y2 on y1; %between% y2 on y1 w1w3; w3 on w2; w2 on w1; 


I have a multilevel analysis in which I have betweenlevel dependent variable that needs to be regressed on a few withinlevel predictor variables, as well as a few betweenlevel predictor variables (all variables are manifest variables). I'm not sure if the MPlus code that I am currently using is correct, so could you possibly give me an example of the setup file that could handle this analysis? 


I think you mean that you want to regress a betweenlevel variable on the between part of a withinlevel variable. This can be done by not putting the variable on the WITHIN list. See Chapter 9 for multilevel examples. 

jan posted on Thursday, March 08, 2007  10:57 am



I'm new to multilevel modeling and maybe my question is simple, but I didn't find the answer, yet. I need to predict an individuallevel variable (selfconcept) by another individuallevel variable (achievement) as well as by the aggregated level of the latter one (class achievement). Doing the following is wrong, of course, because then I'll have a between level selfconcept. %within% self ON achiev; %between% self ON achiev; What I need is something like: self ON indiv_achiev class_achiev So, I'm wondering how to perform this in Mplus. Thank you very much. 


The standard multilevel approach is to say that the influence of classlevel achievement on selfconcept is through the classlevel part of selfconcept (the classlevel part of selfconcept is of course a part of the student's selfconcept score). The classlevel part of selfconcept is the random intercept of students' selfconcept regressed on achievement. In other words, your Mplus setup is correct. 

jan posted on Thursday, March 08, 2007  12:44 pm



Dear Mr. Muthen, thanks for your quick answer. I understand your point, but I don't think that it solves my problem. I want to research the bigfishlittlepondeffect, which supposes that students' individual selfconcept correlates positiv with their individual achievement and negativ with classaverage achievement. Several studies found this effect using HLMModels with classaverage achievement as a level2 predictor and individual achievement as a level1 predictor for students' selfconcept both times on level1, I think (e.g. Lüdtke et al. 2005 in Contemporary Educational Psy; Marsh et al. 2000 in JPSP). I am not dealing with HLM but with Mplus, so I hope to find this effect using Mplus. Maybe I made a big error in reasoning, but I'm still looking for the solution. A misunderstanding in my first message might have been that I talked about aggregated class achievement and not classaverage achievement. I would be very grateful for another idea. 


Let's see if we can understand each other more fully. In the HLM model references you refer to, I would guess that they do what corresponds to the random intercept model in Mplus: %within% self ON achiev; %between% self ON achiev;  except that their betweenlevel covariate is aggregated class achievement rather than the latent variable score that Mplus produces (the difference is probably not large)  and you can do that in Mplus. You can have a positive beta on within and a negative beta on between. But are you saying that you don't find this HLMtype approach sufficient? 

jan posted on Friday, March 09, 2007  3:41 am



I find this HLM approach sufficient. I just wanted to say, that I've no access to the HLMsoftware, but I'd like to find the bflpe (see my prior message) in my data using Mplus. So, what Marsh et al. did is the following: self = b0 + b1*achiev_ind + r (level 1) b0 = g00 + g01*achiev_class + u0 (level 2) b1 = g10 + g11*achiev_class + u1 (level 2) I think this in your short course (day 5) on slide 24 ff. So I tried the following in Mplus: %within% s  self ON achiev; %between% self s ON ach_class; self with s; Doing this, I get following error message: ...PROBLEM INVOLVING VARIABLE SELF. THE RESIDUAL CORRELATION BETWEEN S AND SELF IS 1.001 Am I  aside from the error message  on the right track, now? Should I fix the variance of s with self to 0 (I'm not familiar with fixing variances)? Doing this, I get another error: ... THE VARIANCE OF S APPROACHES 0. FIX THIS VARIANCE AND THE CORRESPONDING COVARIANCES TO 0, DECREASE THE MINIMUM VARIANCE, OR SPECIFY THE VARIABLE AS A WITHIN VARIABLE. 


self with S mean the corelation of intercept of self with slop, do you wanna know this correaltion? for higher corelation between slop and slop, we always center X before run the model, try center X to see what will happen well, since veriance of S approach 0(not statistically significant?), it means the slop is not random among level 2 units, if yes, you should run a random intercept only model if the intercept is random, if level 2 variance of self is also not statistically significant, then, just run an OLS regression. 


I would try a random intercept only model first, so get rid of the random slope. This means using the input %within% self ON achiev; %between% self ON ach_class; 

jan posted on Monday, March 12, 2007  3:13 am



Thanks again, this worked  even though I didn't get different directions for the two beta. 


I'm posting my question here since it's closely related with questions posted on this thread. I have a set of HLM equations that I want to run with Mplus. It's a 3level growth model(time points ?individual ?classroom) Level 1: Yijt = P0ij + P1ij*Time + eijt Level 2: P0ij = B00j + B01j*HRisk + r0ij P1ij = B10j + B11j*HRisk + r 1ij Level 3: B00j = G000 + G001*ECredit + u00j B01j = G010 + G011*ECredit + u01j B10j = G100 + G101*ECredit + u01j B11j = G111 + G111*ECredit + u11j continued on the next post... 


My model statement is as follow: model: %within% iw sw selfc@0 selfc2@1 selfc3@2 selfc4@3; selfc selfc2 selfc3 selfc4 (1); b01 iw on HRisk; b11 sw on HRisk; %between% ib sb selfc@0 selfc2@1 selfc3@2 selfc4@3; ib sb on ECredit; b01 on ECredit; b11 on ECredit; selfc@0 selfc2@0 selfc3@0 selfc4@0; I put the  statements to estimate the crosslevel interactions. I wonder if it's correct code. I looked at the examples in the manual, but it was not clear that I need  statements. Thank you for any help. 


This looks correct. Please keep posts within the size limitation. 

Dan Feaster posted on Wednesday, May 14, 2008  10:18 am



I am trying to estimate a crosslevel interaction with a latent variable score for the X variable at level 2(i.e. my X variable is defined at both within and between): %within% rshas pstmd_1 ON has_1; %between% pstmd_1 rhas ON has_1; rhas=0; Whether I free the random coefficient's variance or not I get errors like: "THE MODEL ESTIMATION DID NOT TERMINATE NORMALLY DUE TO A NONZERO DERIVATIVE OF THE OBSERVEDDATA LOGLIKELIHOOD." OR "THE LOGLIKELIHOOD DECREASED IN THE LAST EM ITERATION." Is this just 1)numerical problem with my data or 2) is this not possible in Mplus, at this time or 3) theoretically not possible (and I need to dig into the algorithm more)? I have no problem if I make this the calculated betweenlevel variable at level 2. 


Given the information that you provide, it sounds like it is something specific to your data and the model. Please send your input, data, output, and license number to support@statmodel.com so we can see the full picture. 

chris lo posted on Tuesday, July 08, 2008  9:23 am



I have repeated measurements over time (e.g., depression scores and pain scores) for a group of individuals. I also have some variables which were measured only once at study entry (e.g., personality trait scores and gender). I am running a multilevel model in which I am predicting the depression scores based on time and pain (level 1 variables). I have also entered the personality trait and gender variables as predictors (level 2 variables). My question concerns the specification of crosslevel interactions. Does a level 1 (repeated) variable have to be set as a random effect before I can enter in an interaction involving it and a level 2 variable? Thank you for any help with this. 


Yes, this is how it is done. See Example 9.2. 

M Hamd posted on Thursday, April 01, 2010  5:06 pm



I am trying to explore crosslevel effects. Here is the case: x leads to y (at level 1) x leads to M which leads to y (at level 2) M also moderates the relation between "x and y" at level 1. Is the following code correct? BETWEEN = M; MODEL: %WITHIN% s  y ON x; %BETWEEN% M on x; s Y ON M; 


Crosslevel interactions are obtained using a random slope model like the one you have specified. See Example 9.2 for further information and Slide 45 of the Topic 7 course handout. 


Hallo, I've question about between level interaction. Suppose I'v got simple multilevel path model with random intercept: WITHIN ARE w x*z; %WITHIN% y on x z x*z; x z on w; where x*z is interaction term. I want to replicate this structure on between level. To have: %BETWEEN% y on x z x*z; the problem is that I could not use XWITH option to specify interaction x*z on between level because x and z are not seeing as latent variables. Should I prepare aggregate variable with is interaction between clusters means of x and z or is it possible to do it in Mplus directly in the model? Best regards Artur 


Do you want a crosslevel interaction of a within variable x with a between variable z or do you want to create an interaction term to use on the between level. 


The second option. I want to create an interaction term to use on the between level. 


Are you going to use observed variables on within and between or are you going to use a latent variable decomposition of the variable. See Example 9.1 for an explanation of these two approaches. 


I try to have latent decomposition of two variables x and z and interactions between those latent parts on between level. 


Do not put x and z on the WITHIN list and use the following for the between part of the MODEL command: $BETWEEN% fx BY x; x@0; fz BY z; z@0; xz  fx XWITH fz; y ON fx fz xz; 


Hello, I am trying to analyze a model with a crosslevel interaction, with a onebetween (BEAT), onewithin (AGG) design. I tried the following code: WITHIN = beat ; BETWEEN = agg; CLUSTER = subj; DEFINE: beat_agg = beat * agg; ANALYSIS: TYPE = TWOLEVEL RANDOM; ALGORITHM = INTEGRATION; MODEL: %WITHIN% s  trusty ON beat ; %BETWEEN% trusty ON agg; s on agg; This gave an error mesage: THE MODEL ESTIMATION DID NOT TERMINATE NORMALLY DUE TO A NONZERO DERIVATIVE OF THE OBSERVEDDATA LOGLIKELIHOOD. I think the solution would be to fix the slope, using s@0. However, this gives the message: SERIOUS PROBLEM IN THE OPTIMIZATION WHEN COMPUTING THE POSTERIOR DISTRIBUTION. CHANGE YOUR MODEL AND/OR STARTING VALUES. Can you give any advice on how to get this model to run? 


Please send the files and your license number to support@statmodel.com. 


Hi, I would like to know how to set up the data for multilevel analysis. I have a unit level construct (team environment) with its measure is referring to the team environment but these survey items are reported by indivduals within the team. So, it is the unit level construct. In my case, I have 200 teams with 45 team members each. I wonder if I should aggregate the data from individual level to the unit level and treat this construct as the variable in the 'between' group command. Please advise. Thanks. 


See the following paper which is available on the website: Lüdtke, O., Marsh, H.W., Robitzsch, A., Trautwein, U., Asparouhov, T., & Muthén, B. (2008). The multilevel latent covariate model: A new, more reliable approach to grouplevel effects in contextual studies. Psychological Methods, 13, 203229. 

Katy Roche posted on Thursday, May 26, 2011  9:25 am



I am trying to test interactions while accounting for clustering (these are NOT crosslevel interactions)...the clustering is only being accounted for in order to obtain correct standard errors. With clustered data and tests of interactions, it is correct to specify: TYPE=COMPLEX and ALBORITHM=INTEGRATION? I am wanting to compare my results from the models accounting for clustering to those that did not  in those models I specified TYPE=RANDOM. 


You need to specify TYPE= COMPLEX RANDOM. This can be used with ALGORITHM=INTEGRATION. 

Katy Roche posted on Thursday, May 26, 2011  11:05 am



Thank you  that did it. One more related question. When I run this same model without the interactions I get the error message that others have posted before (see below) and am curious to know why this would NOT be a problem in the model testing interaction effects. Do you suggest I need to run a Montecarlo for the main effects structural model or am OK to rely on results despite this message? Nothing in results looks very different from teh model that does not account for clustering. THE MODEL ESTIMATION TERMINATED NORMALLY THE STANDARD ERRORS OF THE MODEL PARAMETER ESTIMATES MAY NOT BE TRUSTWORTHY FOR SOME PARAMETERS DUE TO A NONPOSITIVE DEFINITE FIRSTORDER DERIVATIVE PRODUCT MATRIX. THIS MAY BE DUE TO THE STARTINGVALUES BUT MAY ALSO BE AN INDICATION OF MODEL NONIDENTIFICATION. THE CONDITION NUMBER IS 0.234DPROBLEM INVOLVING PARAMETER 33. THIS IS MOST LIKELY DUE TO HAVING MORE PARAMETERS THAN THE NUMBER OF CLUSTERS MINUS THE NUMBER OF STRATA WITH MORE THAN ONE CLUSTER. 

Katy Roche posted on Friday, May 27, 2011  8:42 am



In thinking about the problem I am running into with this error message for the main effects model (not interaction effects model)accouning for clustering, I redid analyses and specificed TYPE = COMPLEX RANDOM; in the main effects model. In that case, I do not get the error message. Of course, I also do not get standardized estimates that I want. So, I guess I am still wondering if I am OK to report coefficients from the main effects model accounting for clustering (TYPE=COMPLEX) despite the error message. 


I think you are, but only a Monte Carlo study could show it clearly. 

kirsten way posted on Friday, October 21, 2011  10:46 pm



Hi, I'm trying to plot my significant cross level interaction using preacher's calculator. I've requested TECH3 in the output to get the coefficient covariances, but wanted to ask  how do I ascertain what variables the parameter numbers in the printout refer to? Thankyou! 


They refer to the parameter numbers in TECH1. 

MT posted on Monday, February 27, 2012  6:18 am



Dear Linda, I am trying to model the following paths: At the withinlevel, I have one predictor (strucjr) and a dependent variable (bevl). This relationship is maybe moderated by a level2 variable (Tafh). At the betweenlevel, I have one predictor (Tstrucjr) and a dependent variable (Tbevl). This relationship may be moderated by a second level2 variable (Tauto). I have the following syntax but am not sure how to model the betweenlevel moderation. Could you please help me with this? CLUSTER IS Team; BETWEEN IS Tafh Taut Tbevl Tstrucjr; WITHIN IS StrucJR; Centering = Grandmean (Tafh Taut); Centering = Groupmean (StrucJR); USEVARIABLES ARE StrucJR Bevl Tafh Taut Tstrucjr Tbevl; ANALYSIS: TYPE = TWOLEVEL RANDOM; ESTIMATOR = ML; ALGORITHM = INTEGRATION; MODEL: %WITHIN% s  Bevl ON StrucJR; %BETWEEN% s Bevl ON Tafh; !crosslevel interaction Tbevl ON Tstrucjr; ! betweenlevel interaction? Thank you so much in advance! 


You can use the DEFINE command to create the betweenlevel interaction terms. 


Hello, I am estimating a multilevel path model and estimate a crosslevel interaction effect. When doing that, I cannot specify the direct effect of the level1 predictor on the dependent any more. In nonSEM Multilevel models that usually is still possible  I would be grateful if you could let me know how I might be able to specify the direct effect of the level1 predictor despite also estimating the crosslevel interaction. The relevant part of the model (there are some paths and covariates at the individual level) reads %Between% I ON A_SocCap; LifeSat ON A_SocCap; %Within% I  LifeSat on DV_U; So essentially my question is whether I can estimate the direct effect of DV_U on LifeSat at level1 still or whether that is not possible in a ML SEM. Thank you very much for your help!! 


Do you mean the direct effect LifeSat on DV_U? You specify this on within as a random effect. The mean and variance of this random effect are found on between. 


Dear Linda, thank you very much  I forget that I get the mean estimated and that it would be that of course. Thanks for your quick help! Best wishes 


Dear Linda, I have specified a crosslevel effect model investigating employee perceptions at the individual level and their impact on the group level performance. The model is: %within% B on A; %between% C on B; D on C; The results are fine but the journal reviewers would like to know if we can identify the impact of A on C and D. Thanks. Pat 


To estimate crosslevel interactions between A with C and C, you need a random slope model. See Example 9.2 in the user's guide. 


Dear Linda, Thanks for the advise on using a random slope to explain the corsslevel interactions. I have questions about the model specification provided in Example 9.1. I would like to know how the grandmean (x) contributes to the analysis. There are both x and xm which already represent x variable in the within and between levels. The other question is I wonder if we can assume that the system refer to random intercept y to represent y in the between part of the model if we use latent variable y in the within level. Thanks. Pat 


Centering x is not necessary. It sometimes helps in interpretation to have a variable with mean zero. y is not on the WITHIN list so y is a random intercept on the between level. 


Dear Linda, I am testing the moderating effects of coping (AVO) between stressor (AS) and outcome (PD). I ran it with following codes. USEVARIABLES ARE SV_ID AS_1 PD_1 AVO_1 AS_AVO; WITHIN are AS_AVO; CLUSTER = SV_ID; ANALYSIS: TYPE = TWOLEVEL random; ALGORITHM=INTEGRATION; ! AVOIDANCE coping MODEL: %WITHIN% PD_1 on AS_1; ! pd=psychologcial distress PD_1 on AVO_1; PD_1 on AS_AVO; %BETWEEN% fx by AS_1; AS_1@0; fz by AVO_1; AVO_1@0 xz  fx XWITH fz; PD_1 on fx fz xz; I received... *** WARNING in MODEL command In the MODEL command, the following variable is a yvariable on the BETWEEN level and an xvariable on the WITHIN level. This variable will be treated as a yvariable on both levels: AS_1 ... as a yvariable on both levels: AVO_1 2 WARNING(S) FOUND IN THE INPUT INSTRUCTIONS THE ESTIMATED BETWEEN COVARIANCE MATRIX COULD NOT BE INVERTED. COMPUTATION COULD NOT BE COMPLETED IN ITERATION 106. CHANGE YOUR MODEL AND/OR STARTING VALUES. THE MODEL ESTIMATION DID NOT TERMINATE NORMALLY DUE TO AN ERROR IN THE COMPUTATION. CHANGE YOUR MODEL AND/OR STARTING VALUES. Could you me any suggestions? 


Please send the output and your license number to support@statmodel.com. 


Dear Linda, I am working on a model with 3 crosslevel interactions predicting 3 withinlevel outcomes, resulting in 6 tested random slopes. I am following example 9.2 of the guide. This example has two alternative options. In the first alternative you specify: y s ON w xm (between level) And in the second alternative you specify: y s ON w x (between level) In my example I am interested to see if the moderator (w) explains the relationship from x to y (specified at the within level). So I can't see why I would include x or xm in this two statements above. Can I skip that completely and simply say the following: y s ON w (between level) ? When I do this, though, I cannot interpret my results. At the within level I can only see residual variances and corelations. If I know the estimate from w to s, don't I also need to know the estimate from x to y at the within level in order to interpret the pattern of my interaction? 


You don't need to include x or xm, but often these "contextual" variables have a significant influence on between. When you have a random slope s and regress it on w (crosslevel interaction) you estimate this regression's intercept, slope, and residual variance. The slope gives the interaction effect. You can think of the intercept as the influence of x on y at w=0. 


Thank you for your reply, Bengt. So if I understand correct the intercept of the slope shows the main effect of x to y (irrespective of w). How can I interpret the pattern of my interaction, though? Do I need to make a plot or can I interpret it directly from my findings? I assume that in order to have a significant interaction the path from w to s needs to be significant. In my example, the intercept of the slope is nonsignificant. If the path from w to s is positive significant, does it mean that x to y becomes positive for high levels of w? Best, Paris 


If you center w, the intercept is the effect of x to y at the w mean. Your sample statistics tell you what the SD of w is, so that you can evaluate the effect of x on y at say 1 SD and +1 SD away from the w mean. Yes, a significant interaction happens when the influence of w on s is significant. The sign and value of the influence of x on y for different values of w is obtained as in my first paragraph. You may also want to study this topiic in multilevel books such as RaudenbushBryk. 


We are trying to examine cross level interactions (i.e., s1 s2 on M032MNRT;) in this multilevel model. We received a ‘fatal error’ that we had a memory shortage due to 5 dimensions of integration needed. We are using an 8 processor. Is there something incorrect with our input statement? Model: %WITHIN% Conct by CO1R CO4R CO6R CO7R CO8R CO12R CO13R CO20R SE1R SE2R; Schl by SE4R SE7R AE1R AE2R AE3R MR1R SV23R; culture by FC1R FC3R FC4R FC8R; S1  Conct on culture; S2  Schl on culture; Conct on Male White; Schl on Male White; CO12R WITH CO7R; SE2R WITH SE1R; SE7R WITH SE4R; CO4R WITH CO1R; AE3R WITH AE1R; MR1R WITH CO4R; CO13R WITH CO6R; AE1R WITH SE7R; CO20R WITH CO4R; %BETWEEN% Conctb by CO1R CO4R CO6R CO7R CO8R CO12R CO13R CO20R SE1R SE2R; Schlb by SE4R SE7R AE1R AE2R AE3R MR1R SV23R; CO1RSE2R@0; SE4RSV23R@0; Conctb on M032Tnrl M032MNRT M032SUSP; Schlb on M032Tnrl M032MNRT M032SUSP; s1 s2 on M032MNRT; 


I assume you have a 64bit computer. With 5 dimensions you have 15^5 = a very high number of integration points. Taken together with a large sample, this causes memory problems. Try integration = montecarlo(5000); 

Ewan Carr posted on Wednesday, June 27, 2012  10:11 am



I have several questions relating to crosslevel interactions in Mplus. I'm using Bayesian estimation. The model is: %WITHIN% s  y ON x; %BETWEEN% x ON w; s ON w; y on x w; (this model also includes a mediating pathway, from x > w > y) [1] How can I interpret the crosslevel interaction effect (i.e. the regression of s on w, where s is the slope and w is the contextual effect)? Bengt's comment on May 16th makes sense, but when I ask for sample statistics I get: > SWMATRIX is available only for TYPE=TWOLEVEL with estimators ULSMV, WLS, WLSM or WLSMV. Request for SWMATRIX will be ignored. [2] Related to [1] is there any way of getting predicted values from Mplus? [3] How can I test the significance of the interaction? (beyond just looking at the pvalue or credible intervals). I'm guessing DIC isn't available with type=twolevel yet? In other words: is there any way of comparing nested models, when "type=twolevel random" and "estimator=bayes"? [4] I've run similar models in R/MLwiN  testing the crosslevel interaction effect the MLM way (i.e. with an interaction term). I get substantially different results, which is slightly worrying. Obviously, these are completely different approaches, but is there any reason to expect such variation? Many thanks, Ewan  


1. Do a Type = twolevel basic run to the sample statistics. Bayes does not use sampstat in its analysis and that's why you don't get that in your run. 2. Not directly. 3. The CI for s on w would seem to be the best way. 4. If the same estimator (ML/Bayes) is used, you should get the same results. If not, send the 2 outputs to Support. 

Ewan Carr posted on Thursday, June 28, 2012  3:00 am



Thank you Bengt, once again, for such a speedy response. It's much appreciated. 

Ewan Carr posted on Thursday, June 28, 2012  6:10 am



A quick followup question: I've rerun the model using "type=twolevel basic", and the following estimation options: type = twolevel basic; estimator = WLS; algorithm = integration; integration = 7; (Bayesian estimation isn't possible). [Question 1]: I've removed the "MODEL:" statement — that is, I'm just estimating an empty model. This is because "type=random" isn't possible with WLS. Is this correct? [Question 2]: I get a file "swmatrix.dat" out. How is this file organised? It just appears as a single column of numbers, with no labels (see here. I've searched the user guide and website for help with this, but can't find anything. I need the SD of the betweenlevel variable (w). Many thanks, Ewan  


Q1. Yes. Q2. SW saving is described on page 668. It is not meant for inspection but rather to be available in a second run so these quantities don't have to be computed again. If you are interested in the within and between sample statistics, you look at the output from a Type=Twolevel Basic run, where you put w on the Between list. 

Ewan Carr posted on Friday, June 29, 2012  4:39 am



Thanks Bengt. I think I've got this sorted. In case this is of use to others, I'll put my working here. The model is: %WITHIN% s  satlife ON empsec; %BETWEEN% s ON rrlongsing; satlife ON rrlongsing; The sample statistics for the contextual variable (rrlongsing) are: The coefficient for the regression of "S ON RRLONGSING" is 0.007, and the intercept for S is 0.195. I then calculate values for the regression at 1 SD above and below the mean of RRLONGSING:
19.68 * 0.007 = 0.138 This gives me the following values:
 rrlongsing  S ON empsec  Mean  1 SD  19.44  0.333  Mean  0.24  0.195  Mean + 1 SD  19.92  0.057  These can be plotted (see here), which seems to make sense. Thanks! 


If you express your computations in Model Constraint using model parameter labels you will both get better precision (more decimals) and SEs for the points in your graph. 


I have come across a reference that suggests that random slopes are not necessarily required to test for (and subsequently find) a significant crosslevel interaction. However, Hox makes no mention of thisnor have I seen any reference to this in searching the mplus forum. In a 2level model, I have systematically tested for variation in level 1 slopes, and nothing is significant. However, when I 'cheated' and tested for crosslevel interactions, several are significant. Is it reasonable to do this based on theory? Thanks. 


What's the reference? 


Multilevel Analysis: An Introduction to Basic and Advanced Multilevel Modeling. T. A. B. Snijders, Roel J. Bosker. (1999) p 96. This comes up in a google search: "multilevel cross level interaction non significant random slopes." AlsoLesa Hoffman's talk: Society of Multivariate Experimental Psychology Annual Meeting October 2011 Systematically Varying Effects in Multilevel Models: Permissible or Problematic? available at: http://psych.unl.edu/hoffman/Sheets/Talks.htm Thanks. 


I see. Yes, this is a phenomenon that also happens in growth modeling where a slope growth factor may not have significant variance when excluding timeinvariant predictors, but including them the effect of them on the slope is significant so the slope does vary. As the book page you mention says, it is a matter of having more power when you include the level 2 covariate and its interaction with the level 1 covariate. So, yes, it is reasonable to do this. 


Thank you Bengt. I also noticed that in Mplus Short Course Lesson 5A (slide 29) the random slopes are correlated with the dv, in what looks like a crosslevel interaction (pasted below). Is this correct? I have seen elsewhere just the crosslevel interaction, without "M92 with s1 s2". Thanks. %WITHIN% s1  m92 ON female; s2  m92 ON stud_ses; %BETWEEN% m92 s1 s2 ON per_adva private catholic mean_ses; m92 WITH s1 s2; 


Yes, this is a crosslevel interaction model because s1, s2 are regressed on betweenlevel covariates. The between level has 3 dependent variables and whenever there are several DVs I would covary their residuals. So, I would even add s1 with s2. But that covariation is a separate issue from crosslevel interaction. 


That makes sense, thanks. Finally, when I run my MLM models (MLF estimator) with cross level interactions, they have significant pvalues. However, testing nesting models using 2LL none of interaction models are significantly better. My understanding is that the 2LL is the better test, but this seems unusual. Can you indeed test nested models with MLF? Also, I'm assuming this is a 2tailed test? Thanks very much. 


Please send the two outputs and your license number to support@statmodel.com. 


Thanks, I realized I needed to zero out the crosslevel effects in the null model. I was incorrectly comparing a general twolevel model to a twolevel random model. 

Ewan Carr posted on Sunday, July 29, 2012  2:53 am



Dear Bengt/Linda, I'm trying to interpret a coefficient in a twolevel path analysis model. The model is:
%WITHIN% s  satlife ON empsec; %BETWEEN% satlife ON uempav grow; empsec ON cons; empsec ON uempav grow; satlife ON empsec; The betweenlevel output is below; the coefficient of interest is highlighted:
SATLIFE ON UEMPAV 0.000 GROW 0.037 EMPSEC 0.810 EMPSEC ON CONS 0.927 UEMPAV 0.000 GROW 0.038 Means S 0.230 My question, then, is what exactly does this coefficient represent? The mean S shows the individuallevel effect of EMPSEC on SATLIFE, but I'm not sure how the betweenlevel effect should be interpreted? Many thanks, Ewan  


Please send the output and your license number to support@statmodel.com. Empsec should not be used on between. It should be on the WITHIN list. I need to see the full situation. 

Ewan Carr posted on Sunday, July 29, 2012  11:55 am



Thanks, I will do. I was following the example of:
Preacher, K. J., Zhang, Z., & Zyphur, M. J. (2011). Alternative methods for assessing mediation in multilevel data: The advantages of multilevel SEM. Structural Equation Modeling, 18, 161 182. The syntax was adapted from: http://www.quantpsy.org/pubs/syntax_appendix_081311.pdf 

Tom Carwell posted on Wednesday, February 06, 2013  11:19 am



Hi, first of all the forum is a great learning platform, thank you for managing it. After reading the relevant posts, I wanted to ask your input on Mplus codes I set up for testing two crosslevel interactions. Model A in which a dichotomous level2 variable (high1, low0) moderates the relationship between two level1 continuous variables: USEVARIABLES ARE x y w; WITHIN = x y; BETWEEN = w; Cluster = id; ANALYSIS: TYPE IS COMPLEX TWOLEVEL random; MODEL: %WITHIN%; beta1  y ON x; %BETWEEN%; beta1 ON w; Model B in which a continuous level2 variable moderates the relationship between a level2 continuous variable and level1 continuous variable USEVARIABLES ARE x y w inter; WITHIN = y; BETWEEN = x w; Cluster = id; DEFINE: inter=x*w ANALYSIS: TYPE IS TWOLEVEL random; MODEL: %WITHIN%; %BETWEEN%; y ON x w inter; 


These look correction. In Model B, be certain the variance of y is estimated as the default. Otherwise add it on within. y; 

Tom Carwell posted on Saturday, February 09, 2013  1:06 am



Hi Linda, thanks for time and suggestion. 

Kätlin Peets posted on Thursday, February 14, 2013  10:25 am



Hi, I am conducting a simple slope analysis (following up a crosslevel interaction). I am interested in associations between my individuallevel predictor and dependent at high and low values of the classroomlevel covariate (when pbur_1 is one standard deviation below and above the mean; or at .032 and at .032). Is this syntax (Model constraint part) correct? %within% s1pder_1 on affemp; %between% s1 ON pbur_1(gam1); [s1] (gam0); s1 with pder_1; MODEL CONSTRAINT: New (ylow yhigh); ylow = (gam0+gam1*(.032)); yhigh = (gam0+gam1*.032); 


I think this is correct as long as pbur_1 is centered with mean zero. 


Hello, I am trying to estimate a multilevel CACE model. We have students nested within schools. The schools were randomly assigned to receive an intervention and some students complied (i.e., attended) the intervention. My CACE model was working fine, but now I am trying to add a crosslevel interaction between the intervention (at level two) and a student characteristic (i.e., Spanish at level one). When I do that using the syntax below, I get the message "Fatal error: Internal code GH1002." Do you have any suggestions? Cluster = sid; Classes = c(2); Training = c1c2; Within = Spanish FRL Latino Other logabs pretest p6 recip shexp1 shexp2 shexp3; Between = FAST D1 D2 D3 B1 S1 S2 Cohort1; Analysis: Type = twolevel random mixture; miterations = 200; Model: %within% %overall% pscale on Spanish FRL Latino Other logabs pretest; c#1 on Spanish FRL Latino Other logabs pretest p6 recip shexp1 shexp2 shexp3; s  pscale on Spanish; %between% %overall% pscale on FAST D1 D2 D3 B1 S1 S2 Cohort1; s on FAST; %c#1% pscale on FAST; %c#2% pscale on FAST@0; 


Please send your output and license number to support@statmodel.com. 


Dear Muthen, We are trying to estimate a model with a level 2 outcome variable (pub) and two crosslevel interactions (gender x motiv & goalcom x restime) We have used the syntax below. DEFINE: CENTER gender goalcom pub (GRANDMEAN); ANALYSIS: TYPE = TWOLEVEL RANDOM; ESTIMATOR = ML; ALGORITHM = INTEGRATION; MODEL: %WITHIN% s1  restime ON motiv; %BETWEEN% s1 ON gender; s2  pub ON restime; s2 ON goalcom; This resulted in the following warning: *** WARNING in MODEL command In the MODEL command, the following variable is an xvariable on the BETWEEN level and a yvariable on the WITHIN level. This variable will be treated as a yvariable on both levels: RESTIME *** ERROR in MODEL command Observed variable on the righthand side of a betweenlevel ON statement for a random slope must be a BETWEEN variable. Problem with: RESTIME Is there a way to model this model? Thank you 


The two random regressions should be on the within level not the between level. Why do you have s2  pub ON restime; on between? 


Dear Linda, Thank you for your response. pub is a between level outcome, that's why we defined it on the between level. Gender and goalcom are also on the between level. 


T think what you want is: WITHIN = RESTIME; BETWEEN = gender clusrest goalcom inter; MODEL: %WITHIN% s1  restime ON motiv; %BETWEEN% s1 ON gender; pub ON clusrest goalcom inter; where clusrest is a cluster level observed variable that you create in DEFINE along with the interaction between that variable and goalcom (inter). 


Thank you for your response. I've made the adjustments, but I still get an error. My input looks like this: WITHIN = motiv restime; BETWEEN = gender clusrest goalcom pub inter; CLUSTER = employee; MISSING ARE ALL (999); DEFINE: CENTER gender goalcom pub (GRANDMEAN); ANALYSIS: TYPE = TWOLEVEL RANDOM; ESTIMATOR = ML; ALGORITHM = INTEGRATION; MODEL: %WITHIN% s1  restime ON motiv; %BETWEEN% s1 ON gender; pub ON clusrest inter; And this is the error I get: *** WARNING in MODEL command Variable on the lefthand side of an ON statement in a  statement is a WITHIN variable. The intercept for this variable is not random. Variable: RESTIME *** ERROR One or more betweenlevel variables have variation within a cluster for one or more clusters. Check your data and format statement. Between Cluster ID with variation in this variable Variable (only one cluster ID will be listed) INTER 1 


I think it should be WITHIN = motiv; not restme The inter variable should be the same for each cluster member. All variables on the between list need to be the same for each cluster member. Check you data. 


Thank you for your response. I've checked my data and tried different things. Now I get this error: One or more variables in the data set have no nonmissing values. Check your data and format statement. Continuous Number of Variable Observations Variance PUB 200 19.296 DAY 200 2.010 RESTIME 200 6.476 MOTIV 200 1.241 GENDER 200 0.241 GOALCOM 200 0.498 CLUSREST 200 3.764 **INTER 0 This is what my define statement looks like: DEFINE: clusrest = CLUSTER_MEAN (restime); CENTER gender clusrest goalcom pub inter (GRANDMEAN); inter = goalcom * clusrest; Thank you in advance. 


Please send your input, data, output, and license number to support@statmodel.com. 


Hello, I would like to estimate a twolevel CACE model with a crosslevel interaction between the treatment and a covariate. Since the treatment effect is fixed at zero for noncompliers, I think the crosslevel interaction should also be fixed at zero for noncompliers. I thought the code would be something like this: Model: %within% %overall% pscale on EngLat Other FRL; c#1 on EngLat SpanLat Other FRL pretest p6 recip shexp1 shexp2 shexp3; s  pscale on SpanLat; %between% %overall% pscale on FAST D1 D2 D3 B1 S1 S2 Cohort1; s on FAST; %c#1% pscale on FAST; s on FAST; %c#2% pscale on FAST@0; s on FAST@0; However, I am getting this error command: "*** ERROR in MODEL command Parameters involving betweenlevel variables are not allowed to vary across classes." The model runs fine when I do not include the "s on FAST" commands separately for each compliance class, but then the results show a significant interaction between the treatment and the covariate for noncompliers. Thanks in advance. 


Please send the full output and your license number to support@statmodel.com. 

Dave posted on Thursday, May 16, 2013  9:45 am



I have encountered a situation similar to the one described by Kathryn Modecki posted on Monday, July 23, 2012  12:32 am. I am comparing the following models: %WITHIN% s1  DV on IV; %BETWEEN% DV ON Con1 Con2; S1 ON Mod1 Mod2 Int@0 Con1 Con2; DV with s1; MODEL FIT INFORMATION Free Parameters: 12 Loglikelihood H0 Value  0.154 H0 Scaling Correction Factor  1.5249 And %WITHIN% s1  DV on IV; %BETWEEN% DV ON Con1 Con2; S1 ON Mod1 Mod2 Int Con1 Con2; DV with s1; MODEL FIT INFORMATION Free Parameters: 13 Loglikelihood H0 Value  1.446 H0 Scaling Correction Factor  1.4745 Int is an interaction term created by multiplying Mod1 and Mod2 to create a three way cross level interaction. I believe these models are nested. Int has a significant p value (p = 0.033). When testing these two nested models using 2LL the model with the interaction is not significantly better (chi_sq = 3.66 vs 3.84; p = 0.055). I am wondering if you can provide me with guidance regarding how to interpret this finding. Thanks in advance for your attention. 


It sounds like you are comparing an approximate ztest (which when squared is approx. chi2 with 1 df) pvalue of 0.033 with an approximate chi2 test with 1 df with a pvalue of 0.055. Such a small pvalue difference can be expected, particularly in samples that are not large, in this case the number of clusters. You have two methods giving asymptotic approximations to chi2 and for any given sample size they can differ. 


Hi Linda: I ran a multilevel model to test some crosslevel interactions. Now, I am interested in plotting those effects using Preacher's website. I was not very sure if I was inputting the right numbers in the table. I would greatly appreciate if you could confirm where I should look for the numbers Regression Coefficients (gamma for Intercept, gamma for IV, Gamma for Moderator and gamma for Interaction effect)? Coefficient Variances? Coefficient Covariances? Conditional Values for w and x (if I want to model +1SD, mean,1SD values of the moderator)? df (int)? df (slope)? Here is the link to Preacher’s website and I am referring to case 3: http://www.quantpsy.org/interact/hlm2.htm Your help in this matter would be greatly appreciated! Thanks! 


The values you need are found in TECH3. Contact Kris Preacher is you have question about his link. You can also see Example 3.18 in the user's guide which uses the LOOP option. This can be applied to crosslevel interactions. 


Hi Linda: Thanks a ton for your response. I am sorry for the tardy reply. I was under the impression that I will get an email notification once you respond to my query, which obviously I did not get. Anyway, I greatly appreciate the help. Thanks again, Praneet 


Responses are given on Mplus Discussion not via email. 

Sara Guediri posted on Monday, September 09, 2013  10:35 am



Hi, I'm testing a crosslevel interaction and depending on whether I grand mean centre the Level 2 moderator or not, I get different results for the intercept of the random slope. This affects the direction of the crosslevel interaction. Should I go with the results when the level 2 moderator is grandmean centred or leave the level 2 variable at its raw score? Many thanks 


You should grand mean center. See the Raudenbush and Bryk book for further information. 


As a follow up to the previously posted question and answer: " kirsten way posted on Friday, October 21, 2011  10:46 pm Hi, I'm trying to plot my significant cross level interaction using preacher's calculator. I've requested TECH3 in the output to get the coefficient covariances, but wanted to ask  how do I ascertain what variables the parameter numbers in the printout refer to? Thankyou! Linda K. Muthen posted on Saturday, October 22, 2011  6:29 am They refer to the parameter numbers in TECH1." Since I have 10 parameters and TECH3 reports 11 in the covariance matrix, should I be looking at the number labels assigned under Beta in TECH1? I thought it odd that the numbering goes 0,2,3,4... and just want to be sure I am looking at the correct number labels. THANK YOU! Johnna 


Please send your output to Support so we can see what you are referring to. Note also that you no longer need to use the Preacher calculator to plot crosslevel interactions because Mplus offers the LOOP and PLOT options of MODEL CONSTRAINT. See slides 2124 of the Utrecht training August 2012: http://mplus.fss.uu.nl/files/2012/09 V7Part1.pdf 


Bengt  Thank you. I just sent my output. I could not find the slides or presentation you suggested. It says file not found. Would you mind checking the link and resending? I'd appreciate it. Regards, Johnna 


Perhaps you didn't get both lines of the link? http://mplus.fss.uu.nl/files/2012/09 V7Part1.pdf 


Dear Bengt & Linda, Below is a crosslevel interaction I am testing in a multilevel latent SEM model: Within = x1 x2 x3; Between = m1 m2 m3 w1 w2 w3; ANALYSIS: Type is random twolevel; ESTIMATOR = ML; ALGORITHM=INTEGRATION; MODEL: %WITHIN% F1 by y1 y2 y3; F2 by x1 x2 x3; s  F1 ON F2; %BETWEEN% F3 by m1 m2 m3; F4 by w1 w2 w3; s ON F3; F1 ON F4; The above model works but only without the very last statement "F1 ON F4" because F1 has been defined as withinlevel. I need this statement to control for the effect of a betweenlevel variable to a withinlevel variable. In path analysis I am able to work around this problem but not in a latent model. What could I do? Thanks! Paris 


You must create a factor on between that uses the between part of y1, y2, and y3. MODEL: %WITHIN% wF1 by y1 y2 y3; F2 by x1 x2 x3; s  F1 ON F2; %BETWEEN% bF1 by y1 y2 y3; F3 by m1 m2 m3; F4 by w1 w2 w3; s ON F3; bF1 ON F4; 


Dear Linda, Thank you! I am wondering if the statement "s  F1 ON F2" is a full test of moderation. Normally in moderation you also need the main effect of the moderator on the outcome, e.g., "bF1 ON F3". Should I include this statement or is it accounted for by the statement "s  F1 ON F2"? Also, how do I plot this interaction? 


s  F1 ON F2 defines a random slope. I'm not sure how you see this as moderation. 

Ewan Carr posted on Monday, March 03, 2014  1:44 pm



Dear Bengt/Linda, I'm following up on a question from two years ago. I have a multilevel path model, with a crosslevel interaction (implemented as a random slope). Mplus doesn't currently offer overall model fit statistics for multilevel SEM models (e.g. DIC). To test the significance of the crosslevel interaction, I asked:
quote:How can I test the significance of the interaction? (beyond just looking at the pvalue or credible intervals)
The response I got was:
quote:3. The CI for s on w would seem to be the best way. (Bengt, 20120627 2054)
Is there any reference/citation you could suggest that would either support this decision, or where a similar approach is taken? (A reviewer is asking for a measure of overall model fit; I'm trying to argue that this approach  of looking at the credible intervals  is adequate). Many thanks, Ewan  


In this situation, no absolute fit statistics are available. There is not a single covariance matrix because the variance of y varies as a function of x. This is not something specific to Mplus. The confidence interval gives the same result as a one degree of freedom chisquare difference test between a model without the interaction term and a model with the interaction term. 

Ewan Carr posted on Saturday, March 08, 2014  10:46 am



Many thanks, that is most useful. Ewan 


Dear Bengt & Linda, I am attempting to write syntax for a multilevel structural equation model with several crosslevel interactions. The relationship of interest is between 7 indicators for race/gender (e.g., White Female, Black Male, Black Female, etc) and a continuous latent variable. This relationship is defined by partially mediated moderation by grouplevel variables where B1 moderates these relationships and B2 partially mediates this moderation. Given that I would need 7 random slopes to specify the crosslevel interactions as typically defined in Mplus (and that from my understanding, modeling several random slopes can get quite hairy), I would like to estimate this model with a random intercept only (and no random slopes). Can I create cross products between my 7 indicators and B1 for use in such a model instead of utilizing random slopes? Thank you for any help! Briana 


Yes. 

C G posted on Tuesday, September 16, 2014  1:20 pm



Dear Dr. Muthen I am using Mplus to do multilevel path analyses. I want to test the interaction results from a cross level prediction of a level 1 random effect by a level 2 covariate. When I interpret and plot the results, I am not sure which mean score to use as there are two sorts of mean scores, one at the within level and another at the between level. Any help will be highly appreciated. Thank you very much. 


Have a look at the crosslevel interaction plot information at http://www.statmodel.com/Mediation.shtml 


Hi, what does "ERROR in VARIABLE command Unknown modifier in the BETWEEN option: LEVEL2" mean? 


It sounds like you are using level2 instead of the name of your level 2 cluster variable. If not, please send the output and your license number to support@statmodel.com. 


Dear Linda: Thank you kindly for your response. I have forwarded my files to the address given. Regards, Ansylla 


Good afternoon, I am running a twolevel path analysis in MPlus and would like to model a crosslevel interaction where the IV is at the group level, the dv is at the individual level and the moderator is at the group level. I have identified the IV and moderator as between subject effects. It is also my understanding that I can use the define command to create the interaction variable: Define: int = IV*moderator; Where I am having difficulty is creating the syntax for the within and between effects. In other words, do I include syntax on the within and between effects? Where would the following command appear? int on IV; Any help you could provide is greatly appreciated. 


See Example 9.2. You must have a random slope to have a crosslevel interaction. See also Slide 45 of the Topic 7 course handout on the website. This shows the formulas. 


Thanks Linda. I have modeled it that way am getting the following error message: "Betweenlevel variables cannot be used in random slope definitions on the within level. " My IV and moderator are at the between level, and my DV is at the within level. As such, I believe I have to use my betweenlevel DV on the within level syntax. The syntax I am using is as follows: MODEL: %WITHIN% RSLOPE  Y ON X; %BETWEEN% Y RSLOPE ON X; Y WITH RSLOPE; Thanks so much. 


You cannot use between variables in the within part of the model. Read Examples 9.1 and 9.2 and see Slide 45 of Topic 7. 

Briana Chang posted on Thursday, October 23, 2014  11:10 am



Hello Linda and Bengt, I wrote several months back about using crosslevel interaction terms instead of using random slopes (4/16/2014, http://www.statmodel.com/cgibin/discus/show.cgi?12/788) and have a follow up question. I am interested in running a multilevel path model with mediated moderation. I am attempting to run an interceptsasoutcomes model so I am using interaction terms to avoid random slopes. The basic idea is this: X affects Y (both variables are Level 1 variables, X is dichotomous, Y is continuous) A (a Level 2 continuous variable) moderates the effect of X on Y, and this moderation is partially mediated through B (a Level 2 continuous variable). My interaction term is AX so that the interaction is a crosslevel interaction. From my understanding, I must run the following in the MODEL command: %WITHIN% Y on X Y on AX X with AX %BETWEEN% Y on A Y on B B on A AX X A with AX X with A Is this correct? My concern is specifying relationships on the between level that involve Level 1 covariates. 


I would think you want to say %WITHIN% Y on X Y on AX %BETWEEN% Y on A Y on B B on A Your within statement X with AX is not needed because X and AX are covariates. Are your between statements B on AX X because you want to use the AX and X latent between parts on between? 


In your correction, I understand where the moderation comes in with the inclusion of: %WITHIN% Y on X Y on AX %BETWEEN% Y on A But I am missing where this moderation effect is mediated by B. This was why I had included the statement "B on AX". And since I suppose is possible that the X>Y effect is also mediated by B, I included "B on X". Does that make sense? I can see from elsewhere on the discussion board that "level2 random intercept part of an individual's variable predicts the level2 variable" but I'm not sure what this would mean for the syntax. Thanks for any help! 


You can't have "B on AX" on between because the interaction variable AX varies across subjects so it is not a Betweenlevel variable. It seems you need to use a random slope approach instead, like Within s  y on x; Between s on b; b on a; plus y on a b; Then the A moderation of the effect of x on y is mediated by B. 


Hi Can you tell me what this error message mean and how do I treat with it? *** ERROR One or more betweenlevel variables have variation within a cluster for one or more clusters. Check your data and format statement. Between Cluster ID with variation in this variable Variable (only one cluster ID will be listed) EI3 41 


Variables on the BETWEEN list must contain the same value for each cluster member. This message indicate that this has been violated. This happens for variables EI3 in cluster 41. 


But I don't quite understand this? Way back at the data entry stage if there were members of the group who no longer participated in the study at T3 then no values were entered (not even corresponding between level data)... .so for example if the group went from 5 to 2 then EI values were only entered for the 2 remaining individual level participants ...... should i have entered the corresponding between level data for the three who no longer participated? 


If a person is in the data set, they should be assigned the same value for variables measured at the cluster level as all other cluster members. 


Dear All, Often I have to test crosslevel interactions in complex models in which it has been suggested to create latent variables to form the interaction term (XL by XL@1;XL@0). I was therefore expecting the following approaches to test a crosslevel interaction to held similar results, but this is not the case. Am I wrong to assume this should be similar? When is it appropriate then to create a latent variable on subsequently create an interaction term. Many thanks for any clarification! MODEL 1 Cluster = team; between = L2M ; within = ; Analysis: Type = twolevel random; Estimator = ml; Model: %Within% SL1Y ON L1X %Between% L1Y ON L1X L2M; S ON L2M; MODEL 2 Cluster = team; between = L2M ; within = ; Analysis: Type = two level random; Estimator = ml; algorithm = integration; Model: %Within% L1Y ON L1X; %Between% L1X_b by L1X@1; L1X@0; INT  L1X_b xwith L2M; L1Y ON L1X_b L2M; L1Y ON INT; 


In Model 1 the random slope causes an interaction between L2M and the withinlevel part of L1X. In Model 2 you have instead an interaction between L2M and the betweenlevel part of L1X. 


Thank you very much, this is now clear. So I assume that the correct option will depend on the theoretical assumptions. Should I want to test the interaction regarding both the within and the between parts should I then integrate both approaches? Thank you, Claudia 


Right on both. 


Hi, I am running a crosslevel interaction model (IV: FSSB and DV: WFBI at the 1st level, W:agCFam at the 2nd level) with control variables (ageI1 sexI1 full). Why do I get different findings for s on agCFam when I run the two models below and which one is the correct approach?Model 1 and 2 should only differ in regards to the plotting? Also, if I define the interaction via define and regress s on it in the between, I get p = .445. If I center according to a hybrid approach (Aguinis & Culpepper, 2015; Preache et al.,2010), I get totally different significant findings for all of the first two models, and p =.951 for the define command model. Also, is it okay to only have the controls at the within? Because if I add them to the between they would function as moderators. Thanks, Kristin 1. Handbook 9.2 Part 1 (s on agCFam = p = .127) within = FSSB sexI1 ageI1 full; between = agCFam agFSSB; Define: Center FSSB (grandmean); ANALYSIS: type = twolevel random; Model: %within% s WFBI on FSSB sexI1 ageI1; %between% WFBI s on agCFam agFSSB; WFBI WITH s; 2. Handbook 9.2 Part 2 (s on agCFam = p = .100) Model: %within% s WFBI on FSSB sexI1 ageI1 full; %between% WFBI on agCFam agFSSB; [s] (gam0); s on agCFam (gam1); agFSSB; WFBI WITH s; 


The first part of my models, if centered according to the hybrid approach, looks like this: usevar = teamM WFBI FSSB agFSSB agCFam sexI1 ageI1 full; cluster = teamM; within = FSSB sexI1 ageI1 full; between = agCFam agFSSB; Define: Center agCFam agFSSB (grandmean); Center FSSB sexI1 ageI1 full (groupmean); p = .000, p = .001 and p =.951 respectively for s on agCFam for the first, second and define model. Sorry for my limited knowledge, I am not a mathematician. 


In your first step you say s on agCFam agFSSB; while in your second setup you say s on agCFam (gam1); agFSSB; In other words, you have only 1 predictor in the second setup, not 2. We ask that no more than one window is used for postings. 

Amelie G posted on Wednesday, August 12, 2015  2:36 pm



Hi Linda & Ben: I have analyzed a twolevel model with a predictor x, a meditator m and 2 outcomes y & z in a team sample. I argued that the relationships occur at both the individual and the team level. As all variables were assessed by asking individuals (L1), I acknowledge Preacher, Zhang & Zhypur, 2010, stating that variables assessed at L1 typically have both L2 and L1 components. They further state that for such cases the L2 component is necessarily uncorrelated with the L1 component of that variable and the L1 components of all other variables in the model. Therefore, I calculated the 111 model, splitting each variable's variance into L1 and L2 components and calculated the relationship between the L1 component of x and the L1 component of m, y and z and the relationship between the L2 component of x and the L2 components of m, y and z. Am I right up to this point? Anyway, in the opinion of the editors from my target journal, x should only be modeled at L2, while m, y, and z should be modeled at both levels. I am asked to report the crosslevel interactions between my variables. As this is not the first time that I have been asked to do that, I am wondering if I misunderstood something? Is there a way to neglect the L1component of x and model only the relationship between the L2component of x and the L1 and L2 components of m, y and z? If so, could you help me on how I'd have to change my input? Thank you so much in advance! 

Amelie G posted on Wednesday, August 12, 2015  2:37 pm



This is my current input("_g" refers to the aggregated values): within = x m ; between = x_g m_g ; cluster = TEAM; analysis: TYPE=TWOLEVEL RANDOM; define: center x m (groupmean); model: %within% m on x (aw) ; y on m (bw) x ; z on m (b1w) x ; [m@0]; %between% m_g y z ; m_g on x_g (a) ; y on m_g (b) x_g; z on m_g (b1) x_g ; model constraint: new (indb indb1 indw indw1); indb = a*b; indb1 = a*b1; indw = aw*bw; indw1 = aw*b1w; 


What does x represent and why do they want it on between? Crosslevel interactions occur when you have random slopes and that gives rise to a special mediation formula. But random slopes are rare  you can look for one at a time if you like (using s  y on m, for example). 


Hello, can you do a cross level interaction with a latent contextual variable? If so I am not sure how to code. This is wrong, but something like: % within s1 y on x (gamma01); % between y on x (gamma10); s1 on x; Model constraint: NEW(betac*); betac = gamma01  gamma10; or would you code the interaction the same way as the latent contextual variable: % within y on x (gamma01); y on x (gamma02); % between y on x (gamma10); y on x (gamma20); Model constraint: NEW(betac* betac1); betac = gamma01  gamma10; betac1 = gamma02  gamma20; Thank you for your guidance. I just discovered Lüdtke, et al., (2008), and would very much like to utilize this approach. 


You can use a latent variable in a crosslevel interaction, for example, MODEL: f BY y1y4; ! latent variable s  f ON x; ! crosslevel interaction 


Thanks for your response. I don't think my last post was not very clear. I have a variable representing individual selfregulation, and want to look at its relationship to a literacy indicator. I also want to look at class selfregulation as a predictor of early literacy. My class selfregulation variable would be an aggregate of the individual selfreg. variable. I used example 9.2 to do this by making my selfreg variable a latent contextual variable. Now, I was wondering if there is any way I can look at the interaction of latent level 2 (class) selfreg with individual selfreg to evaluate whether class selfreg affects individuals with different selfreg scores the same way. Thanks again for all of the help. 

Amelie G posted on Monday, August 17, 2015  10:23 am



Hi Ben, thank you so much for your answer! x represents leadership behavior and its effects on employee reactions are analyzed. As x was assessed at L1 (team member ratings), am I right that it would be wrong to only take the aggregated value of x into account? Moreover, as we also aim to analyze individual reactions to that leadership behavior, I was sure that the 111 model was the correct one. Do you agree or am I missing something? If however, I follow the editor's wish and neglect the individual variance in x, would the 211 model be the model of choice? And in that case  am I right that then no Level 1 mediation effect would or could be modeled? Are there any other solutions to follow the editor's wish to have x only at L2 while still analyzing its effects on both L1 and L2 variables? Thanks so much in advance! 


It's hard for me to say without sinking into the research setting. If you want x>m>y on level 1 you must be thinking that an individual's rating of his/her team leader influences m, y on level 1. It would be fine to not have a mediation model on level 1. Even if you don't have a mediation model on level 1 you can estimate the level 1 variance of x. That is, you can do the Mplus latent variable decomposition of x so that x on between is the latent, more reliable, between part of x. The advantage of that is described in the paper on our website: Lüdtke, O., Marsh, H.W., Robitzsch, A., Trautwein, U., Asparouhov, T., & Muthén, B. (2008). The multilevel latent covariate model: A new, more reliable approach to grouplevel effects in contextual studies. Psychological Methods, 13, 203229. download paper contact first author show abstract 

Bep Uink posted on Wednesday, August 19, 2015  9:06 pm



Hello, I have collected ESM data of mood and events (repeated measures nested within person).I have modeled the regression of mood at T+1 on event at T =0. I created a moodT+1 variable on SPPS using SHIFT VALUES command on SPSS which essentially drops each line of data down by one row. Am I correct in assuming that the original mood variable (mood at t = 0) can be used as level 1 covariate to control for the effects of mood at t = 0. OR does MPLUS aggregate this variable over cluster? Many thanks. 


Mplus doesn't aggregate a variable unless you ask for it. Regarding the general analysis strategy question you may want to ask this on SEMNET. 

Cynthia Yuen posted on Saturday, September 05, 2015  7:16 pm



Hello, I have a couple of multilevel questions that I'm a bit stuck on. First, I'm trying to run a crosslevel model with latent variables but I keep getting the following error: THE LOGLIKELIHOOD DECREASED IN THE LAST EM ITERATION. CHANGE YOUR MODEL, STARTING VALUES AND/OR THE NUMBER OF INTEGRATION POINTS. THE MODEL ESTIMATION DID NOT TERMINATE NORMALLY DUE TO AN ERROR IN THE COMPUTATION. CHANGE YOUR MODEL AND/OR STARTING VALUES. When I run the model with only a fixed slope (just defining factors A and B in the within model command, then specifying A ON B), the model will converge fine. However, if I allow the slope to be random (b1  A ON B in the within command), I get this error. Do you know what might be going wrong? Second, is there a way to groupmean center a latent? Last, I have a basic question. What is the difference between a model where I put all Level 1 variables in the Variable: Within = section vs. one where I don't? For example: VARIABLE: ... Within = DV1DV4 IV1IV4; Between =; MODEL: %Within% DV BY DV1DV4; IV BY IV1IV4; b1  IV ON DV; ... vs. VARIABLE: ... Within = IV1IV4; Between =; MODEL: %Within% DV BY DV1DV4; IV BY IV1IV4; b1  IV ON DV; Thank you very much! ... 


1. The effect may not be random. Loot at the variances in the partial results. Or you may need more integration points. 2. This cannot be done. The means of latent variables are most often zero. 3. If you put variables on the WITHIN list, there is no variability on between. If you don't, there is. 

Cynthia Yuen posted on Tuesday, September 08, 2015  4:42 pm



Thanks much for the speedy response! I wasn't completely sure what partial results referred to but the model results following the error I pasted in my original message says that the variance of b1 is 28.387. However, I have no idea what metric I should be comparing that against and whether this is meaningful. If it helps at all, when I run the model with the latents as an observed average of their indicators, the variance of the path is highly significant. I'm also extremely new to crosslevel models, especially with latents, so would it be possible for you to explain what integration parts are/do or direct me to a source where I could get a better basic understanding? Thank you! 


Please send your output, data, and license number to support so we can see what's going on. 

Jasmin Jin posted on Monday, October 12, 2015  5:56 am



Hello, I think my problem is related on this board. So I'm posting questions. My model is a multilevel SEM(2level). I also want to research crosslevel effects. I read chapter 9 in user¡¯s guide and make the following code but it has errors. I appreciate your checking. VARIABLE: NAMES ARE hw01hw07 a01a08 SLS achi01achi05 t_clus; USEVARIABLES ARE hw03hw07 a05a08 SLS achi01achi05 t_clus; BETWEEN = hw03hw07 a05a08; CLUSTER = t_clus; ANALYSIS: TYPE = TWOLEVEL RANDOM; ALGORITHM = INTEGRATION; INTEGRATION = 10; MODEL: %WITHIN% s1  achi01achi05 ON SLS; %BETWEEN% t_hw by hw03hw07; t_as by a05a08; s_SLS by SLS; SLS@0; achi01achi05 s1 s_SLS ON t_hw t_as; *** WARNING in MODEL command In the MODEL command, the following variable is a yvariable on the BETWEEN level and an xvariable on the WITHIN level. This variable will be treated as a yvariable on both levels: SLS 1 WARNING(S) FOUND IN THE INPUT INSTRUCTIONS 


This is an informational warning not an error. You analysis should have gone on. 

Jasmin Jin posted on Monday, October 12, 2015  3:34 pm



Dear Ms. Muthen Thank you for quick answering. I have more questions. There is only estimates in the output  no model fit information, s.e. and pvalue. Do you mind if I ask you the reason? 


It sounds like the model did not converge. Please send the output and your license number to support@statmodel.com. 


Dear Linda/Bengt, I am conducting a crosslevel interaction analysis with the following variables:  Level1 independent variable (observed variable) = IV (age)  Level2 dependent variable (observed variable) = DV (work unit absenteeism)  Level2 moderator (latent variable) = M1M5 (team climate items loading on the level2 moderator) Could you please tell me if the following syntax is correct? USEVARIABLES ARE IV DV M1 M2 M3 M4 M5 prov; CLUSTER IS prov; BETWEEN ARE M DV; ANALYSIS: TYPE IS TWOLEVEL RANDOM; ALGORITHM=INTEGRATION; INTEGRATION = MONTECARLO; MODEL: %BETWEEN% M BY M1 M2 M3 M4 M5; IVb by IV; IV@0; DV ON M IVb; beta1  DV ON IVb; beta1(gam0); beta1 ON M (gam1); MODEL CONSTRAINT: New (ylow yhigh); ylow = (gam0+gam1*(1.89)); yhigh = (gam0+gam1*1.89); OUTPUT: STDYX TECH1 TECH3 TECH8 CINTERVAL; Thanks a lot in advance, Francesco 


Looks like you are doing twolevel to get a latent variable decomposition of your IV. Make sure you get its variance estimated on Within as well. But you cannot use a random slope construction on Between. It has to be defined on a level below the highest. 


Dear Bengt, Thank you so much for your kind and helpful reply. Concerning your second point, however, I was wondering how I can construct the random slope at the level below the highest, when my DV can only be defined at the betweenlevel.. Could you please give me an idea of how to adddress this issue in my syntax? Thanks a lot in advance. 


It isn't possible in Mplus, or other multilevel programs, to have a random slope vary on its own level so to speak. Your random slope refers to a Level2 relationship so you would need a third level across which units this slope varies. An exception in Mplus is UG ex 3.9, which has a singlelevel model with a random slope. But that is a special kind of heteroscedasticity modeling that I have not seen carried out in a multilevel setting. 


I have two variables that vary at both the within and between level. I would like to form a withinlevel observed interaction term from these variables, and then examine both the within and between variance of this interaction term as predictors of an outcome. Is the following syntax correct, or would the specification be more complex? %WITHIN% y on x z x*z; %BETWEEN% y on x z x*z; Thank you for your help! 


For observed variables, an interaction term is created using the DEFINE command, for example, DEFINE: xz = x*z; Then put xz at the end of the USEVARIABLES list and use it in the MODEL command. 

anonymous Z posted on Friday, February 12, 2016  7:59 am



Dear Drs. Muthen, I am fitting a twopart model by using a multilevel approach to model longitudinal trajectory. “AL” is my outcome variable across five time points. X is a time varying covariate across five time points. TX is treatment status. I want to create a crosslevel interaction between baseline value of X and TX (i.e., TX * baseline value of X), and see how TX*baseline value of X influences time slope. I have a couple of questions: 1. How to specify the baseline value of X? 2. How should I create the interaction term? 3. Should I put the interaction term in the place of “between” or “within” Thanks so much! DATA TWOPART: NAMES = AL; BINARY = binAL; CONTINUOUS = contAL; VARIABLE: NAMES ARE ID TX time X AL; USEVARIABLES ARE ID TX binAL contAL; CATEGORICAL ARE binAL; MISSING = ALL (999999); cluster = ID; within = time X; Between = TX; Analysis: type = twolevel random; MODEL: %within% S1 BinAL on time; BinAL ON X; S2 ContAL on time; ContAL ON X; %between% BinAL ON TX; S1 ON TX; BinAL with S1; ContAL ON TX; S2 ON TX; ContAL WITH S2; 


1.You just have a column in your data with a baseline value that is the same across the time points for an individual. 2.Use Define to create TX*Base and declare that as a Between variable since Between refers to subject. 3. Between 

Selin Kudret posted on Thursday, February 25, 2016  7:49 am



Dear Linda and Bengt On a crosslevel interaction plot produced by MPlus, I would like to swap the L1 predictor and L2 moderator, so that I would see and interpret the alternative symmetrical result of the L1 variable being the moderator and L2 variable being the predictor. I was wondering how I could ask the crosslevel interaction plot in this way. Many thanks and best wishes 


What is your Within model in this case? See also http://www.statmodel.com/download/Crosslevel%20effect%20plotted%20by%20LOOP.pdf 


Dear Bengt My model is as follows. In this code, the plot command produces an interaction plot wherein L1x is the predictor, L2w the moderator, and y the outcome. My aim is to get a plot wherein L2w is the predictor and L1x is the moderator. I've been using a different plot command than the one you shared with the link. As you suggested, I also tried the PLOT (crosslvl) command and don't seem to be able to swap L2w for L1x. It seems to me that crosslvl and mod are labels  crosslvl indicating the outcome y and mod referring to moderator L2w. Hence, simply replacing the mod label doesn't seem to produce a symmetrical interaction plot. Many thanks for your help, best wishes. MODEL: %WITHIN% S  y ON L1x; %BETWEEN% y ON L2w; y WITH S; S; [S] (b0); S ON L2w (b1); MODEL CONSTRAINT: PLOT(LOMOD HIMOD); LOOP(XAXIS,3,3,0.1); LOMOD = (b0 + b1*1)*XAXIS; HIMOD = (b0 + b1*5)*XAXIS; PLOT: TYPE = plot2; 


In your code L2w is a betweenlevel variable and L1x is a withinlevel variable. So L2w can't take the role of L1x on Within and L1x can't take the role of L2x on Between. But maybe I am misunderstanding you. 


Dear Bengt Many thanks; you understand my point correctly. In fact, what I am trying to do features in the Aguinis, Gottfredson, and Culpepper paper (p.1514): "..can we say that the L2 variable moderates the effect of the L1 predictor on the L1 criterion and, also, that the L1 predictor moderates the effect of the L2 predictor on the L1 criterion? From a statistical standpoint, it is just as appropriate to label the L2 predictor as the moderator of the effect of the L1 predictor X on the L1 outcome Y as it is to label the L1 predictor X as the moderator of the effect of the L2 predictor W on the L1 outcome Y because crosslevel interactions are symmetrical." I'd like to plot the crosslevel interaction in the way I described because of conceptual reasons. My crosslevel hypothesis makes much more sense with L1x as the moderator. The way we set up crosslevel interactions in MPlus, i.e. creating the latent variable S to represent a within relationship and explaining it by a between variable, lends itself into a plot where we always have the L2 variable as the moderator. Hence, the symmetrical version is likely to require an alternative setup of the crosslevel interaction in the model command, which I was not able to figure out. If that's somehow possible in MPlus, I would appreciate your help. Many thanks for your time, best wishes. 


You can do it this way I think. Drop the random slope. Create a cluster mean variable for L1X, say L1XM declared as a between variable. Then on Between drop all the random slope references and instead have only y ON L1XM L2W Inter; where Inter is created in Define as L2W*L1XM. 


Hello! I wanted to ask: Is it possible to create a crosslevel interaction term from 2 latent variables (one on the betweenlevel and one on the withinin)? It seems when discussing the crosslevel interactions most people are either discussing observed variables on either level or perhaps only one latent variable and one observed. My apologies if the answer was in this forum and I couldn't find it (or if it involves something obvious that I should already know). Thank you in advance! 


The variable involved in a crosslevel interaction can be observed or latent. Follow Example 9.2 but use latent variables. 


Hi, I'm having a little trouble understanding crosslevel interactions. I'm interested in a random intercepts model where a familylevel covariate interacts with a individuallevel covariate and I'm specifically interested in whether the interaction between the covariates explains variance across individuals (not families) in my DV. All variables are observed. It seems like the approach recommended here is using syntax such as: CLUSTER = clus; ANALYSIS: TYPE = TWOLEVEL; MODEL: %WITHIN% S  y ON x; %BETWEEN% S ON w; I'm wondering how that syntax is interpreted differently than if I created an interaction term using DEFINE for x and w, and then used the following syntax: CLUSTER = clus; ANALYSIS: TYPE = TWOLEVEL; MODEL: %WITHIN% y on x; y on xw; %BETWEEN% y ON w; Thanks, 


The second alternative is fine but doesn't allow the residual that you have in s ON w in the first alternative. 


Slide 45 of the Topic 7 course handout on the website shows the formulas related to you first syntax. This is the correct sytax for crosslevel interactions. The second syntax is not allowed if x is on the WITHIN list and w is on the BETWEEN list. 


Hello, I am fitting multilevel SEM, since I have egoalter data. Ego is the individual, who has rated up to 5 alters. I would like to add moderated mediation, where the mediation is within (111) and the moderator is between. But I would like to moderate the first part of mediation so if my mediation is x (a friend is international or not) mediator (frequency of socialization) y1 (work support) y2 (emotional support) moderator (ego's ability to speak foreign language) What do I do? Does this seem reasonable? Within= x; Between= moderator; MISSING ARE ALL (9999); CLUSTER IS nid; DEFINE: Center x moderator (grandmean); ANALYSIS: TYPE IS TWOLEVEL RANDOM; Model: %BETWEEN% S on moderator; %WITHIN% y1 on mediator; y2 on mediator; S  mediator on x; Does that sound reasonable? What if I would like to add the y1 and y2 on the between level, would Sthe random slope have to be a predictor of y1 and y2 on the between level? Thank you Annamaria 


Q1. Yes. Q2. Perhaps just correlated. 


Dear Linda and Bengt, We are having trouble finding syntax for a crosslevel interaction that fits our specific model. Our predictor (X) is a L2 variable (classroom quality), our outcome (Y) is a L1 variable (child outcome), and our moderator (M) is a L1 variable (child initial skills). We also had a question about whether it was important for us to grand or groupmean center our variables. Any advice you have on centering and syntax for a crosslevel interaction where the moderator and outcome are L1 and the predictor is L2, would be greatly appreciated! All the best, Jenna 


In the Variable command, say Between = x; Within = m; and in the Model command, say: %within% s  y on m; %between% y s on x; This creates an interaction effect from m*x. Regarding centering, see the Topic 7 handout from our short courses on our website, slides 3143. 


I have a followup question to Selin Kudret's Feb 26 post and Bengt's answer. What if my L1 moderator is binary rather than continuous? In that case it doesn't seem to make sense to compute a cluster mean variable. Any help would be appreciated. 


The cluster mean will then be a proportion which is perfectly fine for capturing a between effect. 


Hi! I have a 2122 model, with the 12 path moderated by another Level 2 variable. In order, my L2 variables are Cond, PC, and IS. My L1 variable is AS, and the L2 moderator is PFB. While I'm able to write the syntax for the basic 2122 model, I'm unable to figure out the crosslevel interaction that has a Level 2 dependent variable. Am I correct in creating the interaction term between the Level 1 and Level 2 variables (Int = AS * PFB) in the dataset, and then using this term as the variable to predict the L2 variable? Here's the syntax I have thus far: CLUSTER = Team; MISSING = all(999.00); USEVARIABLES = Cond AS PFB Int PC IS ; BETWEEN = Cond ; ANALYSIS: TYPE IS TWOLEVEL RANDOM; MODEL: %within% AS; %between% AS ON Cond; PC ON AS; PC ON Int; PC ON PFB; PC ON Cond; IS on PC; Thank you very much, and Happy New Year! 


Create the interaction using the cluster mean for AS so that it is a Level2 variable. 


That makes sense – thank you! 


Hi, I would like to test whether the relation between a level1 x variable (gender) and a level1 yvariable (individual's motivation) is moderated by a level2 m variable (context variable). In example no. 9.2 of the user guide, the y variable is decomposed and also modelled at level 2. However, I am not sure whether this syntax applies to my research question as I am interested in the relationship between two level1 variables and whether it is moderated by a level2 moderator. Would this syntax be correct for my research question? within= x y; between= m; %within% slopey on x; %between% slope on m; Or do I need to exclude y from the "within =" part? Thank you very much for your help. 


You should not put y on the within list if it is used for a random slope. See slide 45 of the Topic 7 course handout on the website to see the formulas for this specification. 


According to example 9.8 in the user's guide I now modelled within= x; between= m1 m2 m3; %within% Wfy by y1 y2 y3; slopeWfy on x; %between% fm by m1 m2 m3; Bfy by y1 y2 y3; y1y3@0; slope on fm; However, I still get an error message. THE MODEL ESTIMATION DID NOT TERMINATE NORMALLY DUE TO A CHANGE IN THE LOGLIKELIHOOD DURING THE LAST E STEP. AN INSUFFICENT NUMBER OF E STEP ITERATIONS MAY HAVE BEEN USED. INCREASE THE NUMBER OF MITERATIONS OR INCREASE THE MCONVERGENCE VALUE. ESTIMATES CANNOT BE TRUSTED. SLOW CONVERGENCE DUE TO PARAMETER 28. 


sorry, not "still"  I just get an error message. How can I solve this problem? Thank you! 


Please send the output and your license number to support@statmodel.com. 

Back to top 