-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdevelopmentalScaling.qmd
More file actions
829 lines (642 loc) · 21.6 KB
/
Copy pathdevelopmentalScaling.qmd
File metadata and controls
829 lines (642 loc) · 21.6 KB
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
---
title: "Developmental Scaling"
---
# Preamble
## Install Libraries
```{r}
#install.packages("remotes")
#remotes::install_github("DevPsyLab/petersenlab")
```
## Load Libraries
```{r}
library("lavaan")
library("semTools")
library("semPlot")
library("lavaanPlot")
library("lavaangui")
library("sirt")
library("kableExtra")
library("tidyverse")
```
## Import data
```{r}
mydata_wide <- read.csv("./data/Bliese-Ployhart-2002-indicators-4.csv")
```
## Data Processing
```{r}
mydata_wide$sad1 <- mydata_wide$JOBSAT11
mydata_wide$sad2 <- mydata_wide$JOBSAT21
mydata_wide$sad3 <- mydata_wide$JOBSAT31
mydata_wide$down1 <- mydata_wide$JOBSAT12
mydata_wide$down2 <- mydata_wide$JOBSAT22
mydata_wide$down3 <- mydata_wide$JOBSAT32
mydata_wide$depressed1 <- mydata_wide$JOBSAT13
mydata_wide$depressed2 <- mydata_wide$JOBSAT23
mydata_wide$depressed3 <- mydata_wide$JOBSAT33
```
# Approaches
1. [Partial strong longitudinal factorial invariance](#sec-partialStrongInvariance) (paired with second-order growth functions—i.e., a second-order growth curve model)
1. [Alignment optimization](#sec-alignment) (paired with second-order growth functions)
1. [Moderated nonlinear factor analysis](#sec-mnlfa) (MNLFA) (paired with second-order growth functions)
1. [Item response theory (IRT) with anchor items](#sec-irt) (potentially with regularization/Bayesian penalty methods on the priors)
- [separate calibration](#sec-irtSeparateCalibration)
- [concurrent calibration](#sec-irtConcurrentCalibration)
# Partial Strong Longitudinal Factorial Invariance {#sec-partialStrongInvariance}
The example is adapted from the section on [longitudinal measurement invariance](#sec-longitudinalMI).
Two primary options for identifying a latent factor include:
1. standardizing the latent factor(s) at all timepoints (fixing their intercepts to zero and their variances to one)
1. standardizing the latent factor(s) at T1 (fixing their intercepts to zero and their variances to one) and constraining the factor loadings and intercepts of one item to be equal across time
(Option #2 may be preferable in alignment optimization.)
## Standardizing the Latent Factors at All Timepoints
## Standardizing the Latent Factors at T1 while Constraining Loadings and Intercepts of One Item Across Time
### Configural Invariance With Correlated Residuals Within-Indicator Across Time
1. Standardize the latent factor(s) at T1 (i.e., fix the mean to zero and the variance to one)
1. For each latent construct, constrain the first indicator's factor loading to be the same across time
1. For each latent construct, constrain the first indicator's intercept to be the same across time
1. Allow within-indicator residuals to covary across time
```{r}
configuralInvarianceStandardizeT1Latent_syntax <- '
# Factor Loadings
latent_t1 =~ NA*load1*sad1 + load12*down1 + load13*depressed1
latent_t2 =~ NA*load1*sad2 + load22*down2 + load23*depressed2
latent_t3 =~ NA*load1*sad3 + load32*down3 + load33*depressed3
# Factor Identification: Standardize Factors at T1
## Fix Factor Means at T1 to Zero
latent_t1 ~ 0*1
## Fix Factor Variances at T1 to One
latent_t1 ~~ 1*latent_t1
# Freely Estimate Factor Means at T2 and T3 (relative to T1)
latent_t2 ~ 1
latent_t3 ~ 1
# Freely Estimate Factor Variances at T2 and T3 (relative to T1)
latent_t2 ~~ latent_t2
latent_t3 ~~ latent_t3
# Fix Intercepts of Indicator 1 Across Time
sad1 ~ inta*1
sad2 ~ inta*1
sad3 ~ inta*1
# Free Intercepts of Remaining Manifest Variables
down1 ~ intb1*1
down2 ~ intb2*1
down3 ~ intb3*1
depressed1 ~ intc1*1
depressed2 ~ intc2*1
depressed3 ~ intc3*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
'
configuralInvarianceStandardizeT1Latent_fit <- cfa(
configuralInvarianceStandardizeT1Latent_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
#std.lv = TRUE,
fixed.x = FALSE)
summary(
configuralInvarianceStandardizeT1Latent_fit,
fit.measures = TRUE,
standardized = TRUE,
rsquare = TRUE)
```
### Metric ("Weak Factorial") Invariance
1. Standardize the latent factor(s) at T1 (i.e., fix the mean to zero and the variance to one)
1. For each latent construct, constrain the first indicator's intercept to be the same across time
1. Allow within-indicator residuals to covary across time
1. **For each indicator, constrain its factor loading to be the same across time**
```{r}
metricInvarianceStandardizeT1Latent_syntax <- '
# Factor Loadings
latent_t1 =~ NA*load1*sad1 + load2*down1 + load3*depressed1
latent_t2 =~ NA*load1*sad2 + load2*down2 + load3*depressed2
latent_t3 =~ NA*load1*sad3 + load2*down3 + load3*depressed3
# Factor Identification: Standardize Factors at T1
## Fix Factor Means at T1 to Zero
latent_t1 ~ 0*1
## Fix Factor Variances at T1 to One
latent_t1 ~~ 1*latent_t1
# Freely Estimate Factor Means at T2 and T3 (relative to T1)
latent_t2 ~ 1
latent_t3 ~ 1
# Freely Estimate Factor Variances at T2 and T3 (relative to T1)
latent_t2 ~~ latent_t2
latent_t3 ~~ latent_t3
# Fix Intercepts of Indicator 1 Across Time
sad1 ~ inta*1
sad2 ~ inta*1
sad3 ~ inta*1
# Free Intercepts of Remaining Manifest Variables
down1 ~ intb1*1
down2 ~ intb2*1
down3 ~ intb3*1
depressed1 ~ intc1*1
depressed2 ~ intc2*1
depressed3 ~ intc3*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
'
metricInvarianceStandardizeT1Latent_fit <- cfa(
metricInvarianceStandardizeT1Latent_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
#std.lv = TRUE,
fixed.x = FALSE)
summary(
metricInvarianceStandardizeT1Latent_fit,
fit.measures = TRUE,
standardized = TRUE,
rsquare = TRUE)
anova(
configuralInvarianceStandardizeT1Latent_fit,
metricInvarianceStandardizeT1Latent_fit
)
```
### Scalar ("Strong Factorial") Invariance
1. Standardize the latent factor(s) at T1 (i.e., fix the mean to zero and the variance to one)
1. Allow within-indicator residuals to covary across time
1. For each indicator, constrain its factor loading to be the same across time
1. **For each indicator, constrain its intercept to be the same across time**
```{r}
scalarInvarianceStandardizeT1Latent_syntax <- '
# Factor Loadings
latent_t1 =~ NA*load1*sad1 + load2*down1 + load3*depressed1
latent_t2 =~ NA*load1*sad2 + load2*down2 + load3*depressed2
latent_t3 =~ NA*load1*sad3 + load2*down3 + load3*depressed3
# Factor Identification: Standardize Factors at T1
## Fix Factor Means at T1 to Zero
latent_t1 ~ 0*1
## Fix Factor Variances at T1 to One
latent_t1 ~~ 1*latent_t1
# Freely Estimate Factor Means at T2 and T3 (relative to T1)
latent_t2 ~ 1
latent_t3 ~ 1
# Freely Estimate Factor Variances at T2 and T3 (relative to T1)
latent_t2 ~~ latent_t2
latent_t3 ~~ latent_t3
# Fix Intercepts Across Time
sad1 ~ inta*1
sad2 ~ inta*1
sad3 ~ inta*1
down1 ~ intb*1
down2 ~ intb*1
down3 ~ intb*1
depressed1 ~ intc*1
depressed2 ~ intc*1
depressed3 ~ intc*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
'
scalarInvarianceStandardizeT1Latent_fit <- cfa(
scalarInvarianceStandardizeT1Latent_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
#std.lv = TRUE,
fixed.x = FALSE)
summary(
scalarInvarianceStandardizeT1Latent_fit,
fit.measures = TRUE,
standardized = TRUE,
rsquare = TRUE)
anova(
scalarInvarianceStandardizeT1Latent_fit,
metricInvarianceStandardizeT1Latent_fit
)
```
### Partial Strong Factorial Invariance
1. Standardize the latent factor(s) at T1 (i.e., fix the mean to zero and the variance to one)
1. Allow within-indicator residuals to covary across time
1. For some indicators (i.e., the indicators with invariant factor loadings, called "anchor items"), constrain its factor loading to be the same across time
1. For some indicators (i.e., the indicators with invariant intercepts, called "anchor items"), constrain its intercept to be the same across time
```{r}
partialStrongInvarianceStandardizeT1Latent_syntax <- '
# Factor Loadings
latent_t1 =~ NA*load1*sad1 + load2*down1 + load3*depressed1
latent_t2 =~ NA*load1*sad2 + load2*down2 + load3*depressed2
latent_t3 =~ NA*load1*sad3 + load2*down3 + load33*depressed3
# Factor Identification: Standardize Factors at T1
## Fix Factor Means at T1 to Zero
latent_t1 ~ 0*1
## Fix Factor Variances at T1 to One
latent_t1 ~~ 1*latent_t1
# Freely Estimate Factor Means at T2 and T3 (relative to T1)
latent_t2 ~ 1
latent_t3 ~ 1
# Freely Estimate Factor Variances at T2 and T3 (relative to T1)
latent_t2 ~~ latent_t2
latent_t3 ~~ latent_t3
# Fix Some Intercepts Across Time
sad1 ~ inta*1
sad2 ~ inta*1
sad3 ~ inta*1
down1 ~ intb*1
down2 ~ intb2*1
down3 ~ intb*1
depressed1 ~ intc*1
depressed2 ~ intc2*1
depressed3 ~ intc*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
'
partialStrongInvarianceStandardizeT1Latent_fit <- cfa(
partialStrongInvarianceStandardizeT1Latent_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
#std.lv = TRUE,
fixed.x = FALSE)
summary(
partialStrongInvarianceStandardizeT1Latent_fit,
fit.measures = TRUE,
standardized = TRUE,
rsquare = TRUE)
anova(
configuralInvarianceStandardizeT1Latent_fit,
partialStrongInvarianceStandardizeT1Latent_fit
)
```
### Partial Strong Factorial Invariance With Second-Order Growth Curve {#sec-secondOrderLGCM}
#### Model Syntax
```{r}
partialStrongInvarianceGrowthCurve_syntax <- '
# Factor Loadings
latent_t1 =~ NA*load1*sad1 + load2*down1 + load3*depressed1
latent_t2 =~ NA*load1*sad2 + load2*down2 + load3*depressed2
latent_t3 =~ NA*load1*sad3 + load2*down3 + load33*depressed3
# Factor Identification: Standardize Factors at T1
## Fix Factor Means at T1 to Zero
latent_t1 ~ 0*1
## Fix Factor Variances at T1 to One
latent_t1 ~~ 1*latent_t1
# Fix Some Intercepts Across Time
sad1 ~ inta*1
sad2 ~ inta*1
sad3 ~ inta*1
down1 ~ intb*1
down2 ~ intb2*1
down3 ~ intb*1
depressed1 ~ intc*1
depressed2 ~ intc2*1
depressed3 ~ intc*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
# Linear Growth Model
i =~ 1*latent_t1 + 1*latent_t2 + 1*latent_t3
s =~ 0*latent_t1 + 1*latent_t2 + 2*latent_t3
# Variance-covariances of intercepts and slopes
i ~~ i
s ~~ s
i ~~ s
# Means of level and slope
i ~ 1
s ~ 1
'
```
#### Fit Model
```{r}
partialStrongInvarianceGrowthCurve_fit <- cfa(
partialStrongInvarianceGrowthCurve_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
#std.lv = TRUE,
fixed.x = FALSE)
```
#### Model Summary
```{r}
summary(
partialStrongInvarianceGrowthCurve_fit,
fit.measures = TRUE,
standardized = TRUE,
rsquare = TRUE)
```
Parameter estimates:
```{r}
lavaan::parameterEstimates(partialStrongInvarianceGrowthCurve_fit) %>%
subset(
lhs %in% c("i", "s") & substr(rhs, 1, 6) != "latent",
-label
)
```
# Alignment Optimization {#sec-alignment}
The example is adapted from the section on [longitudinal measurement invariance](#sec-longitudinalMI).
Two primary options for identifying a latent factor include:
1. standardizing the latent factor(s) at all timepoints (fixing their intercepts to zero and their variances to one)
1. standardizing the latent factor(s) at T1 (fixing their intercepts to zero and their variances to one) and constraining the factor loadings and intercepts of one item to be equal across time
(Option #1 may be preferable in alignment optimization.)
## Standardizing the Latent Factors at All Timepoints
### Configural Invariance With Correlated Residuals Within-Indicator Across Time
1. Standardize the latent factor(s) at all timepoints (i.e., fix the mean to zero and the variance to one)
1. Allow within-indicator residuals to covary across time
#### Model Syntax
```{r}
configuralInvarianceStandardizeAllLatent_syntax <- '
# Factor Loadings
latent_t1 =~ NA*load11*sad1 + load12*down1 + load13*depressed1
latent_t2 =~ NA*load21*sad2 + load22*down2 + load23*depressed2
latent_t3 =~ NA*load31*sad3 + load32*down3 + load33*depressed3
# Factor Identification: Standardize Factors at All Timepoints (using std.lv = TRUE)
# Free Intercepts of Manifest Variables
sad1 ~ inta1*1
sad2 ~ inta2*1
sad3 ~ inta3*1
down1 ~ intb1*1
down2 ~ intb2*1
down3 ~ intb3*1
depressed1 ~ intc1*1
depressed2 ~ intc2*1
depressed3 ~ intc3*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
'
```
#### Fit Model
```{r}
configuralInvarianceStandardizeAllLatent_fit <- cfa(
configuralInvarianceStandardizeAllLatent_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
std.lv = TRUE,
fixed.x = FALSE)
```
#### Model Summary
```{r}
summary(
configuralInvarianceStandardizeAllLatent_fit,
fit.measures = TRUE,
standardized = TRUE,
rsquare = TRUE)
```
### Longitudinal Alignment Optimization
Adapted from Lai (2013; [code](https://github.com/marklhc/awc-growth-supp/blob/main/ex_MIDUS_growth.Rmd)):
```{r}
# Extract loadings and intercepts for alignment
lam_mat <- lavInspect(configuralInvarianceStandardizeAllLatent_fit, what = "est")$lambda
nu_vec <- lavInspect(configuralInvarianceStandardizeAllLatent_fit, what = "est")$nu
# Put them into T x p matrices
num_items <- 3
num_waves <- 3
lam_config <- crossprod(lam_mat, rep(1, num_waves) %x% diag(num_items))
nu_config <- matrix(nu_vec, nrow = num_waves, ncol = num_items, byrow = TRUE)
# Add indicator names
colnames(lam_config) <- colnames(nu_config) <- c("sad", "down", "depressed")
# Alignment optimization
aligned_pars <- sirt::invariance.alignment(
lambda = lam_config,
nu = nu_config,
fixed = TRUE
)
```
The aligned loadings and intercepts are below:
```{r}
alignedParameters <- rbind(
"Loadings" = rep(NA, num_items),
`rownames<-`(aligned_pars$lambda.aligned,
paste0("Time", 1:num_waves)),
"Intercepts" = rep(NA, num_items),
`rownames<-`(aligned_pars$nu.aligned,
paste0("Time", 1:num_waves))
)
#opts <- options(knitr.kable.NA = "")
#
#knitr::kable(
# alignedParameters,
# format = "simple",
# digits = 3L
#)
print(alignedParameters, na.print = "")
aligned_pars$lambda.aligned
aligned_pars$nu.aligned
```
#### Effect Size of Noninvariance ($d_{MACS}$)
Lai (2023) suggests using a "50/30/20" rule of thumb for using $d_{MACS}$ to evaluate the appropriateness of the alignment optimization method:
Alignment optimization within CFA "is trustworthy when (a) no more than 50% of items have one or more $d_{MACS}$ > .20 and (b) no more than 30% of the pairwise $d_{MACS}$ > .20.
Lai (2023) suggests reporting the range of $d_{MACS}$ values, the proportion of $d_{MACS}$ > .20, and the proportion of items with at least one $d_{MACS}$ > .20.
```{r}
# Function for dMACS
dmacs <- function(loadings, intercepts, pooled_item_sd,
latent_mean = 0, latent_var = 1) {
dloading <- diff(loadings)
dintercept <- diff(intercepts)
integral <- dintercept^2 + 2 * dintercept * dloading * latent_mean +
dloading^2 * (latent_var + latent_mean^2)
sqrt(integral) / pooled_item_sd
}
# Use item SDs at first time point
item_sds_wave1 <-
apply(
mydata_wide[c("sad1", "down1", "depressed1")],
2, sd
)
dmacs_pairwise <- function(loading_mat, intercept_mat, pooled_item_sd,
latent_mean = 0, latent_var = 1) {
ngroups <- nrow(loading_mat)
pairs <- combn(ngroups, 2)
out <- matrix(NA, nrow = ncol(pairs), ncol = ncol(loading_mat))
for (i in seq_len(ncol(pairs))) {
out[i, ] <- dmacs(loading_mat[pairs[, i], ],
intercepts = intercept_mat[pairs[, i], ],
pooled_item_sd,
latent_mean,
latent_var
)
}
rownames(out) <- apply(pairs, 2, paste, collapse = " vs ")
colnames(out) <- colnames(loading_mat)
out
}
# All pairwise dMACS
dmacs_pairwise(aligned_pars$lambda.aligned,
intercept_mat = aligned_pars$nu.aligned,
pooled_item_sd = item_sds_wave1,
latent_mean = 0,
latent_var = 1
)
```
### An Equivalent Configural Model with Aligned Loadings
For the reference indicator (for which the loadings and intercepts are fixed), it is preferable to select an indicator with a strong factor loading (Lai, 2023).
```{r}
equivalentConfiguralModelAligned_syntax <- '
# Factor Loadings (Loadings of first indicator fixed to alignment solution)
latent_t1 =~ 0.9904750*load11*sad1 + load12*down1 + load13*depressed1
latent_t2 =~ 0.9880715*load21*sad2 + load22*down2 + load23*depressed2
latent_t3 =~ 0.9863225*load31*sad3 + load32*down3 + load33*depressed3
# Intercepts of Manifest Variables (Intercepts of first indicator fixed to alignment solution)
sad1 ~ 3.319192*inta1*1
sad2 ~ 3.332276*inta2*1
sad3 ~ 3.345631*inta3*1
down1 ~ intb1*1
down2 ~ intb2*1
down3 ~ intb3*1
depressed1 ~ intc1*1
depressed2 ~ intc2*1
depressed3 ~ intc3*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
# Free latent means
latent_t1 + latent_t2 + latent_t3 ~ NA*1
'
equivalentConfiguralModelAligned_fit <- cfa(
equivalentConfiguralModelAligned_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
#std.lv = TRUE,
fixed.x = FALSE)
```
Compare model fit (they're equivalent):
```{r}
anova(
configuralInvarianceStandardizeAllLatent_fit,
equivalentConfiguralModelAligned_fit
)
```
### Alignment-Within-CFA (AwC) Approach for Growth Modeling
#### Model Syntax
For the reference indicator (for which the loadings and intercepts are fixed), it is preferable to select an indicator with a strong factor loading (Lai, 2023).
```{r}
awcGrowthModel_syntax <- '
# Factor Loadings (Loadings of first indicator fixed to alignment solution)
latent_t1 =~ 0.9904750*load11*sad1 + load12*down1 + load13*depressed1
latent_t2 =~ 0.9880715*load21*sad2 + load22*down2 + load23*depressed2
latent_t3 =~ 0.9863225*load31*sad3 + load32*down3 + load33*depressed3
# Intercepts of Manifest Variables (Intercepts of first indicator fixed to alignment solution)
sad1 ~ 3.319192*inta1*1
sad2 ~ 3.332276*inta2*1
sad3 ~ 3.345631*inta3*1
down1 ~ intb1*1
down2 ~ intb2*1
down3 ~ intb3*1
depressed1 ~ intc1*1
depressed2 ~ intc2*1
depressed3 ~ intc3*1
# Residual Covariances Within Indicator Across Time
sad1 ~~ sad2
sad2 ~~ sad3
sad3 ~~ sad3
down1 ~~ depressed2
down2 ~~ depressed3
down3 ~~ depressed3
depressed1 ~~ depressed2
depressed2 ~~ depressed3
depressed3 ~~ depressed3
# Linear Growth Model
i =~ 1*latent_t1 + 1*latent_t2 + 1*latent_t3
s =~ 0*latent_t1 + 1*latent_t2 + 2*latent_t3
# Variance-covariances of intercepts and slopes
i ~~ i
s ~~ s
i ~~ s
# Means of level and slope
i ~ 1
s ~ 1
# Fixed disturbances of latent outcomes to zero
latent_t1 ~ 0*1
latent_t2 ~ 0*1
latent_t3 ~ 0*1
'
```
#### Fit Model
```{r}
awcGrowthModel_fit <- cfa(
awcGrowthModel_syntax,
data = mydata_wide,
missing = "ML",
estimator = "MLR",
meanstructure = TRUE,
#std.lv = TRUE,
fixed.x = FALSE)
```
#### Model Summary
```{r}
summary(
configuralInvarianceStandardizeAllLatent_fit,
fit.measures = TRUE,
standardized = TRUE,
rsquare = TRUE)
```
Parameter estimates:
```{r}
lavaan::parameterEstimates(awcGrowthModel_fit) %>%
subset(
lhs %in% c("i", "s") & substr(rhs, 1, 6) != "latent",
-label
) %>%
knitr::kable(format = "simple", digits = 3L)
```
## Standardizing the Latent Factors at T1 while Constraining Loadings and Intercepts of One Item Across Time
### Configural Invariance With Correlated Residuals Within-Indicator Across Time
1. Standardize the latent factor(s) at T1 (i.e., fix the mean to zero and the variance to one)
1. For each latent construct, constrain the first indicator's factor loading to be the same across time
1. For each latent construct, constrain the first indicator's intercept to be the same across time
1. **Allow within-indicator residuals to covary across time**
# Moderated Nonlinear Factor Analysis (MNLFA) {#sec-mnlfa}
# Item Response Theory (IRT) with Anchor Items {#sec-irt}
It can be potentially helpful to consider regularization/Bayesian penalty methods (e.g., using priors such as Horseshoe, Lasso, or Spike-and-slab).
For examples of IRT models, see [here](irt.qmd).
## Separate Calibration {#sec-irtSeparateCalibration}
## Concurrent Calibration {#sec-irtConcurrentCalibration}