-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmplus.Rmd
735 lines (559 loc) · 19.8 KB
/
mplus.Rmd
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
---
title: "Mplus"
output:
html_document:
code_folding: show
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
echo = TRUE,
error = TRUE,
comment = "",
class.source = "fold-show")
```
# Overview of `Mplus`
[`Mplus`](https://www.statmodel.com) is software for [structural equation modeling](sem.html).
A summary of the [`Mplus`](https://www.statmodel.com) language syntax is [here](https://www.statmodel.com/language.html) (archived at: https://perma.cc/962G-QUEG).
The [Mplus User's Guide](https://www.statmodel.com/html_ug.shtml) is located [here](https://www.statmodel.com/download/usersguide/MplusUserGuideVer_8.pdf) (archived at: https://perma.cc/W39W-NRGH).
# Prepare Data {#prepareData}
To prepare the data in `R` for use in `Mplus`:
```{r, eval = FALSE}
library("MplusAutomation")
prepareMplusData(
mydata,
file.path(path, "/GitHub/Project_Name/Data/mplusdata.dat"))
```
# Model Example {#example}
```
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!! MPLUS SYNTAX LINES CANNOT EXCEED 90 CHARACTERS;
!!!!! VARIABLE NAMES AND PARAMETER LABELS CANNOT EXCEED 8 CHARACTERS EACH;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
TITLE: Example Mplus Model
DATA:
FILE = "C:/[insert_filepath]/filename.dat";
VARIABLE:
NAMES = ID age x1 x2 x3 x4 x5 x6 y1 y2;
MISSING = .;
USEVARIABLES = ID age x1 x2 x3 x4 x5 x6 y1 y2;
ANALYSIS:
TYPE = COMPLEX;
ESTIMATOR = MLR;
MODEL:
! Factor loadings
latent1 BY x1* x2 x3;
latent2 BY x4* x5 x6;
! Covariances between latent factors
latent1 WITH latent2
! Regression paths
y1 ON latent1 + latent2
y2 ON latent1 + latent 2
! Standardize latent factors: fix means to zero
[latent1@0];
[latent2@0];
! Standardize latent factors: fix variances to one
latent1@1;
latent2@1;
OUTPUT:
STDYX;
TECH1;
TECH4;
SAMPSTAT;
MODINDICES (3);
CINTERVAL;
RESIDUAL;
SAVEDATA:
FILE = "C:/[insert_filepath]/filename.dat";
SAVE = FSCORES;
```
# Model Title {#modelTitle}
```
TITLE: INSERT TITLE HERE
```
# Read Data {#readData}
```
DATA:
FILE = "C:/[insert_filepath]/filename.dat";
```
# Variables {#variables}
## Specify Variables {#specifyVariables}
```
VARIABLE:
NAMES = ID age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID age x1 x2 y1;
CLUSTER = ID;
```
## Categorical Variables {#categoricalVariables}
```
VARIABLE:
NAMES = ID age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID age x1 x2 y1;
CATEGORICAL = x1 x2;
```
## Count Variables {#countVariables}
```
VARIABLE:
NAMES = ID age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID age x1 x2 y1;
COUNT = x1 x2;
```
## Cluster Variable {#clusterVariable}
There are multiple ways of accounting for nested data in [structural equation modeling](sem.html).
One way to account for nested data is to use multilevel structural equation modeling.
Another approach is to use a cluster variable to generate cluster-robust standard errors of parameters.
To use a cluster variable, specify `CLUSTER` under the `VARIABLE` section, and specify `TYPE = COMPLEX` under the `ANALYSIS` section:
```
VARIABLE:
NAMES = ID age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID age x1 x2 y1;
CLUSTER = ID;
ANALYSIS:
TYPE = COMPLEX;
```
## Individually Varying Times of Observation {#tScores}
```
VARIABLE:
NAMES = ID age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID age x1 x2 y1;
TSCORES = age;
```
## Auxiliary Variables {#auxiliaryVariables}
```
VARIABLE:
NAMES = ID age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID x1 x2 y1;
AUXILIARY = age;
```
## Sampling Weight Variable {#samplingWeight}
```
VARIABLE:
NAMES = ID wt age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID age x1 x2 y1;
WEIGHT = wt;
```
## Multilevel Variables {#multilevelVariables}
Between- and within-cluster variables:
```
VARIABLE:
NAMES = ID wt age x1 x2 x3 y1;
MISSING = .;
USEVARIABLES = ID age x1 x2 y1;
WITHIN = x1;
BETWEEN = x2;
```
# Analysis {#analysis}
## Analysis Types {#analysisTypes}
- `TYPE = COMPLEX`
- `TYPE = TWOLEVEL`
- `TYPE = EFA`
## Model Estimators {#estimators}
```
ANALYSIS:
ESTIMATOR = MLR;
```
- `MLR`: for likert/continuous data
- `WLSMV`: for ordinal/categorical data
- `BAYES`
## Bootstrap Draws {#bootstrap}
```
BOOTSTRAP = 2000; ! insert number of bootstrap draws
```
## Starts {#starts}
```
STARTS = 20; ! insert number of initial stage starts and number of final stage optimizations
```
## Low Covariance Coverage {#lowCovarianceCoverage}
To estimate a model with low covariance coverage, lower the `COVERAGE` value under the `ANALYSIS` section:
```
ANALYSIS:
COVERAGE = 0;
```
# Exploratory Factor Analysis {#efa}
## Oblique Rotation {#oblique}
```
ANALYSIS:
TYPE = EFA 1 5; ! extract 1-5 factors
ROTATION = GEOMIN;
```
## Orthogonal Rotation {#orthogonal}
```
ANALYSIS:
TYPE = EFA 1 5; ! extract 1-5 factors
ROTATION = VARIMAX;
```
# Bayesian SEM {#bayesian}
Other settings you can specify under the "ANALYSIS" section include:
```
ANALYSIS:
ESTIMATOR = BAYES;
BCONVERGENCE = .05; ! value of the Gelman-Rubin convergence criterion; ! default is .05; van de Schoot et al. (2014) recommend .01
BITERATIONS = a (b); ! a = maximum, b = minumum number of iterations for each MCMC chain
CHAINS = 4; ! number of chains
PROCESSORS = 4; ! number of computer processors to use
BSEED = 52242; ! set seed for replicability
STVALUES = ml; ! set starting values based on ML estimation
```
You can specify model priors under the "MODEL PRIORS" section.
Other settings you can specify under the "OUTPUT" section include:
```
OUTPUT:
STAND; ! standardized estimates
TECH1; ! model priors
TECH8; ! potential scale reduction (PSR); to evaluate convergence (should be near one)
CINTERVAL; ! posterior predictive intervals (credible intervals)
```
Other settings you can specify under the "PLOT" section include:
```
PLOT:
TYPE = PLOT3; ! trace plots, histogram, and kernel density
```
# Model {#model}
## Define Latent Variables {#latentVariables}
```
MODEL:
latent1 BY x1 x2 x3;
```
## Regression Paths {#regressionPaths}
Regress outcome variable on predictor variable(s):
```
MODEL:
y1 ON x1 x2;
```
## Covariance Paths {#covariancePaths}
```
MODEL:
x1 WITH x2;
```
## Indirect Effects {#indirectEffects}
```
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 1000;
MODEL:
MODEL INDIRECT:
y IND x;
OUTPUT:
STAND;
CINTERVAL (BOOTSTRAP); !percentile boostrap CI
CINTERVAL (BCBOOTSTRAP); !bias-corrected boostrap CI
```
## Means/Intercepts {#means}
Freely estimate:
```
MODEL:
[x1];
```
Fix to zero:
```
MODEL:
[x1@0];
```
## Variances {#variances}
Freely estimate:
```
MODEL:
x1;
```
Fix to one:
```
MODEL:
x1@1;
```
## Parameter Label {#parameterLabel}
To specify a parameter label, provide the label in parentheses after the parameter:
```
MODEL:
latent1 BY x1* x2 x3 (load1-3);
latent2 BY x4* x5 (load5) x6;
```
## Multigroup Model {#multigroup}
```
VARIABLE:
NAMES = group x1 x2 x3 y1;
GROUPING = group (0=boys, 1=girls);
MISSING = .;
USEVARIABLES = group x1 x2 x3 y1;
MODEL:
Model boys:
latent BY x1* x2 x3;
[latent@0];
latent@1;
y ~ latent;
Model girls:
latent BY x1* x2 x3;
[latent@0];
latent@1;
y ~ latent;
```
## Multigroup Measurement Invariance {#measurementInvariance}
### Configural Invariance {#configuralInvariance}
```
VARIABLE:
NAMES = group x1 x2 x3 y1;
GROUPING = group (0=boys, 1=girls);
MISSING = .;
USEVARIABLES = group x1 x2 x3;
MODEL:
Model boys:
latent BY x1* x2 x3;
[latent@0];
latent@1;
Model girls:
latent BY x1* x2 x3;
[latent@0];
latent@1;
```
### Metric (Weak Factorial) Invariance {#metricInvariance}
```
VARIABLE:
NAMES = group x1 x2 x3 y1;
GROUPING = group (0=boys, 1=girls);
MISSING = .;
USEVARIABLES = group x1 x2 x3;
MODEL:
Model boys:
latent BY x1* (load1); ! constrain factor loading across groups (same parameter label)
latent BY x2* (load2); ! constrain factor loading across groups (same parameter label)
latent BY x3* (load3); ! constrain factor loading across groups (same parameter label)
[latent@0];
latent@1;
Model girls:
latent BY x1* (load1); ! constrain factor loading across groups (same parameter label)
latent BY x2* (load2); ! constrain factor loading across groups (same parameter label)
latent BY x3* (load3); ! constrain factor loading across groups (same parameter label)
[latent@0];
latent@1;
```
### Scalar (Strong Factorial) Invariance {#scalarInvariance}
```
VARIABLE:
NAMES = group x1 x2 x3 y1;
GROUPING = group (0=boys, 1=girls);
MISSING = .;
USEVARIABLES = group x1 x2 x3;
MODEL:
Model boys:
latent BY x1* (load1); ! constrain factor loading across groups (same parameter label)
latent BY x2* (load2); ! constrain factor loading across groups (same parameter label)
latent BY x3* (load3); ! constrain factor loading across groups (same parameter label)
[x1] (int1); ! constrain intercept across groups (same parameter label)
[x2] (int2); ! constrain intercept across groups (same parameter label)
[x3] (int3); ! constrain intercept across groups (same parameter label)
[latent@0];
latent@1;
Model girls:
latent BY x1* (load1); ! constrain factor loading across groups (same parameter label)
latent BY x2* (load2); ! constrain factor loading across groups (same parameter label)
latent BY x3* (load3); ! constrain factor loading across groups (same parameter label)
[x1] (int1); ! constrain intercept across groups (same parameter label)
[x2] (int2); ! constrain intercept across groups (same parameter label)
[x3] (int3); ! constrain intercept across groups (same parameter label)
[latent@0];
latent@1;
```
# Comments {#comments}
```
!This is a comment in Mplus
```
# Setting Parameter Constraints {#parameterConstraints}
## Freeing a Parameter {#freeParameter}
By default, the first loading on a factor is fixed to zero.
You can freely estimate the parameter by adding an asterisk:
```
MODEL:
latent1 BY x1* x2 x3;
```
## Constraing a Parameter {#constrainParameter}
```
MODEL:
latent1 BY x1@1 x2 x3;
[latent1@0];
latent1@1;
```
## Setting Two Parameters to be Equal {#equalParameters}
To set two parameters to be equal, provide the same [parameter label](#parameterLabel) for each parameter.
## Setting Lower and Upper Bounds on a Parameter {#parameterBounds}
To set lower and upper bounds on a parameter, you can assign the parameter a [parameter label](#parameterLabel).
Then, you can assign the constraint to the parameter (via the label) under the `MODEL CONSTRAINT` section.
For example, to constrain a parameter between 0–1,
```
MODEL:
latent1 BY x1* x2 x3 (load3);
MODEL CONSTRAINT:
load3 > 0; load3 < 1;
```
# Output {#output}
```
OUTPUT:
STDYX;
TECH1;
TECH4;
SAMPSTAT;
MODINDICES (ALL); ! specify number in parentheses to print only those mod indices that are above a particular chi-square value
CINTERVAL;
RESIDUAL;
```
# Save Factor Scores {#factorScores}
```
SAVEDATA:
FILE = "C:/[insert_filepath]/filename.dat";
SAVE = FSCORES;
```
# Multiple Imputation {#multipleImputation}
For examples of how to conduct [multiple imputation](multipleImputation.html) in [`Mplus`](https://www.statmodel.com), see [here](multipleImputation.html#mplus).
To run a model on multiply imputed data, use the following:
```
DATA: FILE = "implist.dat"; ! where implist.dat is the name of the *list.dat file saved from the imputation step
TYPE = IMPUTATION;
```
# Run Models in Batch {#runModels}
Run models in batch via `R`:
```{r, eval = FALSE}
library("MplusAutomation")
runModels(
file.path(path, "/GitHub/Project_Name/Analyses/Mplus/"),
recursive = TRUE,
replaceOutfile = "always",
showOutput = TRUE)
```
# Monte Carlo Simulation/Power Analysis {#monteCarlo}
## Single Group Model {#monteCarloSingleGroup}
```
TITLE: Single-Group Monte Carlo Simulation with Ordinal Items and Common Factor;
MONTECARLO:
NAMES = v1-v5; ! variable names
NOBSERVATIONS = 500; ! number of participants in each sample
NREPS = 100000; ! number of samples to create
SEED = 52242; ! random seed
GENERATE = v1-v5 (3 p); ! specify the scale of the DVs; number of thresholds; probit (p)
CATEGORICAL = v1-v5; ! specify the variables that are (ordered) categorical
ANALYSIS:
PROCESSORS = 4 1; ! number of processors; number of threads
ESTIMATOR = WLSMV;
PARAMETERIZATION = THETA;
MODEL POPULATION: ! tell Mplus how to generate the population data; can use asterisks (*) and at symbols (@) interchangeably here, but they differ in the MODEL command (see below); I use the same symbol as in the MODEL command
dep BY v1-v5*.7; ! factor loadings
[dep@0]; ! set factor mean to 0
dep@1; ! set factor variance to 1 (standardize)
[v1$1*0.5] (v1t1); [v1$2*1.0] (v1t2); [v1$3*1.5] (v1t3); ! item thresholds for v1
[v2$1*0.5] (v2t1); [v2$2*1.0] (v2t2); [v2$3*1.5] (v2t3); ! item thresholds for v2
[v3$1*0.5] (v3t1); [v3$2*1.0] (v3t2); [v3$3*1.5] (v3t3); ! item thresholds for v3
[v4$1*0.0] (v4t1); [v4$2*0.5] (v4t2); [v4$3*1.0] (v4t3); ! item thresholds for v4
[v5$1*0.0] (v5t1); [v5$2*0.5] (v5t2); [v5$3*1.0] (v5t3); ! item thresholds for v5
v1-v5@1; ! item residual variances
MODEL: ! tell Mplus to estimate our model; asterisks (*) are free estimates with a starting value; at symbols (@) are fixed estimates
dep BY v1-v5*.7; ! factor loadings
[dep@0]; ! set factor mean to 0
dep@1; ! set factor variance to 1 (standardize)
[v1$1*0.5] (v1t1); [v1$2*1.0] (v1t2); [v1$3*1.5] (v1t3); ! item thresholds for v1
[v2$1*0.5] (v2t1); [v2$2*1.0] (v2t2); [v2$3*1.5] (v2t3); ! item thresholds for v2
[v3$1*0.5] (v3t1); [v3$2*1.0] (v3t2); [v3$3*1.5] (v3t3); ! item thresholds for v3
[v4$1*0.0] (v4t1); [v4$2*0.5] (v4t2); [v4$3*1.0] (v4t3); ! item thresholds for v4
[v5$1*0.0] (v5t1); [v5$2*0.5] (v5t2); [v5$3*1.0] (v5t3); ! item thresholds for v5
v1-v5@1; ! item residual variances
MODEL CONSTRAINT:
NEW (stdt stdt1 stdt2 stdt3 noninvt noninvt1 noninvt2 noninvt3 diff);
stdt1 = (v1t1 + v2t1 + v3t1) / 3;
stdt2 = (v1t2 + v2t2 + v3t2) / 3;
stdt3 = (v1t3 + v2t3 + v3t3) / 3;
noninvt1 = (v4t1 + v5t1) / 2;
noninvt2 = (v4t2 + v5t2) / 2;
noninvt3 = (v4t3 + v5t3) / 2;
stdt = (stdt1 + stdt2 + stdt3) / 3;
noninvt = (noninvt1 + noninvt2 + noninvt3) / 3;
diff = noninvt - stdt;
OUTPUT:
TECH9;
```
## Multi-Group Model {#monteCarloMultigroup}
```
TITLE: Multi-Group Monte Carlo Simulation with Ordinal Items and Common Factor;
MONTECARLO:
NAMES = v1-v5; ! variable names
NGROUPS = 2; ! number of groups
NOBSERVATIONS = 500 300; ! number of participants in each sample
NREPS = 100000; ! number of samples to create
SEED = 52242; ! random seed
GENERATE = v1-v5 (3 p); ! specify the scale of the DVs; number of thresholds; probit (p)
CATEGORICAL = v1-v5; ! specify the variables that are (ordered) categorical
ANALYSIS:
PROCESSORS = 4 1; ! number of processors; number of threads
ESTIMATOR = WLSMV;
PARAMETERIZATION = THETA;
MODEL POPULATION: ! tell Mplus how to generate the population data; can use asterisks (*) and at symbols (@) interchangeably here, but they differ in the MODEL command (see below); I use the same symbol as in the MODEL command
dep BY v1-v5*.7; ! factor loadings
[dep@0]; ! set factor mean to 0
dep@1; ! set factor variance to 1 (standardize)
[v1$1*0.5] (v1t1g1); [v1$2*1.0] (v1t2g1); [v1$3*1.5] (v1t3g1); ! item thresholds for v1
[v2$1*0.5] (v2t1g1); [v2$2*1.0] (v2t2g1); [v2$3*1.5] (v2t3g1); ! item thresholds for v2
[v3$1*0.5] (v3t1g1); [v3$2*1.0] (v3t2g1); [v3$3*1.5] (v3t3g1); ! item thresholds for v3
[v4$1*0.5] (v4t1g1); [v4$2*1.0] (v4t2g1); [v4$3*1.5] (v4t3g1); ! item thresholds for v4
[v5$1*0.5] (v5t1g1); [v5$2*1.0] (v5t2g1); [v5$3*1.5] (v5t3g1); ! item thresholds for v5
v1-v5@1; ! item residual variances
MODEL POPULATION-g2: ! tell Mplus how to generate the population data for group 2; can use asterisks (*) and at symbols (@) interchangeably here, but they differ in the MODEL command (see below); I use the same symbol as in the MODEL command
!dep BY v1-v5*.7; ! factor loadings
![dep@0]; ! set factor mean to 0
!dep@1; ! set factor variance to 1 (standardize)
[v1$1*0.5] (v1t1g2); [v1$2*1.0] (v1t2g2); [v1$3*1.5] (v1t3g2); ! item thresholds for v1
[v2$1*0.5] (v2t1g2); [v2$2*1.0] (v2t2g2); [v2$3*1.5] (v2t3g2); ! item thresholds for v2
[v3$1*0.5] (v3t1g2); [v3$2*1.0] (v3t2g2); [v3$3*1.5] (v3t3g2); ! item thresholds for v3
[v4$1*0.0] (v4t1g2); [v4$2*0.5] (v4t2g2); [v4$3*1.0] (v4t3g2); ! item thresholds for v4
[v5$1*0.0] (v5t1g2); [v5$2*0.5] (v5t2g2); [v5$3*1.0] (v5t3g2); ! item thresholds for v5
!v1-v5@1; ! item residual variances
MODEL: ! tell Mplus to estimate our model; asterisks (*) are free estimates with a starting value; at symbols (@) are fixed estimates
dep BY v1-v5*.7; ! factor loadings
[dep@0]; ! set factor mean to 0
dep@1; ! set factor variance to 1 (standardize)
[v1$1*0.5] (v1t1g1); [v1$2*1.0] (v1t2g1); [v1$3*1.5] (v1t3g1); ! item thresholds for v1
[v2$1*0.5] (v2t1g1); [v2$2*1.0] (v2t2g1); [v2$3*1.5] (v2t3g1); ! item thresholds for v2
[v3$1*0.5] (v3t1g1); [v3$2*1.0] (v3t2g1); [v3$3*1.5] (v3t3g1); ! item thresholds for v3
[v4$1*0.5] (v4t1g1); [v4$2*1.0] (v4t2g1); [v4$3*1.5] (v4t3g1); ! item thresholds for v4
[v5$1*0.5] (v5t1g1); [v5$2*1.0] (v5t2g1); [v5$3*1.5] (v5t3g1); ! item thresholds for v5
v1-v5@1; ! item residual variances
MODEL g2: ! tell Mplus to estimate our model in group 2; asterisks (*) are free estimates with a starting value; at symbols (@) are fixed estimates
!dep BY v1-v5*.7; ! factor loadings
![dep@0]; ! set factor mean to 0
!dep@1; ! set factor variance to 1 (standardize)
[v1$1*0.5] (v1t1g2); [v1$2*1.0] (v1t2g2); [v1$3*1.5] (v1t3g2); ! item thresholds for v1
[v2$1*0.5] (v2t1g2); [v2$2*1.0] (v2t2g2); [v2$3*1.5] (v2t3g2); ! item thresholds for v2
[v3$1*0.5] (v3t1g2); [v3$2*1.0] (v3t2g2); [v3$3*1.5] (v3t3g2); ! item thresholds for v3
[v4$1*0.0] (v4t1g2); [v4$2*0.5] (v4t2g2); [v4$3*1.0] (v4t3g2); ! item thresholds for v4
[v5$1*0.0] (v5t1g2); [v5$2*0.5] (v5t2g2); [v5$3*1.0] (v5t3g2); ! item thresholds for v5
!v1-v5@1; ! item residual variances
MODEL CONSTRAINT:
NEW (stdt1g1 stdt2g1 stdt3g1 stdt1g2 stdt2g2 stdt3g2
nonit1g1 nonit2g1 nonit3g1 nonit1g2 nonit2g2 nonit3g2
stdtg1 stdtg2 nonitg1 nonitg2 diffwg diffbg);
stdt1g1 = (v1t1g1 + v2t1g1 + v3t1g1) / 3;
stdt2g1 = (v1t2g1 + v2t2g1 + v3t2g1) / 3;
stdt3g1 = (v1t3g1 + v2t3g1 + v3t3g1) / 3;
stdt1g2 = (v1t1g2 + v2t1g2 + v3t1g2) / 3;
stdt2g2 = (v1t2g2 + v2t2g2 + v3t2g2) / 3;
stdt3g2 = (v1t3g2 + v2t3g2 + v3t3g2) / 3;
nonit1g1 = (v4t1g1 + v5t1g1) / 2;
nonit2g1 = (v4t2g1 + v5t2g1) / 2;
nonit3g1 = (v4t3g1 + v5t3g1) / 2;
nonit1g2 = (v4t1g2 + v5t1g2) / 2;
nonit2g2 = (v4t2g2 + v5t2g2) / 2;
nonit3g2 = (v4t3g2 + v5t3g2) / 2;
stdtg1 = (stdt1g1 + stdt2g1 + stdt3g1) / 3;
stdtg2 = (stdt1g2 + stdt2g2 + stdt3g2) / 3;
nonitg1 = (nonit1g1 + nonit2g1 + nonit3g1) / 3;
nonitg2 = (nonit1g2 + nonit2g2 + nonit3g2) / 3;
diffwg = nonitg2 - stdtg2; ! difference within group
diffbg = nonitg2 - nonitg1; ! difference between groups
OUTPUT:
TECH9;
```
# Session Info
```{r, class.source = "fold-hide"}
sessionInfo()
```