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!
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
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;
You can just play with the regression equations for your model:
y = a_j + b1*x + b2*w + b3_j*w + error
a_j = a + g1*z + error
b3_j = b + g2*z + error
Here a_j is your random intercept which appears as Y on Between and b3_j is your random slope s in the regression of y on the xw interaction. Plugging the last 2 equations into the first, you have
y = a + g1*z + b1*x + b2*w + (b + g2*z)*xw + error terms,
where the terms involving x can be summarized as
[b1 + (b + g2*z)*w]*x.
That would be the simple slope that can be evaluated as a function of x for different combinations of values of z and w - but you better check that I did the algebra right. This can be done like the plot of ex 9.2b where you just have a different simple slope formula as given above and you have not only 2 expressions you want to plot but perhaps 4 (low/high z combined with low/high w).
that is exactly what I was looking for, thank you very much!
Silvia posted on Tuesday, October 30, 2018 - 6:12 am
Dear Prof. Muthen,
as in the previous post, I need to estimate the simple slopes for a three way interaction between x, w (both level 1) and z (level 2). I would like to know whether my syntax is accurate in labeling the terms for the simple slope formula you suggested ([b1 + (b + g2*z)*w]*x).
1. If the effects are significant you would want to keep these (as random or non-random effects depending on the significance of the mean and variance of the random effects sx sw sxw)
2. If you are not using the new methodology that we just released in 8.3 you should take a look at section 3.3 http://statmodel.com/examples/webnotes/webnote%2023.pdf and examples http://statmodel.com/download/WebNote23.zip From the input you are providing I am not sure you are using latent centering correctly since X*W should have been defined with the XWITH command. If you want to use latent centering you should follow the scripts in Section 3.3. Alternatively and sufficiently good for cluster sizes >50 use observed centering for X and W and then form the interactions. Also see Table 5 & 6 for MLO estimation and the corresponding scripts.
Thank you for directing us to this new material, it's been very helpful. Reading through the webnote and the examples, it looks as though the recommendation is to no longer use a random slope for Preacher's B1 hypothesis (cross-level interaction). I've been trying to adapt our own syntax to match the Section 3.3.5 example (B1 hypothesis, Table 10). Iíve started with a simpler 2-way cross-level interaction (rather than jumping into the 3-way I mention above) but the model doesn't converge and Iím wondering if I've made an error in setting it up (it has previously converged, using the random slope approach). We use a true factor at the between-level instead of a single indicator latent. Is this the appropriate way to set it up?
I have a similar genre of questions. I'm interested in testing a 1x(1-1) model with other covariates using Bayes in Mplus 8.3. Some of the predictors are binary, including one of the predictors in the interaction.
1. Can I still use the XWITH command in this case? Both variables are observed, but I can't specify the within variance for the binary variable.
xw BY ImmDiAvg@1; ImmDiAvg@.01; zw BY immi@1; !immi@.01; gives it issues xzw | xw XWITH zw; xw WITH zw;
2. Is latent variable centering automatic in 8.3? Or should I be creating a latent variable behind every L1 predictor, including all the covariates? Or a subset of only the categorical/continuous covariates?
1. It is not possible with binary variables. Depending on your situation you might be able to use xzw | xw XWITH immi; You would need to drop the categorical specification for that variable and declare it as within only. If that variable is needed elsewhere in the model you can make a duplicate copy of the variable that would be used in the XWITH. The interaction is based on the observed values 0/1 and no centering or underlying latent is used. It is probably your best bet. If clusters are large you can do observed centering and form the interactions from observed values rather than latent.
2. It is automatic if the variable appears on both levels. You don't need to create latent variables if the variables are not going into an XWITH statement.
3. I am not sure what testing you were expecting. When data is imputed we estimate the imputation model until convergence and then impute the variables by continuing to run the MCMC after the convergence is achieved. If you need to test a model - you would do that separately from the imputation.
anonymous posted on Friday, January 17, 2020 - 1:17 am
I used doubly laten model to investigate cross-level interaction effects: the interaction effects between the class-average score (latent, scb) and individual scores (latent, scw) on individuals' mot (latent).
I used following code center z1-z4 (grandmean); ANALYSIS: TYPE = twolevel random; algorithm=integration em; integration=5; mconv=1000; GHFIML=OFF; MODEL: %WITHIN% motw by e18 (1) e19 (2) e36 (3) e32 (4) e59 (6);
scw by z1 (11) z2 (12) z3(13) z4 (14);
t | motw on scw ; %BETWEEN% motb by e18 (1) e19 (2) e36 (3) e32 (4) e59 (6);
scb by z1 (11) z2 (12) z3(13) z4 (14);
t on scb (mod); !significant [t] (bw) motb on scb (bb);
MODEL CONSTRAINT: new(cont); cont = bb - bw; !significant
1. Moderate effect (mod) was significant. Does this significant interaction effect indicates that students with different score are differently affected by class-average score?
2. How can I plot this effect (scb*scw -> motw) using model constrain?
This plot seems to show that scw on motw was higher in the higher-performing classes than lower-performing classes (different lines; the both lines intersect the x-axis).
Actually, I am interesting to see whether class-average score (scb, latent aggerated) would have a greater impact on motw among individuals with lower or higher scores (scw). So I thought that scb should be on the x-axis and scw_high and scw_low should be on the different lines.