Cross-level interaction in multilevel... PreviousNext
Mplus Discussion > Multilevel Data/Complex Sample >
 TD posted on Monday, November 19, 2007 - 7:32 am
Hello -

Forgive me if this question is too general. I have used HLM to determine the siginificance of a cross-level interaction in a multilevel model. However, I would like to compare the fit of the overall path model, to a second nested model. I have decided to use SEM and Mplus to do this. Yet, it is not clear to me if I can generate a cross-level interaction with a multilevel SEM. I haven't seen this in the literature either. The models and literature by both Muthens has been very helpful, but I hadn't seen anything about this possibility. You are innovators with regard to multilevel SEMs, so I am sure you can offer some information.
 Linda K. Muthen posted on Monday, November 19, 2007 - 8:35 am
A cross-level interaction, or a between-level (level 2) variable moderating a within level (level 1) relationship, as shown below as the random slope in y regressed on x:

yij = beta0 + beta1j xij + rij

beta1j = gamma10 + gamma11 wj + u1j

gives the interaction, a product of xij and wj if you insert the beta1j equation in the yij equation.

is specified in Mplus as:

beta1 | y ON x;
beta1 ON w; ! estimates gamma11

The variable y can be observed or latent that is a factor measured by multiple indicators.
 TD posted on Monday, November 19, 2007 - 9:31 am
Thank you so much!
 Verena Hahn posted on Tuesday, August 07, 2012 - 6:45 am

I would like to estimate a cross-level interaction in which the slope is not randomly varying:

yij = beta0 + beta1j xij + rij

beta0j = gamma00 + gamma01 wj

beta1j = gamma10 + gamma11 wj

How can I specify this in Mplus?

I thought the following might work. Is this right?

beta1 | y ON x;
y on w;
beta1 ON w;
beta1 @0;

 Linda K. Muthen posted on Tuesday, August 07, 2012 - 7:57 am
That looks correct.
 Garett Howardson posted on Thursday, September 26, 2013 - 10:40 am
I just wanted to confirm that the Verena Hahn's post on Tuesday, August 7th, 2012 is still what you would suggest. I have a multilevel model where repeated measures are taken at two time points within persons. I'm only interested in the fixed effect of the within person slope but to also allow a random intercept. I also expect that the fixed slope will be moderated by a level 2 variable. In other words, I'm only interested in examining whether the average within person effect changes as a function of a level 2 variable. As such, I'm interested in a cross-level interaction where the level 1 slope is not randomly varying. Would you still recommend implementing this in Mplus as:

beta1 | y ON x;
y on w;
beta1 ON w;
beta1 @0;
 Bengt O. Muthen posted on Thursday, September 26, 2013 - 3:46 pm
That seems like a correct setup. I wouldn't say that the slope isn't varying because it does vary as a function of w. I also don't see the need for fixing the residual variance at zero for the slope on between - that says w totally determines the variation in the slope.
 Garett Howardson posted on Friday, September 27, 2013 - 4:38 am
Thank you Dr. Muthen. I see what mean about the slope varying across w. If I omit the residual constraint (i.e., beta1 @0) won't that estimate the random effect for the level 1 slope? I was under the impression that with only two level 1 observations a model with both a random intercept and slope would be underidentified and that the residual constraint is necessary for model identification.

Thank you.
 Bengt O. Muthen posted on Friday, September 27, 2013 - 8:24 am
Try freeing this residual variance and see if Mplus tells you about any problems.
 Praneet Randhawa posted on Monday, October 21, 2013 - 8:25 am
Good morning:

I have a quick question. When we are testing cross-level interactions, do we test the main effects between the two level 1 variables in the hypothesized interactive model?

For example:
s1 | Y ON X;

YB s1 ON Z1 Z2;

In the above model, the effect of YW ON X is negative and non-significant. Whereas in the main effects model, the effect was positive and significant. I saw some papers report similar effects but argued that lower level effects should not be interpreted in the presence of higher level effects. Is that the way to go? And what the reasoning behind such an effect?
Thank you.
 Linda K. Muthen posted on Monday, October 21, 2013 - 4:59 pm
In a model like the following,

y ON x1 x2 x1x2,

if the interaction is significant, you do not interpret the main effects. That is because they do not behave the same for everyone. There is an interaction.

I don't understand your model above in the context of your question.
 Aurelie Lange posted on Monday, January 05, 2015 - 4:26 am
Dear Dr Muthen and Muthen,

I have specified a cross-level interaction as follows:
S | x on y;
S on w;

In my output, I get the estimates for s on w, but not for x on y. I was wondering why this is.

Thank you for your help!
 Linda K. Muthen posted on Monday, January 05, 2015 - 5:36 am
x ON y has a random slope not a fixed slope like s ON w. You will get an intercept and residual variance for the random slope in the between results.
 Aurelie Lange posted on Monday, January 05, 2015 - 6:21 am
Of course! That makes sense. Thank you so much for your clarification.
 dummyvariable123 posted on Sunday, January 21, 2018 - 6:25 am
Dear Dr Muthen,

I'm testing a cross-level interaction in a three-level longitudinal model (time-persons-classes).
L3 (time-invariant) predictor "Z_grandmean" moderates the random effect of L2 (time-invariant) predictor "X_grandmean" on L1 outcome "Y".

1. Is this code correct?:

cluster = class id;
between = (id)X_grandmean (class) Z_grandmean;
within = wave Qwave X_personcenter;
S1 | Y ON wave;
Y ON Qwave;
Y ON X_personcenter;
%between id%
S2 | S1 ON X_grandmean;
%between class%
Y WITH s1;
Y WITH s2;
s2 ON Z_grandmean;

2. When I'm running this code I get an error message: "One or more between-level variables have variation within a cluster for one or more CLASS clusters. Check your data and format statement. Between Cluster IDs with variation in this variable: Z_grandmean 34 19 31 36 16 6 14"
Z_grandmean is grand-mean centered at L3 and X_grandmean is grand-mean centered at L2.
 Bengt O. Muthen posted on Sunday, January 21, 2018 - 5:23 pm
The code seems ok. The problem lies in the data as suggested by the error message - check the data.
 dummyvariable123 posted on Monday, January 22, 2018 - 12:59 am
Thank you for taking a look at the code.
Just to make sure: shouldn't I also include:

at the %between class% level
S1 ON Z_grandmean
Y ON Z_grandmean


at the %between id% level
Y ON X_grandmean?
 Bengt O. Muthen posted on Monday, January 22, 2018 - 5:10 pm
Yes, that would be better.
 Matt Boulter posted on Thursday, May 17, 2018 - 3:01 am
Dear Dr Muthen,

I am currently testing a level 1 mediation model with a level 2 moderator variable (VAR).

The model gives me this error message:

*** WARNING in MODEL command
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: RC
*** WARNING in MODEL command
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: COMM

For the given script:

define: center NPI RC (groupmean);

snpirc| RC ON NPI;
snpicomm| COMM ON NPI;

snpirc ON VAR;
snpicomm ON VAR;

Is it possible to run this model without a twolevel random analysis? As it does not work with a TYPE= TWOLEVEL analysis either.

Any help is welcome and thank you!

Matt B
 Bengt O. Muthen posted on Thursday, May 17, 2018 - 4:34 pm
Putting RC and COMM on the Within list says that they don't vary across Between units and this is a contradiction to saying that you have random slopes for those DVs. If you have random slopes, they will vary over clusters. So remove RC and COMM from the Within list.

Also, you don't want to group-mean center RC .
 Filippo Temporin posted on Tuesday, March 19, 2019 - 9:19 am
Dear Dr Muthen,
I am fitting a three-level model to check the effects of an observed binary covariate v1 (defined at level 1) and a latent variable decomposed into level-2 and level-3 components L2 and L3 on an outcome (d) defined at level 1:

d on v1

%BETWEEN level 2%
L2 BY *observed items*
d ON L2

%BETWEEN level 3%
L3 BY *observed items*
d ON L3

How can I define the cross-level interaction effect between v1 and L3 on d?

Many thanks!
 Bengt O. Muthen posted on Tuesday, March 19, 2019 - 1:48 pm
Say on Within

s | d on v1;

and on Between Level 3

d s on L3;
 N_2018 posted on Thursday, June 20, 2019 - 8:41 am
Hello, I am attempting to conduct several cross-level interactions in a multilevel model.

The outcome variable of interest is drinking (a single-timepoint variable). There are two within-person variables pertaining to an experimental task condition: friend and peer. I want to know whether the effect of (friend x peer) on drinking depends on a third variable: frdrink, which is a between-level, single-timepoint variable.

I'm trying to model all the main effects and two-way interactions as is done in a standard OLS regression, but keep getting errors because creating a two-way interaction requires estimating the slope of my within-person variables and my between-person predictor. Below is my input. I know it is incorrect, but I have it below so that it hopefully clarifies what I'm thinking. Will you kindly advise on the best way to proceed? Many thanks in advance!

WITHIN = friend peer;
BETWEEN = frdrink;
COUNT = drinking;
MISSING are all (-999);


drinking ON friend peer;
thresh | friend ON peer;
s1 | frdrink ON friend;
s2 | frdrink ON peer;
3wy | frdrink ON thresh;

drinking ON frdrink s1 s2 thresh 3wy;
 Bengt O. Muthen posted on Saturday, June 22, 2019 - 6:27 am
I don't know why you have

thresh | friend ON peer;

Perhaps you want to use Define to compute friend*peer and use that interaction in the model?
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