Using define with widetolong PreviousNext
Mplus Discussion > Multilevel Data/Complex Sample >
 Alain Girard posted on Tuesday, June 12, 2012 - 11:57 am
I have a file in wide format (twins data) and i want to analysis in long format.

I use:
data widetolong:
wide = x1 x2 | y1 y2 | z1 z2;
long = x | y | z;
idvariable = fam;
repetition = pid;

names = x1 x2 y1 y2 z1 z2 fam;
usevariable = x y z;

I want to compute the interaction k=x*z.

I try


And i recive the error message that k1 and k2 don't exist.

I add k1 and k2 in the wide statement and k in the wide statement. I recive the same error message.

I add k1, k2 and k in the usevariable statement. The model was estimated but it also compute means and variance for k1 and k2.

I realy confuse... the analysis was in the long format but k1 and k2 was in wide format.

I probably doing something wrong

How can i compute the interaction ?

Alain Girard
 Linda K. Muthen posted on Tuesday, June 12, 2012 - 7:07 pm
Try the following:

data widetolong:
wide = x1 x2 | y1 y2 | z1 z2 | k1 k2;
long = x | y | z | k;
idvariable = fam;
repetition = pid;

names = x1 x2 y1 y2 z1 z2 fam;
usevariable = k1 k2 x y z k;
Auxiliary = k1 k2;

 Katharine Buek posted on Tuesday, February 13, 2018 - 11:08 am
Hi there, I'm trying to do a repeated measures model that is not two-level like in example 9.16, but rather it's crossed. Meaning, I have six time points for each person (time), but those time points consist of fall and spring measures. I want to add spring (set at 1 or 0 for each time point) as one of the fixed effects in my model. I also want to include an interaction for time and spring in the model. Can you tell me how to set up the code for this??

WIDE = y1-y6 spring1-spring6;
LONG = y | spring;
IDVARIABLE = person;
REPETITION = time spring;

VARIABLE: NAMES ARE y1-y6 spring1-spring6;
USEVARIABLE = y spring person time;
CLUSTER = person;
WITHIN = time spring;

MODEL: ?????
 Bengt O. Muthen posted on Tuesday, February 13, 2018 - 6:02 pm
I don't see why this would be a crossed situation.
 Katharine Buek posted on Tuesday, February 13, 2018 - 6:12 pm
Well because we believe there is a within-year effect as well as across all years. We want to capture the variation that occurs between fall and spring each year as well as the year to year variation, and the interaction between the two.
 Tihomir Asparouhov posted on Thursday, February 15, 2018 - 11:04 am
Something like that could work

i s | y1@0 y2@1 y3@2 y4@3 y5@4 y6@5;
spring by y1@1 y3@1 y5@1;

Take a look at User's Guide Chapter 6 for more ideas.
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