-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmplus.qmd
1168 lines (889 loc) · 44.7 KB
/
mplus.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Using Mplus"
output:
html_document:
toc: true
bibliography: references.bib
---
For Mplus [@Mplus8] to work properly, make sure that you save the input file with the model specification (*example.inp*) in the same folder as the data (*example.dat*). You can download the simulated example datasets [here](https://github.com/jeroendmulder/RI-CLPM/tree/master/data). Mplus includes defaults, like that:
* observed and latent exogenous variables are correlated, and
* residuals of observed and latent outcome variables (which do not predict anything) in a path model are correlated.
These defaults are included to make the specification of many standard SEM models easier, but they are not always useful in the current modeling context. Therefore, we use the command `ANALYSIS: MODEL = NOCOV;` to overrule these defaults for the covariances and set all of them to zero.
::: {.callout-tip title="Mplus residual language" appearance="simple"}
From Mplus version 8.7 onward, the Residual Structural Equation Modeling (RSEM) capabilities have been expanded [@asparouhov_residual_2021]. This allows for considerably simpler model syntax for the RI-CLPM using the `^` command. You can find Mplus syntax using this alternative hats-notation for the basic RI-CLPM (both with and without constraints over time) in the [Residual syntax](https://jeroendmulder.github.io/RI-CLPM/mplus.html#Residual_syntax) section.
:::
# The RI-CLPM
To specify the RI-CLPM we need four parts.
* A *between* part, consisting of the random intercepts. It is specified using the `BY` command, `RIx BY x1@1 x2@1 ...;`, where `@1` fixes the factor loading to one.
* A *within* part, consisting of within-unit fluctuations. It is also specified using the `BY` command, `wx1 BY x1; wx2 BY x2; ...`. We do not have to constrain the factor loading to 1, as this is already the default in Mplus for the factor loading of the first indicator of a latent variable. However, we do need to constrain the measurement error variances to zero, as Mplus will include them by default when we use the `BY` statement. We do this by including `x1@0 x2@0 x3@0 x4@0 x5@0;` where `@0` fixes the measurement error variances to zero, which is the same as saying there is no measurement error.
* The *lagged regressions* between the within-unit components, using `wx2 ON wx1 wy1; wx3 ON wx2 wy2; ...`.
* Relevant *covariances* in both the between and within part. In the within part the components at wave 1, and their residuals at waves 2 and further are correlated within each wave, using `wx1 WITH wy1; wx2 WITH wy2;...`. For the between part we have to specify that the random intercepts are correlated using `RIx WITH RIy;`.
::: {.panel-tabset}
## Basic model
The syntax for specifying the basic RI-CLPM is given below.
```default
TITLE: The basic RI-CLPM, 5 waves.
DATA: FILE = RICLPM.dat;
VARIABLE: NAMES = x1-x5 y1-y5;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Estimate lagged effects between within-person centered variables
wx2 wy2 ON wx1 wy1;
wx3 wy3 ON wx2 wy2;
wx4 wy4 ON wx3 wy3;
wx5 wy5 ON wx4 wy4;
! Estimate covariance between random intercepts
RIx WITH RIy;
! Estimate covariance between within-person components at first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations)
wx2 WITH wy2;
wx3 WITH wy3;
wx4 WITH wy4;
wx5 WITH wy5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## Constraints over time
Imposing constraints to the model can be achieved by giving labels to parameters and using the same label for parameters that you want to constrain to be equal. A label is specified by adding `(label)` after a parameter. Below we specify a RI-CLPM with the following constraints:
* fixed auto-regressive and cross-lagged relations over time, `(a b c d)`,
* time-invariant (residual) (co-)variances in the within-person part `(cov)`, `(vx)`, and `(vy)`, and
* constrained grand means over time, `(mx)` and `(my)`.
```default
TITLE: The basic RI-CLPM, 5 waves.
Constrain the grand means, (residual) variances, and
lagged effects over time.
DATA: FILE = RICLPM.dat;
VARIABLE: NAMES = x1-x5 y1-y5;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Estimate lagged effects between within-person centered variables
wx2 wy2 ON wx1 wy1 (a b c d);
wx3 wy3 ON wx2 wy2 (a b c d);
wx4 wy4 ON wx3 wy3 (a b c d);
wx5 wy5 ON wx4 wy4 (a b c d);
! Estimate covariance between random intercepts
RIx WITH RIy;
! Estimate covariance between within-person components at the first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations) and constrain these and residual variances to be
! invariant over time
wx2 WITH wy2 (cov); wx2 (vx); wy2 (vy);
wx3 WITH wy3 (cov); wx3 (vx); wy3 (vy);
wx4 WITH wy4 (cov); wx4 (vx); wy4 (vy);
wx5 WITH wy5 (cov); wx5 (vx); wy5 (vy);
! Constrain grand means to be invariant over time
[x1 x2 x3 x4 x5] (mx);
[y1 y2 y3 y4 y5] (my);
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## Constrain *standardized* lagged effects
Rather than imposing constraints on the unstandardized auto-regressive and cross-lagged relations over time, we can impose constraints on the standardized lagged effects, as explained in the [FAQ](https://jeroendmulder.github.io/RI-CLPM/faq.html#Standardization). Compared to the basic model, there are multiple changes to the syntax. First, we freely estimate the factor loadings that link the observed variables to the within-components, rather than fixing them to 1:
```default
! Create within-components with freely estimated factor loadings
wx1 BY x1*;
wx2 BY x2*;
wx3 BY x3*;
wx4 BY x4*;
wx5 BY x5*;
wy1 BY y1*;
wy2 BY y2*;
wy3 BY y3*;
wy4 BY y4*;
wy5 BY y5*;
```
Second, we set the variances of within-components at first wave to 1, and label the covariance (now also the correlation) between them:
```default
! Set variances of within-components at first wave to 1
wx1@1 wy1@1;
! Estimate correlation between within-components at first wave
wx1 WITH wy1 (cor1);
```
Third, we give the residual variance and covariances between the within-component each a unique label:
```default
wx2 WITH wy2 (rcov2); wx2 (rvx2); wy2 (rvy2);
wx3 WITH wy3 (rcov3); wx3 (rvx3); wy3 (rvy3);
wx4 WITH wy4 (rcov4); wx4 (rvx4); wy4 (rvy4);
wx5 WITH wy5 (rcov5); wx5 (rvx5); wy5 (rvy5);
```
Finally, we compute the correlations between the within-components *themselves* at each wave, and then constrain the residual variances to ensure that the total variance of each within-component equals 1. This is done in the `MODEL CONSTRAINT` command:
```default
MODEL CONSTRAINT:
! Compute correlations of within-components at each wave
NEW(cor2);
NEW(cor3);
NEW(cor4);
cor2 = a*c + b*d + a*d*cor1 + b*c*cor1 + rcov2;
cor3 = a*c + b*d + a*d*cor2 + b*c*cor2 + rcov3;
cor4 = a*c + b*d + a*d*cor3 + b*c*cor3 + rcov4;
! Contrain residual variances of within-components such that variance of each
! within-component equals 1
rvx2 = 1 - (a*a + b*b + 2*a*b*cor1);
rvy2 = 1 - (c*c + d*d + 2*c*d*cor1);
rvx3 = 1 - (a*a + b*b + 2*a*b*cor2);
rvy3 = 1 - (c*c + d*d + 2*c*d*cor2);
rvx4 = 1 - (a*a + b*b + 2*a*b*cor3);
rvy4 = 1 - (c*c + d*d + 2*c*d*cor3);
rvx5 = 1 - (a*a + b*b + 2*a*b*cor4);
rvy5 = 1 - (c*c + d*d + 2*c*d*cor4);
```
:::
# Extension 1: Including time-invariant predictors and outcomes
Use the tabs below to navigate to the model specification of the RI-CLPM with
* a time-invariant predictor $z_{1}$ of the observed variables ($z_{1}$ $\rightarrow$ observed),
* a time-invariant predictor $z_{1}$ of the random intercepts ($z_{1}$ $\rightarrow$ RIs),
* random intercepts predicting a time-invariant outcome $z_{2}$ (RIs $\rightarrow$ $z_{2}$), or
* within components predicting a time-invariant outcome $z_{2}$ (within $\rightarrow$ $z_{2}$).
::: {.panel-tabset}
## $z_{1}$ $\rightarrow$ observed
Below you can find the syntax for a RI-CLPM with 5 waves and a time-invariant predictor $z_{1}$ for the observed variables. The effect of $z_{1}$ on the observed variables is constrained to be the same across waves.
```default
TITLE: RI-CLPM, 5 waves, including a time-invariant predictor for
the observed variables.
DATA: FILE = RICLPM-Z.dat;
VARIABLE: NAMES = x1-x5 y1-y5 z2 z1;
USEVARIABLES = x1-y5 z1;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Estimate covariance between random intercepts
RIx WITH RIy;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Regression of observed variables on z1 (unconstrained)
x1-x5 ON z1 (s1);
y1-y5 ON z1 (s2);
! Estimate lagged effects between within-person centered variables
wx2 wy2 ON wx1 wy1;
wx3 wy3 ON wx2 wy2;
wx4 wy4 ON wx3 wy3;
wx5 wy5 ON wx4 wy4;
! Estimate covariance between within-person components at first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations)
wx2 WITH wy2;
wx3 WITH wy3;
wx4 WITH wy4;
wx5 WITH wy5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## $z_{1}$ $\rightarrow$ RIs
Below you can find the syntax for a RI-CLPM with 5 waves and a time-invariant predictor $z_{1}$ for the random intercepts.
```default
TITLE: RI-CLPM, 5 waves, including a time-invariant predictor for
the random intercepts.
DATA: FILE = RICLPM-Z.dat;
VARIABLE: NAMES = x1-x5 y1-y5 z2 z1;
USEVARIABLES = x1-y5 z1;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Estimate covariance between random intercepts
RIx WITH RIy;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Regression of random intercepts on z1
RIx RIy ON z1;
! Estimate lagged effects between within-person centered variables
wx2 wy2 ON wx1 wy1;
wx3 wy3 ON wx2 wy2;
wx4 wy4 ON wx3 wy3;
wx5 wy5 ON wx4 wy4;
! Estimate covariance between within-person components at first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations)
wx2 WITH wy2;
wx3 WITH wy3;
wx4 WITH wy4;
wx5 WITH wy5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## RIs $\rightarrow$ $z_{2}$
Below you can find the syntax for a RI-CLPM with 5 waves and the random intercepts predicting the time-invariant outcome $z_{2}$.
```default
TITLE: RI-CLPM, 5 waves.
Time-invariant predictor z1 for observed variables (constrained).
Between components predicting time-invariant outcome z2.
DATA: FILE = RICLPM-Z.dat;
VARIABLE: NAMES = x1-x5 y1-y5 z2 z1;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Estimate covariance between random intercepts
RIx WITH RIy;
! Regres distal outcome on random intercepts
z2 ON RIx RIy;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Regression of observed variables on z1 (constrained)
x1-x5 ON z1 (s1);
y1-y5 ON z1 (s2);
! Estimate lagged effects between within-person centered variables
wx2 wy2 ON wx1 wy1;
wx3 wy3 ON wx2 wy2;
wx4 wy4 ON wx3 wy3;
wx5 wy5 ON wx4 wy4;
! Estimate covariance between within-person components at first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations)
wx2 WITH wy2;
wx3 WITH wy3;
wx4 WITH wy4;
wx5 WITH wy5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## within $\rightarrow$ $z_{2}$
Below you can find the syntax for a RI-CLPM with 5 waves and the within components predicting the time-invariant outcome $z_{2}$.
```default
TITLE: RI-CLPM, 5 waves
Time-invariant predictor z1 for observed variables (constrained).
Within components predicting time-invariant outcome z2.
DATA: FILE = RICLPM-Z.dat;
VARIABLE: NAMES = x1-x5 y1-y5 z2 z1;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between-components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Estimate covariance between random intercepts
RIx WITH RIy;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Regres distal outcome on within components
z2 ON wx1-wx5 wy1-wy5;
! Regression of observed variables on z1 (constrained)
x1-x5 ON z1 (s1);
y1-y5 ON z1 (s2);
! Estimate lagged effects between within-person centered variables
wx2 wy2 ON wx1 wy1;
wx3 wy3 ON wx2 wy2;
wx4 wy4 ON wx3 wy3;
wx5 wy5 ON wx4 wy4;
! Estimate covariance between within-person components at first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations)
wx2 WITH wy2;
wx3 WITH wy3;
wx4 WITH wy4;
wx5 WITH wy5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
:::
# Extension 2: Multiple group
Use the tabs below to navigate to the model specification of the basic multiple-group model, or the model with constrained lagged parameters (and intercepts across groups).
To specify a multiple group RI-CLPM, we need to overrule some of the defaults that Mplus will impose and that are associated with multiple group factor analysis. The reason for this is that when we use the `BY` statement in combination with multiple groups, Mplus will automatically impose the defaults that are associated with strong factorial invariance [@meredith_measurement_1993]. These defaults are:
* equal factor loadings across the groups,
* equal intercepts for the observed variables across the groups, and
* free latent means in the second (and subsequent) group(s).
In the context of a multiple-group RI-CLPM, the first constraint is not an issue as all the factor loadings are supposed to be constrained to one in both groups. However, the second constraint on the intercepts and the freeing of the latent means in the second group are not sensible here. There will be fewer observed variables than latent variables defined with a `BY` statement (i.e., a within-unit part for each observed variable, plus a random intercept for each variable); as a result, we would try to estimate more means than that there were observed. Such a model is unidentified. We should therefore overrule the defaults associated with the mean structure. We do this by adding for the second group `[x1 x2 ...];` which frees the intercepts for the observed variables in the second group. Additionally, we include `[wx1@0 wx2@0 ... ]; [RIx@0];` for the second group, which ensures all latent means are fixed to zero.
::: {.panel-tabset}
## The basic model
Below you can find the code for a multiple group RI-CLPM with 5 waves.
```default
TITLE: Multiple group RI-CLPM, 5 waves.
Overruling the Mplus multiple group factor analysis defaults.
DATA: FILE = RICLPM-MG.dat;
VARIABLE: NAMES = x1-x5 y1-y5 GROUP;
GROUPING = GROUP (1=G1 2=G2);
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Estimate lagged effects between within-person centered variables
wx2 wy2 ON wx1 wy1;
wx3 wy3 ON wx2 wy2;
wx4 wy4 ON wx3 wy3;
wx5 wy5 ON wx4 wy4;
! Estimate covariance between random intercepts
RIx WITH RIy;
! Estimate covariance between within-person components at first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations)
wx2 WITH wy2;
wx3 WITH wy3;
wx4 WITH wy4;
wx5 WITH wy5;
MODEL G2: ! Overrule multiple group factor analysis default of equal intercepts
! across groups
[x1-y5];
! Overrule multiple group factor analysis default of free latent means
! in second group
[wx1-wy5@0];
[RIx@0 RIy@0];
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## Constrained lagged-parameters
Below you can find the code for a multiple group RI-CLPM, 5 waves. The lagged-parameters are constrained to be equal over time.
```default
TITLE: Multiple group RI-CLPM, 5 waves, with equal lagged parameters
across groups.
Overruling the Mplus multiple group factor analysis defaults.
DATA: FILE = RICLPM-MG.dat;
VARIABLE: NAMES = x1-x5 y1-y5 GROUP;
GROUPING = GROUP (1=G1 2=G2);
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: ! Create between components (random intercepts)
RIx BY x1@1 x2@1 x3@1 x4@1 x5@1;
RIy BY y1@1 y2@1 y3@1 y4@1 y5@1;
! Create within-person centered variables
wx1 BY x1@1;
wx2 BY x2@1;
wx3 BY x3@1;
wx4 BY x4@1;
wx5 BY x5@1;
wy1 BY y1@1;
wy2 BY y2@1;
wy3 BY y3@1;
wy4 BY y4@1;
wy5 BY y5@1;
! Constrain measurement error variances to 0
x1-y5@0;
! Estimate lagged effects between within-person centered variables
! (constrained across groups)
wx2 wy2 ON wx1 wy1 (a1 b1 c1 d1);
wx3 wy3 ON wx2 wy2 (a2 b2 c2 d2);
wx4 wy4 ON wx3 wy3 (a3 b3 c3 d3);
wx5 wy5 ON wx4 wy4 (a4 b4 c4 d4);
! Estimate covariance between random intercepts
RIx WITH RIy;
! Estimate covariance between within-person components at first wave
wx1 WITH wy1;
! Estimate covariances between residuals of within-person components
! (i.e., innovations)
wx2 WITH wy2;
wx3 WITH wy3;
wx4 WITH wy4;
wx5 WITH wy5;
MODEL G2: ! Overrule multiple group factor analysis default of equal intercepts
! across groups
[x1-y5];
! Overrule multiple group factor analysis default of free latent means
! in second group
[wx1-wy5@0];
[RIx@0 RIy@0];
! Estimate lagged effects between within-person centered variables
! (constrained across groups)
wx2 wy2 ON wx1 wy1 (a1 b1 c1 d1);
wx3 wy3 ON wx2 wy2 (a2 b2 c2 d2);
wx4 wy4 ON wx3 wy3 (a3 b3 c3 d3);
wx5 wy5 ON wx4 wy4 (a4 b4 c4 d4);
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
:::
# Extension 3: Multiple indicators
Use the tabs below to navigate to the model specification of a multiple indicator RI-CLPM, 5 waves and 3 indicators for each variable at each wave. The five steps correspond to:
* the configural model (Step 1),
* weak factorial invariance (Step 2),
* strong factorial invariance (Step 3),
* strong factorial invariance with factor loadings equal to the within-person factor loadings (Extra), and
* the latent RI-CLPM (Step 4).
::: {.panel-tabset}
## Step 1
When we have three indicators $X$, measured at five waves, we specify three random intercepts to capture the trait-like part of each indicator, that is, `RIX1 BY x11@1 x21@1 ...;`, `RIX2 BY x12@1 x22@1 ...;`, and `RIX3 BY x13@1 x23@1 ...;`. In addition, we specify five within-unit components that capture the state-like part at each wave, using `WFX1 BY x11 x12 x13; WFX2 BY x21 x22 x23; ...`.
At the latent within-unit level, we specify the dynamic model in Mplus using` WFX2 ON WFY1 WFX1; WFX3 ON WFY2 WFX2; ...`. In addition, we allow the within-person factors at the first wave, and their residuals at subsequent waves to be correlated within each wave, `WFX1 WITH WFY1; WFX2 WITH WFY2; ...`. The six random intercepts are allowed to be freely correlated with each other through `RIX1-RIY3 WITH RIX1-RIY3;`.
```default
TITLE: Multiple indicator RI-CLPM, 5 waves, with 3 indicators for
each variable at each wave (30 observed variables) and with
random intercepts for each indicator separately.
DATA: FILE = RICLPM-MI.dat;
VARIABLE: NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33
x41 x42 x43 x51 x52 x53 y11 y12 y13
y21 y22 y23 y31 y32 y33 y41 y42 y43
y51 y52 y53;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL:
!!!!!!!!!!!!!!!!
! BETWEEN PART !
!!!!!!!!!!!!!!!!
! Create between factors (random intercepts) for each indicator separately
RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;
! Add covariances between all RIs
RIX1-RIY3 WITH RIX1-RIY3;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: MEASUREMENT MODEL !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Due to having a random intercept per indicator, the measurement model
! is only on the within part of the measurements
! Factor models for X at 5 waves
WFX1 BY x11-x13;
WFX2 BY x21-x23;
WFX3 BY x31-x33;
WFX4 BY x41-x43;
WFX5 BY x51-x53;
! Factor models for Y at 5 waves
WFY1 BY y11-y13;
WFY2 BY y21-y23;
WFY3 BY y31-y33;
WFY4 BY y41-y43;
WFY5 BY y51-y53;
!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: DYNAMICS !
!!!!!!!!!!!!!!!!!!!!!!!!!
! Specify lagged effects between within-person centered latent variables
WFX2 WFY2 ON WFX1 WFY1;
WFX3 WFY3 ON WFX2 WFY2;
WFX4 WFY4 ON WFX3 WFY3;
WFX5 WFY5 ON WFX4 WFY4;
! Estimate correlations within same wave
WFX1 WITH WFY1;
WFX2 WITH WFY2;
WFX3 WITH WFY3;
WFX4 WITH WFY4;
WFX5 WITH WFY5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## Step 2
In the second step, we constrain the factor loadings to be invariant over time using the labels `(a b)` and `(c d)`. We only need to constrain the second and third loading of the factor models at each wave (i.e., `WFX1 BY x12 x13`, `WFX2 BY x22 x23`, etc.), because the first loading (i.e., `WFX1 BY x11` and `WFX2 BY x21`, etc.) is constrained to 1 by default, and is therefore already invariant over time.
```default
TITLE: Multiple indicator RI-CLPM, 5 waves, with 3 indicators for
each variable at each wave (30 observed variables) and with
random intercepts for each indicator separately. Fitting a model
with constraints to ensure weak factorial invariance.
DATA: FILE = RICLPM-MI.dat;
VARIABLE: NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33
x41 x42 x43 x51 x52 x53 y11 y12 y13
y21 y22 y23 y31 y32 y33 y41 y42 y43
y51 y52 y53;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: !!!!!!!!!!!!!!!!
! BETWEEN PART !
!!!!!!!!!!!!!!!!
! Create between factors (random intercepts) for each indicator separately
RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;
! Add covariances between all RIs
RIX1-RIY3 WITH RIX1-RIY3;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: MEASUREMENT MODEL !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Due to having a random intercept per indicator, the measurement model
! is only on the within part of the measurements
! Factor models for X at 5 waves (constrained)
WFX1 BY x11-x13 (a b c);
WFX2 BY x21-x23 (a b c);
WFX3 BY x31-x33 (a b c);
WFX4 BY x41-x43 (a b c);
WFX5 BY x51-x53 (a b c);
! Factor models for Y at 5 waves (constrained)
WFY1 BY y11-y13 (d e f);
WFY2 BY y21-y23 (d e f);
WFY3 BY y31-y33 (d e f);
WFY4 BY y41-y43 (d e f);
WFY5 BY y51-y53 (d e f);
!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: DYNAMICS !
!!!!!!!!!!!!!!!!!!!!!!!!!
! Specify lagged effects between within-person centered latent variables
WFX2 WFY2 ON WFX1 WFY1;
WFX3 WFY3 ON WFX2 WFY2;
WFX4 WFY4 ON WFX3 WFY3;
WFX5 WFY5 ON WFX4 WFY4;
! Estimate correlations within same wave
WFX1 WITH WFY1;
WFX2 WITH WFY2;
WFX3 WITH WFY3;
WFX4 WITH WFY4;
WFX5 WITH WFY5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## Step 3
In Mplus, the model for strong factorial invariance can be specified as the previous model with the following addition `[x11 x12 x13] (g h i);[x21 x22 x23] (g h i); ...` which ensures that the intercepts of the observed variables are constrained over time, and `[WFX2* WFX3* ... ];` which implies that the latent means at each wave can differ from zero.
```default
TITLE: Multiple indicator RI-CLPM, 5 waves, with 3 indicators for
each variable at each wave (30 observed variables) and with
random intercepts for each indicator separately. Fitting a model
with constraints to ensure strong factorial invariance.
DATA: FILE = RICLPM-MI.dat;
VARIABLE: NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33
x41 x42 x43 x51 x52 x53 y11 y12 y13
y21 y22 y23 y31 y32 y33 y41 y42 y43
y51 y52 y53;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: !!!!!!!!!!!!!!!!
! BETWEEN PART !
!!!!!!!!!!!!!!!!
! Create between factors (random intercepts) for each indicator separately
RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;
! Add covariances between all RIs
RIX1-RIY3 WITH RIX1-RIY3;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: MEASUREMENT MODEL !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Due to having a random intercept per indicator, the measurement model
! is only on the within part of the measurements
! Factor models for X at 5 waves (constrained)
WFX1 BY x11-x13 (a b c);
WFX2 BY x21-x23 (a b c);
WFX3 BY x31-x33 (a b c);
WFX4 BY x41-x43 (a b c);
WFX5 BY x51-x53 (a b c);
! Factor models for Y at 5 waves (constrained)
WFY1 BY y11-y13 (d e f);
WFY2 BY y21-y23 (d e f);
WFY3 BY y31-y33 (d e f);
WFY4 BY y41-y43 (d e f);
WFY5 BY y51-y53 (d e f);
! Constrained intercepts over time (necessary for strong factorial
! invariance; without these constraints we have weak factorial invariance)
[x11 x12 x13] (g h i);
[x21 x22 x23] (g h i);
[x31 x32 x33] (g h i);
[x41 x42 x43] (g h i);
[x51 x52 x53] (g h i);
[y11 y12 y13] (j k l);
[y21 y22 y23] (j k l);
[y31 y32 y33] (j k l);
[y41 y42 y43] (j k l);
[y51 y52 y53] (j k l);
! Free latent means from second wave onward (only do this in combination
! with constraints on intercepts; without these, this is not identified)
[WFX2* WFX3* WFX4* WFX5*];
[WFY2* WFY3* WFY4* WFY5*];
!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: DYNAMICS !
!!!!!!!!!!!!!!!!!!!!!!!!!
! Specify lagged effects between within-person centered latent variables
WFX2 WFY2 ON WFX1 WFY1;
WFX3 WFY3 ON WFX2 WFY2;
WFX4 WFY4 ON WFX3 WFY3;
WFX5 WFY5 ON WFX4 WFY4;
! Estimate correlations within same wave
WFX1 WITH WFY1;
WFX2 WITH WFY2;
WFX3 WITH WFY3;
WFX4 WITH WFY4;
WFX5 WITH WFY5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## Extra
```default
TITLE: Multiple indicator RI-CLPM, 5 waves with 3 indicators for each
variable at each wave (30 observed variables). Fitting a model
with constraints to ensure strong factorial invariance, with a
random intercept for each indicator separately, for which a
factor model is specified, with factor loadings equal to the
within- person factor loadings.
DATA: FILE = RICLPM-MI.dat;
VARIABLE: NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33
x41 x42 x43 x51 x52 x53 y11 y12 y13
y21 y22 y23 y31 y32 y33 y41 y42 y43
y51 y52 y53;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero
MODEL: !!!!!!!!!!!!!!!!
! BETWEEN PART !
!!!!!!!!!!!!!!!!
! Create between factors (random intercepts) for each indicator separately
RIX1 BY x11@1 x21@1 x31@1 x41@1 x51@1;
RIX2 BY x12@1 x22@1 x32@1 x42@1 x52@1;
RIX3 BY x13@1 x23@1 x33@1 x43@1 x53@1;
RIY1 BY y11@1 y21@1 y31@1 y41@1 y51@1;
RIY2 BY y12@1 y22@1 y32@1 y42@1 y52@1;
RIY3 BY y13@1 y23@1 y33@1 y43@1 y53@1;
! Create single random intercept for all X-variables, and another for all
! Y-variables. Constrain factor loading to be identical to within-person
! factor loadings
RIX BY RIX1 RIX2 RIX3 (a b c);
RIY BY RIY1 RIY2 RIY3 (d e f);
! Add covariance between 2nd-order random intercepts
RIX WITH RIY;
! Constrain measurement error variances of 2nd-order factor model to 0
RIX1-RIY3@0;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: MEASUREMENT MODEL !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Due to having a random intercept per indicator, the measurement model
! is only on the within part of the measurements
! Factor models for X at 5 waves
WFX1 BY x11-x13 (a b c);
WFX2 BY x21-x23 (a b c);
WFX3 BY x31-x33 (a b c);
WFX4 BY x41-x43 (a b c);
WFX5 BY x51-x53 (a b c);
! Factor models for Y at 5 waves
WFY1 BY y11-y13 (d e f);
WFY2 BY y21-y23 (d e f);
WFY3 BY y31-y33 (d e f);
WFY4 BY y41-y43 (d e f);
WFY5 BY y51-y53 (d e f);
! Constrained intercepts over time (necessary for strong factorial invariance;
! without these we have weak factorial invariance)
[x11 x12 x13] (g h i);
[x21 x22 x23] (g h i);
[x31 x32 x33] (g h i);
[x41 x42 x43] (g h i);
[x51 x52 x53] (g h i);
[y11 y12 y13] (j k l);
[y21 y22 y23] (j k l);
[y31 y32 y33] (j k l);
[y41 y42 y43] (j k l);
[y51 y52 y53] (j k l);
! Free latent means from second wave onward (only do this in combination with
! constraints on intercepts; without these, this is not identified)
[WFX2* WFX3* WFX4* WFX5*];
[WFY2* WFY3* WFY4* WFY5*];
!!!!!!!!!!!!!!!!!!!!!!!!!
! WITHIN PART: DYNAMICS !
!!!!!!!!!!!!!!!!!!!!!!!!!
! Specify lagged effects between within-person centered latent variables
WFX2 WFY2 ON WFX1 WFY1;
WFX3 WFY3 ON WFX2 WFY2;
WFX4 WFY4 ON WFX3 WFY3;
WFX5 WFY5 ON WFX4 WFY4;
! Estimate correlations within same wave
WFX1 WITH WFY1;
WFX2 WITH WFY2;
WFX3 WITH WFY3;
WFX4 WITH WFY4;
WFX5 WITH WFY5;
OUTPUT: TECH1 STDYX SAMPSTAT CINTERVAL;
```
## Step 4
We have to overrule the default of Mplus to include a term for measurement error when the `BY` statement is used, through `FX1@0 FX2@0 ...;`. The two random intercepts are allowed to be freely correlated with each other, through `RIX WITH RIY;`.
```default
TITLE: Multiple indicator RI-CLPM, 5 waves with 3 indicators for each
variable at each wave (30 observed variables). Fitting a model
with constraints to ensure strong factorial invariance, with
the RI-CLPM at the latent level.
DATA: FILE = RICLPM-MI.dat;
VARIABLE: NAMES = x11 x12 x13 x21 x22 x23 x31 x32 x33
x41 x42 x43 x51 x52 x53 y11 y12 y13
y21 y22 y23 y31 y32 y33 y41 y42 y43
y51 y52 y53;
ANALYSIS: MODEL = NOCOV; ! Sets all default covariances to zero