DSEM data and interaction questions PreviousNext
Mplus Discussion > Dynamic Structural Equation Modeling >
 Charlotte Vrijen posted on Wednesday, December 20, 2017 - 7:09 am
I have three questions regarding DSEM analyses and our data. We have 228 participants who filled in questionnaires 5 times a day, with random time intervals, for 11 days. So max 55 measures a day. We want to explore the reciprocal lagged associations between variables X,Y , Z.

Question 1:
X was always filled in, Y and Z were only filled in when the participants were not alone, this was the case in 64% of all measurements. Is this kind of non-random missing an issue in DSEM?

Question 2:
We would like to include within-person interaction terms with another variable (variable W) in our DSEM analyses, but there are 2 problems there. 1. We are not allowed to make product terms with the lagged variables. 2. We cannot add a lagged moderator (variable W) when there is no autoregressive path for this variable in the model. Is this in any way possible? If not, will this option be included in a future version of Mplus?

Question 3: Variables Y and Z have rather skewed distributions. Are there any recommendations about the max skewness of the data within the DSEM framework?

Many thanks in advance!
 Bengt O. Muthen posted on Wednesday, December 20, 2017 - 1:50 pm
Q1: It is the usual issue - if missingness is not influenced by X or Y and Z at an earlier time point so that MAR holds.

Q2: You can add a fake autoregressive path

W on W&1@0

The interactions at this point can be explored using observed interactions (although that might not work if you have missing data).

Q3: You can try categorizing the variables and treating them as ordinal.
 Glenn Kiekens posted on Friday, February 08, 2019 - 5:41 am
Dear drs. Muthen,

I have a question regarding the specification of within-person interaction terms in DSEM. I want to examine whether a continuous variable W (t-1) moderates the temporal association between a binary variable X (t-1) and binary outcome variable Y(t). I am not using any random effects given that there are only few individuals. I have specified the interaction term using the define command. However, I am unsure to whether I should fix the autocorrelation of the interaction term “inter on inter&1@0!”, given that the autocorrelation of X and W (that make up the interaction) are already in the model , or I should let this term be estimated freely (as in the syntax below)? Many thanks in advance!

Y on Y&1;! carryover Y
X on X&1;! carryover X
W on W&1;! carryover W
inter on inter&1! carryover interaction,
Y on X&1;! spillover X
Y on W&1;! spillover W
Y on inter&1! Spillover interaction-term, the effect we are interested in.

X; Y;
W; Inter;
[W]; [Inter];
 Tihomir Asparouhov posted on Friday, February 08, 2019 - 7:46 pm
I would leave it if it is significant.

I would recommend exploring the interaction effect (especially if you don't have missing data) using the observed centering. It would require some more data manipulation ahead of time - center X and W for each cluster then form the interaction term - observed centering for the interaction. Then shift the interaction by 1 period (use the cluster average for the first period) and treat it as an actual covariate (not a lagged dependent variable). You may find some useful information here


and here

 Jana Holtmann posted on Thursday, February 21, 2019 - 1:30 am
Dear Mplus team,

I would like to estimate a time-series model with DSEM including two time-varying covariates as within-variables. As I am using the tinterval option, I am working around the missings on my within-level predictor variables by including a fake autoregression of the predictors:

within = pred1 pred2;
lagged = pred1(1) pred2(1);
tinterval = time;

Y on pred1 pred2;
pred1 on pred1&1@0;
pred2 on pred2&1@0;

I wondered whether in this specification the covariance between my two predictors is estimated and accounted for in the regression of Y on pred1 and pred2 ? Or is it constrained to zero (as my predictors become dependent variables by inclusion of the fake autoregressive effects and I have not explicitly specified them to be correlated)?
Do I need to specify "pred1 with pred2" in the model in order to account for the predictors' correlation?

Thank you very much for your help
 Bengt O. Muthen posted on Friday, February 22, 2019 - 12:02 pm
Yes, say pred1 with pred2. And drop the @0 for the AR - estimating them freely can make a difference.
 Jana Holtmann posted on Monday, February 25, 2019 - 11:06 am
Dear Bengt,

thank you for your quick answer. I noticed that my question might not have been precise enough...

My predictor variables are actually dummy variables (which is why I do not want to freely estimate their AR effect as they happen to be quite stable over some time periods). The loading parameters of my dummy predictors are random effects that are allowed to covary on the between level. In this way, the correlation is somehow already included in the model.


s1 | y on pred1;
s2 | y on pred2;

pred1 on pred1&1@0;
pred2 on pred2&1@0;


s1 with s2;

1) Do you think I still need to include pred1 with pred2 ?

2) And as I think about it now, does it make any sense at all to estimate this model with the tinterval option? When my dummy predictors are treated as dependent variables, they are probably augmented for the inserted missing time points in the MCMC estimation using information such as their mean and variance? That would not make any sense for my dummy variables. Do you have any idea how I can include my dummy predictors while still making use of the tinterval option?

Thank you so much for your help!
 Tihomir Asparouhov posted on Monday, February 25, 2019 - 5:15 pm
If pred1 and pred2 are stable - perhaps they shouldn't be considered missing, for example if you know when they change. Regardless
pred1 on pred1&1@0;
is not a good idea because it makes them random rather than stable. It is a tricky situation also because the dummies are highly correlated (thetrachoric correlation of -1).

I think the best possible solution would be some very specialized imputation for these covariates that accommodates all the information. You can also consider, modeling the covariates as categorical, model the between part as well, abandoning tinterval, switching to RDSEM which is safer when it comes to missing covariates. These methods all have merits and issues and it is hard for me to give a single method without thoroughly looking at your application. These two papers might help.



To address your point 2) however ... with that model you have correctly identified the problem ... the missing values will be imputed at random from the mean which is not good in your case. The imputed values will not be stable, will not be binary, and will not behave like dummies, i.e.,
pred1 + pred2 will not be 0 or 1.
 Jana Holtmann posted on Wednesday, February 27, 2019 - 3:19 am
Thank you Tihomir!

One last question: Is there any way to save the dataset with the inserted missing values that is generated by using the tinterval command ?
 Tihomir Asparouhov posted on Wednesday, February 27, 2019 - 6:02 pm
The command is

IMPUTE = pred1 pred2 ...;
SAVE = name*.dat;

You can use it in combination with fbiter=100; to start the saving as soon as possible (so the first 100 iterations you can't save). Each MCMC iteration is saved in a separate file.
 Sebastian Castro posted on Wednesday, November 27, 2019 - 7:45 am
Dear Mplus team,

I am trying to fit a DSEM model, which includes two dependent variables in the within level ( y and x). Moreover, I have a covariate (z) at the between level. Is it possible to predict y on x at the between level and furthermore include the interaction between x and z?

My idea would be to do somehting like this:

sy | y ON y&1;
sx | x ON x&1;

y ON z;
y ON x;
xz | x XWITH z;
y ON xz;

Would this work?
Would be a problem if x is a categorical variable?

Thanks in advance
 Tihomir Asparouhov posted on Wednesday, November 27, 2019 - 9:22 am
It will not work because the two features XWITH and DSEM are not available in the same model currently. The best option available in Mplus is to use "observed centering" to form the interaction. You can modify the model as follows.

variable: usevar=y x z xc xz;
define: xc=cluster_mean(x); xz=x*z;
sy | y ON y&1;
sx | x ON x&1;
y ON x z xz;

It is not a problem if X is a categorical variable but you must declare it as such.
 Ashley posted on Tuesday, August 11, 2020 - 5:02 pm
Dear Mplus team,

I am conducting a DSEM model using twice-daily diary data, and am examining how minutes spent co-ruminating in person, over text, over social media, or on the phone predicts negative affect at the following time point. I would like to test whether sex moderates the effect of each form of co-rumination on later negative affect. Is the below input correct?

usevariables are ID Mins_Inperson Mins_Texting Mins_Socialmedia Mins_Overphone NegAff Sex_dummy;

between = Sex_dummy;
lagged = Mins_Inperson(1) Mins_Texting(1) Mins_Socialmedia(1) Mins_Overphone(1) NegAff(1);
tinterval = Prompt_Final(1);

type is twolevel random;
estimator = BAYES;
Processor = 2;
BITERATIONS = 100000(2000);

s_nn | NegAff ON NegAff&1;
s_ni | NegAff ON Mins_Inperson&1;
s_nt | NegAff ON Mins_Texting&1;
s_ns | NegAff ON Mins_Socialmedia&1;
s_no | NegAff ON Mins_Overphone&1;

s_nn-s_no ON sex_dummy;
Mins_Inperson Mins_Texting Mins_Socialmedia Mins_Overphone NegAff s_nn-s_no
WITH Mins_Inperson Mins_Texting Mins_Socialmedia Mins_Overphone NegAff s_nn-s_no;

output: tech1 tech8;
 Bengt O. Muthen posted on Wednesday, August 12, 2020 - 5:45 pm
I recommend adding ARs for your 4 minutes predictors. Have them not be random for simplicity.
 Katerina Rnic posted on Thursday, August 13, 2020 - 1:20 pm
Thanks very much for your advice Dr. Muthen. Have I implemented your suggestion correctly in the below syntax?

usevariables are Mins_Inperson Mins_Texting Mins_Socialmedia
Mins_Overphone NegAff;

lagged = Mins_Inperson(1) Mins_Texting(1) Mins_Socialmedia(1) Mins_Overphone(1) NegAff(1);
tinterval = Prompt_FINAL(1);

type is twolevel random;
estimator = Bayes;
Processor = 2;
BITERATIONS  = 100000 (2000);

Mins_Inperson ON Mins_Inperson&1;
Mins_Texting ON Mins_Texting&1;
Mins_Socialmedia ON Mins_Socialmedia&1;
Mins_Overphone ON Mins_Overphone&1;
s_nn | NegAff ON NegAff&1;
s_ni | NegAff ON Mins_Inperson&1;
s_nt | NegAff ON Mins_Texting&1;
s_ns | NegAff ON Mins_Socialmedia&1;
s_no | NegAff ON Mins_Overphone&1;

Mins_Inperson Mins_Texting Mins_Socialmedia Mins_Overphone NegAff s_nn-s_no
WITH Mins_Inperson Mins_Texting Mins_Socialmedia Mins_Overphone NegAff s_nn-s_no;

output: tech1 tech8;
 Bengt O. Muthen posted on Thursday, August 13, 2020 - 6:15 pm
Yes, this looks right.

To make it faster, I recommend:

Proc = 8;

And as a first step, use

Biterations = (1000);
 Katerina Rnic posted on Friday, August 14, 2020 - 12:17 pm
Thank you very much for your help Dr. Muthen!
 Peter Hilpert posted on Monday, August 24, 2020 - 12:16 pm
Dear MPlus Team,

Is there a way to compute a cross-level interaction? Thus, the trait emotion affects the lags between the states?

I would assume that emolis emosha are representing the traits on the between level - but that does not seem to be the case:

s1 | emolis ON emolis&1;
s2 | emosha ON emosha&1;
s12 | emolis ON emosha&1;
s21 | emosha ON emolis&1;

s1 s2 s12 s21 ON emolis emosha;
s1 s2 s12 s21 WITH s1 s2 s12 s21;
emolis WITH emosha;

If I try to specify, I get an error message:
In the MODEL command, the following variable is an x-variable on the BETWEEN level and a y-variable on the WITHIN level. This variable will be treated as a y-variable on both levels: EMOLIS (and the same for emosha)

How can I define the trait on the between level to model the interactions with s12 and s21?

 Bengt O. Muthen posted on Monday, August 24, 2020 - 4:54 pm
The script is correct for what you want to do and the message can be ignored (it is simply giving information).
Back to top
Add Your Message Here
Username: Posting Information:
This is a public posting area. Enter your username and password if you have an account. Otherwise, enter your full name as your username and leave the password blank. Your e-mail address is optional.
Options: Enable HTML code in message
Automatically activate URLs in message