Message/Author 

Student 09 posted on Saturday, December 27, 2008  3:04 am



Hello I wonder how to correctly compute a contextual effect when using a twolevel SEM with latent factors. Following Raudenbush and Bryk (2002, p. 141), for models with groupmeancentering the contexual effect is computed as beta_between  beta_within. This could straigtforward be applied to a model where one regresses e.g. latent factor Y on latent factor X on both levels, and then computes the differences in the unstandardized beta`s. Would this be correct? If so, how could I test the significance of any difference between these two beta`s? Best Jan 


This topic is a little involved, which has delayed our answer. There has been some work done on this and we are checking if this is ready to be distributed. One key issue which the observed variable case of R&B doesn't face, is that the formula you give would only be relevant if the within and between factor loadings were equal so you are sure you are dealing with the same latent variable on both levels. That equality often does not hold. 

Student 09 posted on Monday, January 05, 2009  9:55 am



Dear Dr. Muthen I would be very grateful if you would notify me once your work is published  if you are aware of any further published research reports in this field (I am not) please let me know Best Jan 

Student 09 posted on Monday, February 16, 2009  2:20 am



Dear Dr. Muthen according to Bryk and Raudenbush (2002, 141), a contexual effect can  besides the grandmeancentred centered approach (e.g. ex9.1a & ex9.1b) also be computed as: b_between  b_within = b_contextual. A potential limitation of this approach is that one gets no information whether the resulting difference is significantly different from zero. To obtain this information apart from the grandmean centered approach, I am curious whether it would be correct to A) constrain the within and betweenregression weights of the variable of interest to equality and then B) compare the fit of a constrained (b_between = b_within) to an unconstrained (b_between /= b_within) model. Then, C) if the fit of the constrained model would not differ from the unconstrained model, I would argue that the contextual effect (b_between  b_within) is not significant. Would this procedure be correct? Thanks Jan 


See page 231 of the Version 5 User's Guide for how to get this significance information using Model Constraint. See also 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. under Papers, Multilevel SEM. 

Student 09 posted on Monday, February 16, 2009  7:42 am



Thanks, I'll check the Ludtke paper. In the meantime, let me ask whether it is correct that the withinslopes must be invariant (=fixed coefficients, variance between groups) for estimating contextual effects? Thanks a lot! 

Student 09 posted on Monday, February 16, 2009  8:22 am



Thanks for the Ludtke et al. reference which, for the time being, clarified my earlier questions. 


The contextual model uses fixed slopes. See the reference our UG gives: Raudenbush & Bryk 2002, p. 140. 

Student 09 posted on Tuesday, February 17, 2009  6:40 am



Hi I am still not clear for which reason grandmeancentering is used in ex9.1b. I noted that deactivating grandmeancentering yields almost identical results, the only difference being that the yintercept with grandmeancentered X is 2.036, but without grandmeancentered X the yintercept is 2.005. From the UG, I understand that in line with the 'group mean example' by R&B (table 5.11, p. 140), in ex.9.1b beta_c is calculated as gamma01  gamma10. For this way of calculating contextual effects R&B do not use grandmean (X..), but groupmean (X.j) centering only. Grandmean centering is used in the right hand example of table 5.11. But because in this second example beta_c is equal to gamma01, this procedure obviously differs from the way contextual effects are estimated in ex9.1.b. That's were my confusion comes from. So at the risk of asking something very obvious or which could be deduced from the Luedtke et al. paper, I would be very grateful if you could give me an answer a) whether and if so, b) for which reason grandmeancentering must be used in ex9.1btypes of analysis? Many thanks for your answer! 


Grandmean centering is not essential for ex9.1b. 

Simon Denny posted on Thursday, August 27, 2009  4:27 pm



I have been looking at the paper by Ludtke et al(2008) as I am running a contextual analysis of school climate. I have a question regarding the paper which is confusing me. On page 207 it states "Thus, y10 is the specific effect of the group mean after controlling for interindividual differences on X." (1st para top of page) Shouldn't this be y01 as the contextual effect? Thanks for your help! 


Oliver Ludtke says it is a typo. "It should be gamma_01 instead of gamma_10." 

Simon Denny posted on Saturday, August 29, 2009  3:38 pm



Thanks Linda, a couple of followup questions. 1. Why in example in 9.1 do you use Centering = grandmean (x) rather groupmean? I take it that it doesn't really matter in a random intercepts only model. But would groupmean be more appropriate as this is how Mplus decomposes the latent variable (pg 231 users guide). 2. Mplus doesn't produce standardized outputs for variables in model constraint. When I subtract gama01 from gamma10 by hand from the output I get the same as the model constraint estimates. Can I do the same for standardized gamma10 and gama01 output to get standardized contextual coefficients? 

Simon Denny posted on Saturday, August 29, 2009  3:48 pm



sorry, just figured out that you can't use GROUPMEAN for variables used in between analyses. But why specify grandmean (x) anyhow? 


The RaudenbushBryk (2002) page 140 Table 5.11 shows two alternatives, group and grandmean centering. As you see there, the grandmean approach gets you the contextual effect directly as the betweenlevel slope. So here you can use the standardized coefficient directly. As an exercise you can see if you get that by standardizing the subtraction in the groupmean centered alternative. 

Simon Denny posted on Sunday, August 30, 2009  2:48 pm



Thanks, that works for the observed covariate groupmean contextual effect. I guess I was meaning for the second part of example 9.1, why specify grandmean centering for the latent covariate model? As described on page 231  the latent variable is decomposed as a latent group mean. Hence the need to transform the within and between slopes as in the MODEL CONSTRAINT command. Is it because Grandmean centering helps the maximum liklihood estimation of the latent group mean? 


I don't think that centering is important. 


Hi, I'm testing a cross level mediation in which a L2 predictor (X) has an effect on a L1 dependent latent variable (Y) via an L1 mediator (m) (it's the type 211). The dependent variable is a 2level latent factor specified by three indicators which factor loadings are constrainted to be equal across the 2 levels. According to Preacher, Zyphur & Zhang (2010), to test the mediation I have to free the variance of the mediator at the to levels. Namely to remove m from the WITHIN list in the VARIABLE specification of my Mplus model. I was wondering if this mean that I need also to control for the contextual effect of m, as suggested by Ludtke et al (2008) or I simply center it on the grandmean. 


In addition to previous post, I'm also trying to calculate the effect size of X on Y, on the basis of Marsh et al (2009). I am interested in the total size of the effect (direct+indirect). Using Marsh's indications I wrote the model as following: Model: %within% DV_W by R1_CNV (2) ; DV_W by R2_CNV (1) ; DV_W by R3_CNV (3); DV ON MV(b_within); MV (Psi_W); DV_W (Theta_W); %between% DV_B by R1_CNV (2) ; DV_B by R2_CNV (1) ; DV_B by R3_CNV (3); DV_B ON IV_B (b1_between); DV_B ON MV (b2_between); MV ON IV_B (b3_between); IV_B (Psi2_B); CNV_B (Theta_B); MV (Psi_B); Model constraint: NEW(ind_eff); IND_EFF = b3_between*b2_between; !effect sizes new(EFFSIZE); EFFSIZE = (b1_between+IND_EFF)*2*(sqrt(Psi_B + Psi2_B))/sqrt(Psi_W*b_within**2 + Theta_W); I was wondering if you think the equation for EFFSIZE is correct. Resulting effect size is .367; I also tried a model without the mediating variable (MV). In that case the effect size results .328 Thank you very much!! Davide 


The MODEL command should be as follows with neither m nor y on the WITHIN list. MODEL: %WITHIN% y ON m; %BETWEEN% y ON m; ! contextual effect m ON x; For the second part of your question, please send the full output and your license number to support@statmodel.com. 


Dear Dr. Muthen, Thanks for all your recent help. I am also trying to estimate a 211 mediation model. Are you saying that we should use your more simplified command above instead of the one from Example E of Preacher et al. (2010), which I have written below? MODEL %WITHIN% m y; y ON m; %BETWEEN% x m y; m ON x(a); y ON m(b); y ON x; MODEL CONSTRAINT: NEW(indb); !<Between indirect effect indb=a*b; Jennifer 


I was translated what you wrote into the Mplus language. If you want to estimate an indirect effect also, you can use MODEL CONSTRAINT as shown above. 

yin fu posted on Monday, September 12, 2011  7:12 am



Dear Dr. Muthen, I am trying to moderate a contextual effect. I am using a similar syntax code to Marsh et al. 2009. When modeling their model 4 (no random slopes) and their model 5a (random slopes), the contextual effect switches from (significantly) positive to (nonsignificant) negative in my model. What could be the reasons for that? The effect stayed similar in the Marsh et al. paper. Also I am a bit unsure about the "[s] (b_within);" command on the %between% level in Model 5a. Does it say: "the mean of the variance of the slope s on level 2 is called b_within"? Isn't that different to the defining command of (b_within) in model 4? Thanks for your help, Martin 


For your first question it is best if you contact one of the two first authors. Regarding your second question, the Model 5 statement "[s] (b_within)" says "the mean of the random slope s is given the label b_within". The Model 4 (b_within) is the fixed slope, so the Model 5 label refers to the same thing conceptually, except that in Model 5 the slope also has a variance. 

yin fu posted on Wednesday, September 14, 2011  3:43 am



Dear Dr. Muthen, Thanks for clarifying. I compared my two outputs and the reason for the contextual effect to switch signs is a strongly decreasing Between Level effect. Is it a normal thing to happen, that the between effect decreases a lot, when a random slope is included in the model, or are chances high that there is something wrong with my data? Thanks again, Martin 


I think that can happen. See the RaudenbushBryk (2002) HLM book. 


Hello, I would like to test a 211 mediation hypothesis within a (larger) MSEM. I use the syntax provided by Preacher, Zyphur, & Zhang (2010) and started with a small model consisting only of continuous variables. For this model the MSEM and the UCM produce comparable results. Now I would like to transfer this to a dichotomous mediator and I ask myself how to build analogous models: In the UCM; if I composed the L2variable of the dichotomous mediator as the mean of this variable, will this be substantially the same as the latent L2variable in the MSEM? If not: How do I compose a manifest counterpart? Kind regards Katrin 


Q1. Yes. Q2. Use the CLUSTER_MEAN option 


Thank you for the quick reply. Now I have a followup question concerning L1. In the UCM, the covariate x and the mediator m have to be group mean centered on L1. However, in Mplus this is not possible for categorical variables. (1) How do I disentangle within and between effects of categorical variables in an UCM in Mplus? (2) How should I imagine the latent version of my dichotomous L1 variable in a MSEM: Is it substantially comparable to a group mean centered manifest version of the variable? If yes, how can I construct analogous models (UCM  MSEM)? Kind regards Katrin 


I think you are getting into a methods research area. If you are going to be serious about a binary mediator you have to study up on the issues. For instance, there is a choice of either taking the WLSMV approach of focusing the modeling on the continuous latent response variable underlying the binary observed variable, or taking the counterfactual causal effect approach (but this is not easy with 2level models). I describe the issues of a binary mediator in my 2011 and 2014 mediation papers (see our website). With the WLSMV approach the mediator is then continuous so binaryspecific issues may no longer be present. 


Thank you for the advice. Even if the binary mediator were not focal, my dependent variable is also binary. Furthermore, I have missings in my data. Please correct me, but the usual recommendation is to prefer ML over WLSMV in this case. Concerning that I am no statistician I won’t be able to apply the counterfactual causal effect approach on a 2levelmodel. So I will try to keep it simple and divide my model in several regressions, following the classical mediation analysis. In doing so I would like to use the Mplus approach which decomposes covariates in two latent parts. Now I hope that you can give me an advice or a reference as regards this difficulty: I would like to investigate, whether a compositional effect is mediated and I assume that the Mplus approach is analogous to group mean centering of manifest variables. So bc is not calculated (but should be the difference of bb and bw). (1) How do I calculate the indirect effect in this case and why? I see two options: (a) Do I first have to calculate the compositional effects for XM (a) and MY (b) and then their product? (b) Or do I first have to calculate the product of (a) and (b) on both levels and then the difference of the products? What are the differences in meaning of the two options? (2) How do I calculate the standard errors for the “right” option? Thank you for any hints Katrin 


I don't think I know the answers here; seems like it requires methods research. I assume that you have a model like Y ON M X; M ON X; extended to a 2level setting with a W predictor of random effects on level 2. But your M and Y are binary. With missing data on M or Y I would recommend ML over WLSMV. Even if Y and M were continuous, I am not sure what you mean. By decomposing covariates I don't know if you mean decomposing X or M or both. You say you are interested in whether a compositional (contextual) effect is mediated  but I don't know if you are referring to a level2 relationship. Perhaps a path diagram of your intentions would be helpful. On top of this your M and Y are binary and latent variable decompositions are tricky here. 


I am not sure, whether we think of the same model. Please, let me describe my context of application instead of a path model: We know that after primary school the individual SES explains the choice of a school track but beyond that, the mean SES of the class has additional explanatory value (compositional/contextual effect). Let’s consider a metric mediator: I assume that a higher SES results in higher aspirations which in turn promote the choice of a more demanding school track (Other assumptions contain the binary recommendation for a certain track by the teacher as a mediating variable). The questions are, whether the mediation partially/fully breaks up the direct compositional effect of SES on choice and how large the indirect effect is. Now I would like to analyze my data by classical mediation analysis, i.e. using several regressions instead of a full path model. I thought of following the second part of ex. 9.1 in the users’s guide. The “implicit, latent group mean centering” led me to the questions in my last posting. Would you still say that my aim requires further methods research or can you think of some suggestions/solutions as regards my questions? Thank you for your efforts Katrin 


Maybe it would help if you show (a simplified version of) the Mplus input for the version of this model where all the variables are continuous. 


If all variables were continuous, I specified the following path model: ANALYSIS: TYPE = TWOLEVEL; MODEL: %WITHIN% track_choice ON SES (c1); track_choice ON Aspiration (b1); Aspiration ON SES (a1); SES track_choice Aspiration; !model missingness %BETWEEN% track_choice ON SES (c2); track_choice ON Aspiration (b2); Aspiration ON SES (a2); SES track_choice Aspiration; !model missingness By using MODEL CONSTRAINT I could calculate the direct contextual effect of SES as c2c1 and the indirect effects as a1*b1 for Level 1 and a2*b2 for Level 2. Now, I am interested in the indirect contextual effect. I see two options: MODEL CONSTRAINT: !see Q1a in posting above NEW(indirect context_a context_b); context_a = a2a1; context_b = b2b1; indirect = context_a*context_b; MODEL CONSTRAINT: !see Q1b in posting above NEW(context indirect_1 indirect_2); indirect_1 = a1*b1; indirect_2 = a2*b2; context = indirect_2  indirect_1; My questions: 1) Which option is the right one for my purpose? Do you know any reference? 2) In case of separate regressions I will have to calculate SE and p manually. How do I calculate them for the respective option? Thank you for any ideas and hints Katrin 


I find page 140 of RaudenbushBryk's Second edition helpful where Table 5.11 shows the two alternatives. If you are interested in contextual effects, the rightmost alternative gives beta_c directly. That approach would therefore seem to me as the one most useful to expand from regression to the mediation modeling you are interested in. That is, you would focus on the product of slopes on Between. I don't know about references on this specifically. You can still do latent variable decomposition, although I don't see that as essential. I thought your major question was about switching from continuous to binary variables. In any case that's about all I have to say about this. 


I know the mentioned table  and your suggestion (product of slopes after grandmeancentering) is, what I would have intuitively chosen. Unfortunately, I am not able to give good reasons and I had hoped that you could think of reasons/references to justify the decision. Nevertheless, thank you for all your efforts and advices. Katrin 


Dear MplusTeam! How can I get contextual effects in threelevel models? I use a simple model: %within% y ON X (bw); x; %between level2% y ON X (bl2); X; %between level3% y ON X (bl3); X; Is the contextual effect of x level2 = bl2  bw and the contextual effect of x level3 = bl3  bl2  bw?? Or is it better to use manifest aggregation of X and use grandmean centering? Thanks Chrisotph 


Look at the right column of Table 5.11 in the RaudenbushBryk book. Not doing groupmean centering gives you the contextual effects on the between levels. The RB book may also discuss this in the 3level case. So, yes, for simplicity, do manifest aggregation of X and grandmean centering. 


Dear Linda/Bengt I am trying to estimate a contextual effects in a growth model. I have measured reading achievement four times (end of Grade 1, Grade 2, Grade 3 and middle of Grade 4). The following growth model fits the date well. i s  y1@0 y2@1 y4@2 y4@2.5 On the individual level, intercept and slop are influenced by reading abilities measured at the beginning of Grade 1 (x). However, I am interested, whether the mean reading abilities of the classes (xm) have an influence (additional to the influence of x) on individual growth in reading. First, I thought the example on p. 270 in the Mplus User Guide v6 might relates exactly to this question. However, if I understand it correctly the example considers growth on within and between level without crosslevel interaction. Thank you very much for your time JanHenning 


You can add a crosslevel interaction, saying for instance %Within% i s  .......... slopei  i on x; slopes  s on x; %Between% ib sb  ....... slopei slopes on xm; 


Dear Bengt, thanks for your answer. Thus, in the following model %within% iw sw  y1@0 y2@1 y4@2 y4@2.5; iw sw on x; %between% ib sb  y1@0 y2@1 y4@2 y4@2.5; ib sb on xm; the effect of xm (aggregated variable) on ib and sb is over and above their effect at the within level? Thanks JanHenning 


That's right. 


Dear Drs. Muthen, I want to simulate ordinal multilevel data that has DIF. I just know I should use 2 parameter logistic IRT model. Please tell information about this model and steps of my simulation. I have a little information about this problem and I do not know where I can find about it? 


IRT modeling in Mplus is described on our IRT page which you find in the left margin of our homepage. But you need to learn about the topic before you can start doing simulations. You will find many references using Google. And you can ask on a general discussion forum like SEMNET. 

Dirk Pelt posted on Tuesday, September 29, 2015  2:35 am



I have a similar question as Student 09 and Simon Denny in 2009: When grandmean centering is used, gamma10 should already be the contextual effect, right? (according to R&B, table 5.11, p. 140). So why is the betac = gamma01  gamma10 command there in example ex9.1b? I noticed that in the Marsh et al (2009) paper, the same is done (Model 4). Then, in Model 5, the centering is removed, while the contextual effect is calculated in the same way (gamma01  gamma10). So my question is basically: what is the correct way of calculating the contextual effect when using a grand mean centered X (or raw X, corresponds to raw X  0)? Regards, Dirk 


Note that ex 9.1b uses a latent variable decomposition of x. As it says on page 263 of the UG, this means that Mplus uses a "latent groupmean centering of the latent withinlevel covariate". Hence, the betac expression. 

Dirk Pelt posted on Thursday, October 01, 2015  4:37 am



Thanks for your answer. However, when I compare results from the two different methods of example 9.1., it appears that this betac expression is not needed. With my data, using the first method with grandmeancentering, the between effect (Mx) on y is .16 (contextual effect), the within effect is .35. Using the second method produces identical results. Hence, if I had used the betac expression in the 2nd method (latent decompositon of X), the conclusion would have been that the contextual effect would be .16  .35 = .18. As a check, I compared the results using groupmean centering: the latent between effect is then .51 and the within effect is .35. The contextual effect being .51  .35 = .16. Again, this speaks against using the betac calculation when using grand mean centering. Why should adding a latent between component of X change calculations of the contextual effect? Assuming perfect reliability of Mx (as is almost the case in my data), shouldn't the results be the same? I hope you can clear my confusion. 


Note that in the latent, implicit groupmean centering x_w = x  x_b so a change in contextual effects between observed and latent variable treatment of x on between is not exactly dependent on reliability of the covariate, but more on the between variance. To get clarity in your comparisons, please send the 2 outputs from the analyses of your data corresponding to the 2 approaches of ex 9.1.a and 9.1.b to support along with your license number. 


Hello Prof. Muthen, you write "a change in contextual effects between observed and latent variable treatment of x on between is not exactly dependent on reliability of the covariate, but more on the between variance." Is there any literature available discussing this point? Why is it the variance, and not so much the absence of sampling error? I'd like to learn more about why and when contextual effects change  Best, Tino 


Have a look at the article on our web site 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 

Back to top 