2-level path analysis PreviousNext
Mplus Discussion > Multilevel Data/Complex Sample >
 Veronique Van ACker posted on Friday, November 24, 2006 - 8:00 am
I am working on a 2-level path analysis to study travel behavior of individuals (level 1) within neighborhoods (level 2). The dataset consists of information of singles, so there is no interaction with a household-level. This is how I defined the model:

DATA: file is C:\single.dat;

names are ...;
usevariables are ...;
within = age sex driv_lic degree employed car income weekend;
between = dist_pt pop road housing com entropy;
cluster = neigh;


distance ON age sex driv_lic degree employed car income weekend;
time ON distance age sex driv_lic degree employed car income weekend;

distance on dist_pt pop road housing com entropy;
time on distance dist_pt pop road housing com entropy;

MODEL INDIRECT: time ON distance age ...

However, I get this error:

The number of observations is 0. Check your data and format statement.
Data file: C:\single.dat
Invalid symbol in data file:
"age" at record #: 1, field #: 3

I checked the data-file, but I can not find out what goes wrong.

Thanking you in advance,
 Linda K. Muthen posted on Friday, November 24, 2006 - 8:56 am
It sounds like you have the variable names as the first record of your data file. You need to remove the record that contains the variable names.
 Kätlin Peets posted on Tuesday, February 08, 2011 - 1:16 pm

I am running a two-level path model (with fixed slopes but random intercepts). I have tried to use different centering options for within-level co-variates (grand- and group-mean centering). I understand that these transformations should affect the intercept values. But my slopes (and their significance) change dramatically as well. How can this be? I have understood that this should not be the case (as I don't have random slopes).
 Linda K. Muthen posted on Tuesday, February 08, 2011 - 2:16 pm
Grand mean centering will result in the same regression coefficients as no centering because the same value is subtracted from each value of the variable. Group mean centering will result in different regression coefficients because different values are subtracted from each value of the variable depending on the cluster. See Table 5.11 on page 140 of Raudenbush and Bryk shows this.
 Kätlin Peets posted on Tuesday, February 08, 2011 - 3:04 pm
Thank you for your quick reply. However, I guess there is still a slight difference in parameters (slope coefficients) when using raw vs. grand-mean centered variables.
For instance, under no centering:
ARITM2 ON READING0(B = 0.016; SE = .027)
ARITM2 ON MATH0 (B = 0.031; SE = 0.011)
ARITM2 ON AVOID0 (B = -0.104; SE = 0.050)

But when I grand-mean center,
ARITM2 ON READING0(B = 0.059; SE = 0.027)
ARITM2 ON MATH0 (B = 0.036; SE = 0.011)
ARITM2 ON AVOID0 (B = -0.064; SE = 0.046)

What is the reason for that? Also, why does the model fit change?
 Linda K. Muthen posted on Tuesday, February 08, 2011 - 3:39 pm
There should be no differences. The fit should be the same. If the fit changes, then either you are hitting a local solution in one case or the centering is not the only difference between the two models. For further information, please send the two outputs and your license number to support@statmodel.com.
 Kätlin Peets posted on Tuesday, February 08, 2011 - 4:11 pm

I might send my outputs. But I also already checked it and it seems that you are correct about hitting a local solution. It concerns the model where raw scores are used. Thus, I might use grand-mean centered scores then.


Final stage loglikelihood values at local maxima, seeds, and initial stage start numbers:

-3830.482 unperturbed 0
-3831.864 93468 3
-3831.864 27071 15
-3831.867 259507 53
-3831.867 565819 65
-3833.319 761633 50

4 perturbed starting value run(s) did not converge.

 Kätlin Peets posted on Wednesday, February 09, 2011 - 2:33 pm
I have one more question. When I use raw or grand-mean centered predictors that are specified at both levels (within and between), are the between-level effects already contextual effects? That's what I understand from Raudenbush and Bryk. However, in their example, they use an aggregate variable that is observed rather than latent.
 Linda K. Muthen posted on Thursday, February 10, 2011 - 10:59 am
I think this is the case. See the following paper which is available on the website for further information:

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 group-level effects in contextual studies. Psychological Methods, 13, 203-229.
 Kätlin Peets posted on Thursday, February 10, 2011 - 1:01 pm
I am still a bit confused. In the user's guide (p. 242), it seems that contextual effects are computed by gamma01 - gamma10. This would mean that between-level effects are not directly contextual effects.
 Bengt O. Muthen posted on Thursday, February 10, 2011 - 1:39 pm
Page 242 talks about the case where you work with a latent x variable. On top of page 243 we state that using a latent x implies latent group-mean centering - so corresponding to the left column of R & B's Table 5.11. With a manifest x, grand-mean centering leads to a contextual effect coming out directly as the between-level slope, as in the right column of Table 5.11, and as you said.
 Kätlin Peets posted on Thursday, February 10, 2011 - 1:57 pm
OK. Thanks a lot.
 Jing Zhang posted on Thursday, May 03, 2012 - 10:57 am
I have a cross-level mediation model or a two-level path model with:

X (independent variable at cluster level)
M1 (mediator 1 at individual level)
M2 (mediator 2 at individual level)
Y (dependent variable at individual level)

Can I use the command “IND” to examine the indirect effects from X to Y in this case? I looked into the Mplus forum, notes and other related website of Mplus, it seems to me that “IND” is used with one-level model only in the examples I have found. Is there a reason that “IND” is not used in a two-level path model?
 Linda K. Muthen posted on Thursday, May 03, 2012 - 11:41 am
 Kelly Harper posted on Friday, December 29, 2017 - 7:46 am
I was wondering if I am able to analyze a 2-level path model that is a linear path where X is a Level 2 variable, the two mediators (M1 and M2) are Level 1 variables, and the dependent variables is a Level 1 variable. The model looks like this:

SPP(Level 2) -> ns_comp (Level 1) -> exp_mean (Level 1) -> lonely (Level 1)

I tried to run the model using the syntax below; however, I get a warning that says "Variable on the left-hand side of an ON statement in a | statement is a WITHIN variable. The intercept for this variable is not random. Variable: EXP_MEAN"

Usevariables = SOP SPP ns_comp exp_mean lonely;
Useobservations = Surveys gt 14;
MISSING = ALL (-999);
within = ns_comp exp_mean;
between = SPP SOP ;
Cluster = ID;

center spp sop (grandmean);

Type = twolevel random;

s | exp_mean on ns_comp;
s2 | lonely on ns_comp;

s on SPP SOP;
s2 on s;

Does this mean the model is not executing properly? Thank you!
 Bengt O. Muthen posted on Friday, December 29, 2017 - 10:45 am
It sounds like you've put exp_mean on the Within list. This contradicts having this variable on the left-hand-side of a random slope statement - if you say that the slope varies across between units, the variable varies across between units and is therefore not a Within variable. Note that you don't have to have random slopes (they are often not random).
 Helan Asghar posted on Wednesday, August 29, 2018 - 1:38 am
Hi Dr Muthen,
Is it possible to predict level 2 dependant variable with level1 independant variable and level 1 mediator?

I think of using the following syntax with Two Level Random using examples from 9.1 onwards


S| m on x;


m on x (a);
y on m (b)
S (c);

Model constraint:
New (indirect);
Indirect= a*b;
 Bengt O. Muthen posted on Wednesday, August 29, 2018 - 1:17 pm
You can say


S| m on x;


m on x (a);
y on m (b)
x (c);
s on x;
s with y m;

Model constraint:
New (indirect);
Indirect= a*b;

The best approach is to use Estimator = Bayes; see the new paper on our website:

Asparouhov, T. & Muthén, B. (2018). Latent variable centering of predictors and mediators in multilevel and time-series models. Technical Report, Version 2. August 5, 2018. Accepted for publication in Structural Equation Modeling. (Download scripts).
 Helan Asghar posted on Wednesday, August 29, 2018 - 4:12 pm
***ERROR in MODEL command
Unrestricted x-variables for analysis with TYPE=TWOLEVEL and ESTIMATOR=BAYES must be specified as either a WITHIN or BETWEEN variable. The following variable cannot exist on both levels: X

This error command appear.
 Ahmad Siddiquei posted on Thursday, August 30, 2018 - 12:38 am
Same problem occured to me. If I restrict X to within level, then I could not test "c" path and hence could not infer about partial or full mediation.
 Bengt O. Muthen posted on Friday, August 31, 2018 - 1:15 pm
Are you using version 8.1? If so, send output and data to Support.
 Ahmad Siddiquei posted on Saturday, September 01, 2018 - 4:14 pm
I am using version 8. Is this feature npt available on 8?
 Bengt O. Muthen posted on Saturday, September 01, 2018 - 4:31 pm
Latent variable decomposition for an X with random slope using Bayes was introduced in Version 8.1 - see the Version History page on our website:

 Ahmad Siddiquei posted on Saturday, September 01, 2018 - 4:45 pm
Perfect, Thank you.
 Jason Lava posted on Saturday, September 01, 2018 - 8:52 pm
Hi Dr Muthen,
I read this article you mentioned and saw the initial discussion. It looks great. What I get is that we can now test 1-1-2 model where outcome has no within cluster variation. Right?
If I am correct, then this is a big thing since it was a limitation in earlier multilevel models.
 Bengt O. Muthen posted on Sunday, September 02, 2018 - 1:12 pm
The new feature is for random slope situations. We already did 1-1-2 models without random slopes where outcome has no within cluster variation.
 Ahmad Siddiquei posted on Sunday, September 02, 2018 - 6:39 pm
Use variables are Independent, Mediator, Dependant;

Between= Dependant;
Within= Independent;

Cluster= Team ID;
Analysis: Type= TWOLEVEL RANDOM;

Mediator ON Independent (a);


Dependant ON Mediator (b);

Model Constraint:

New (Indirect);

Indirect= a*b;

My question is how can I estimate Independent (Level 1) to dependant path (Level 2)?
 Bengt O. Muthen posted on Monday, September 03, 2018 - 1:53 pm
Sounds like yet another variation on your mediation theme. In this case, I would delete the Independent variable from the Within= list and add on %Between%

Mediator on Independent (a);

and delete your within level "(a)". In this way, it is the between-level part of Independent that influences the between-level part of the Mediator which in turn influences the Dependent variable, resulting in the indirect effect a*b.
 Ahmad Siddiquei posted on Monday, September 03, 2018 - 4:30 pm
Thank you. One final question, do we need to test a*b and c in ONE model or test them separately? If I test them separately, all paths are significant including the a*b indirect effect. When test them in a ONE model, everything becomes insignificant. Can you please advise on this?
 Bengt O. Muthen posted on Tuesday, September 04, 2018 - 2:48 pm
They should be tested separately. They are different hypotheses.
Back to top
Add Your Message Here
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Options: Enable HTML code in message
Automatically activate URLs in message