Plotting MLM interaction
Message/Author
 Jaimee posted on Tuesday, May 27, 2014 - 4:01 pm
I am trying to figure out how to plot an interaction effect between 2 level 2 variables in a MLM. I am having a bit of trouble as I am getting confused with the syntax.

Here is what I have

USEVARIABLES clus Y X C D M N O MxN;
CLUSTER = clus;
WITHIN = C D;
BETWEEN = M N O MxN;
DEFINE:
MxN = M*N;
CENTER M (GRANDMEAN);
CENTER N (GRANDMEAN);
CENTER O (GRANDMEAN);

ANALYSIS: TYPE = TWOLEVEL;

MODEL: %within%
Y on C D;
%BETWEEN%
Y on M (beta1)
N (beta2)
O
MxN;

MODEL CONSTRAINT:
PLOT(interaction);
LOOP(moderate, 5, 28, 1);
Y = beta1+beta2* moderate;
PLOT: TYPE = PLOT2;

The model constraint and naming of the pathways is where I am confused. I need a plot with Y on the Y axis, N as the moderator and M on the X axis.

Any help would be very much appreciated. Thanks very much.
 Bengt O. Muthen posted on Tuesday, May 27, 2014 - 6:18 pm
Take a look at how it is done for UG ex 3.18 as shown on our Mediation page:

http://www.statmodel.com/Mediation.shtml

Just translate that to your Between-level statements.
 Laura Giurge posted on Thursday, April 30, 2015 - 4:33 am
Hi, I have a related question to the above discussion. I am running a twolevel random model with random intercepts and slopes. I wish to plot the cross over interaction but I get an error message: ' Error in parsing line:"LOOP (MOD,-1,1,0.1)"'

Here is the full syntax:
Missing are all (-99);
BETWEEN = gmx;
WITHIN = gmw;
CLUSTER = Id;
ANALYSIS: TYPE = TWOLEVEL RANDOM;
MODEL:
%WITHIN%
s | sqy ON gmw;
%BETWEEN%
sqy ON gmx;
[s] (a);
s ON gmx (b);
sqy WITH s;
MODEL CONSTRAINT
PLOT(crosslv1);
LOOP (mod, -1,1,0.1);
crosslv1 = a+b*mod;
PLOT:
TYPE = PLOT2;
OUTPUT: TECH8 TECH4 SAMPSTAT;

I cannot figure out what am I doing wrong. Thanks a lot in advance!
 Bengt O. Muthen posted on Thursday, April 30, 2015 - 6:24 pm
You don't show a colon after CONSTRAINT.
 Laura Giurge posted on Friday, May 01, 2015 - 7:44 am
Professor Muthen, thank you so much for the quick response! It was a very sloppy mistake on my side.
 Stefan Kamin posted on Wednesday, October 25, 2017 - 9:02 am
Dear all,

I would like to plot an interaction between X and M within the level 1 equation. The model has one covariate at level 1 (cov1) and another one at level 2 (cov2). In addition, I am interested in the simple slopes at different values of M (0/1). I adapted the example from UG ex 3.18 and would like to know whether my syntax is accurate:

%WITHIN%
s_x | y on x;
s_m | y on m;
s_xm | y on xm;
s_cov1 | y on cov1;

%BETWEEN%
[y] (b0);
[s_x] (b1);
[s_m] (b2);
[s_xm] (b3);
y on cov2;
y with s_x s_m s_xm;

Model Constraint:
PLOT(SS1 SS2);
LOOP(x,0,100,0.1);
SS1 = b0 + b1*x + b3*0*x + b2*0;
SS2 = b0 + b1*x + b3*1*x + b2*1;

NEW(SS1 SS2);
SS1 = b1+b3*(0);
SS2 = b1+b3*(1);

Thank you very much!
 Bengt O. Muthen posted on Wednesday, October 25, 2017 - 11:01 am
The syntax looks correct.
 S REN posted on Friday, February 23, 2018 - 3:29 am
Hi, could I ask how to create the xm IN mplus 9.2 EXAMPLE.
I don't really understand that 'The observed cluster-level covariate xm takes the value of the mean of x for each cluster'.

Does this mean
xm = (the group mean of X) * m

Or does this mean
xm = (groupmean centering X) * m

Thank you.
 S REN posted on Friday, February 23, 2018 - 3:55 am
Hi a follow-up question is for the example 9.2 in the UserGuide as below

is X (as specified as the within level) referring to the raw data of X?
Or is X (as specified as the within level) referring to the group mean centered raw data of X? Thanks.

VARIABLE: NAMES = y x w xm clus; WITHIN = x; BETWEEN = w xm; CLUSTER = clus;
 Bengt O. Muthen posted on Friday, February 23, 2018 - 4:38 pm
First post:

xm refers to "the x mean", that is what can be obtained using the Cluster_Mean option.

Second post:

x is the group-mean centered raw data of the observed x variable. This is what the Center x(groupmean) statement in the Define command accomplishes.
 S REN posted on Saturday, February 24, 2018 - 9:32 am
Much appreciated@