-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2018_IJBD_long_MI.r
282 lines (231 loc) · 9.78 KB
/
2018_IJBD_long_MI.r
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
# Please cite as:
# Edossa, A. K., Schroeders, U., Weinert, S., & Artelt, C. (2018).
# The development of emotional and behavioral self-regulation and their effects on academic
# in childhood. International Journal of Behavioral Development, 42(2), 192–202.
# https://doi.org/10.1177/0165025416687412
#
# contact Ashenafi Kassahun Edossa <ashenafiedossa@gmail.com>
# Ulrich Schroeders <ulrich.schroeders@gmail.com>
#
# title Longitudinal Measurement Invariance Testing with Categorical Data
# GitHub https://github.com/ulrich-schroeders/syntax-publications
# date 2015-08-04
# version 1.0.0
# Data availability statement:
# The manuscript used data from the Millennium Cohort Study, which is a longitudinal birth cohort study that follows the lives of children born in 2000 and 2001 in the United Kingdom (more information: Hansen, K. (2014). Millennium cohort study first, second, third, fourth and fifth surveys: A guide to the datasets, (8th ed.). London: Centre for Longitudinal Studies, Institute of Education, University of London.).
# Information and data set: https://discover.ukdataservice.ac.uk/series/?sn=2000031
#
# Testing for Longitudinal Measurement Invariance with Continous and Categorical Data.
# (more information in Edossa et al., 2018)
# ---------------------------------------------------------------------------
# Continuous Factor Residual Factor
# variables Loadings Intercepts Variances Means
# ---------------------------------------------------------------------------
# Configural invariance * * * Fixed at 0
# Weak invariance Fixed * * Fixed at 0
# Strong invariance Fixed Fixed * Fixed at 0/*
# Strict invariance Fixed Fixed Fixed Fixed at 0/*
#
# ---------------------------------------------------------------------------
# Categorical variables Factor Tresholds Residual Factor
# Loadings Variances Means
# ---------------------------------------------------------------------------
# Configural invariance (* *) Fixed at 1 Fixed at 0
# Strong invariance (Fixed Fixed) Fixed at 1/* Fixed at 0/*
# Strict invariance (Fixed Fixed) Fixed at 1 Fixed at 0/*
# ---------------------------------------------------------------------------
# Note. The asterisk (*) indicates that the parameter is freely estimated.
# Fixed = the parameter is fixed to equity over time points; Fixed at 1 =
# the residual variances are fixed to 1 at all time points; Fixed at 0 =
# factor means are fixed at 0 at all time points. Fixed at 0/* = factor
# means are fixed at 0 at the first time point and freely estimated at the
# other time points. Fixed at 1/* = the residual variances are fixed to 1
# at the first time point and freely estimated at the other time points.
# Parameters in parentheses need to be varied in tandem.
# Explanation of variable labels
# ------------------------------
# er = emotional regulation
# br = behavioral regulation
# .x = age at which assessment took place
library(lavaan)
# configrual measurement invariance
-----------------------------------
mod.configural <- '
# measurement part
er.3 =~ er1.3 + er2.3 + er3.3 + er5.3
er.5 =~ er1.5 + er2.5 + er3.5 + er5.5
er.7 =~ er1.7 + er2.7 + er3.7 + er5.7
br.3 =~ isr4.3 + isr5.3 + task.3 + think.3
br.5 =~ isr4.5 + isr5.5 + task.5 + think.5
br.7 =~ isr4.7 + isr5.7 + task.7 + think.7
# mean structure
er.3 ~ 0*1
er.5 ~ 0*1
er.7 ~ 0*1
br.3 ~ 0*1
br.5 ~ 0*1
br.7 ~ 0*1
# residual covariances
er1.3 ~~ er1.5 + er1.7
er1.5 ~~ er1.7
er2.3 ~~ er2.5 + er2.7
er2.5 ~~ er2.7
er3.3 ~~ er3.5 + er3.7
er3.5 ~~ er3.7
er5.3 ~~ er5.5 + er5.7
er5.5 ~~ er5.7
isr4.3 ~~ isr4.5 + isr4.7
isr4.5 ~~ isr4.7
isr5.3 ~~ isr5.5 + isr5.7
isr5.5 ~~ isr5.7
think.3 ~~ think.5 + think.7
think.5 ~~ think.7
task.3 ~~ task.5 + task.7
task.5 ~~ task.7 '
fit.configural <- cfa(mod.configural, data=mcs, missing="pairwise",
estimator="WLSMV", parameterization="theta",
ordered =c("isr4.3", "isr4.5", "isr4.7",
"isr5.3", "isr5.5", "isr5.7",
"er1.3", "er1.5", "er1.7",
"er2.3", "er2.5", "er2.7",
"er3.3", "er3.5", "er3.7",
"er5.3", "er5.5", "er5.7",
"task.3", "task.5", "task.7",
"think.3","think.5","think.7"))
summary(fit.configural, fit.measures=TRUE, standardized=TRUE)
# strong measurement invariance
-------------------------------
mod.strong <- '
# measurement part
er.3 =~ er1.3 + a2*er2.3 + a3*er3.3 + a4*er5.3
er.5 =~ er1.5 + a2*er2.5 + a3*er3.5 + a4*er5.5
er.7 =~ er1.7 + a2*er2.7 + a3*er3.7 + a4*er5.7
br.3 =~ isr4.3 + b2*isr5.3 + b3*task.3 + b4*think.3
br.5 =~ isr4.5 + b2*isr5.5 + b3*task.5 + b4*think.5
br.7 =~ isr4.7 + b2*isr5.7 + b3*task.7 + b4*think.7
# mean structure
er.3 ~ 0*1
er.5 ~ NA*1
er.7 ~ NA*1
br.3 ~ 0*1
br.5 ~ NA*1
br.7 ~ NA*1
# thresholds
er1.3 | c1*t1 + c2*t2; er1.5 | c1*t1 + c2*t2; er1.7 | c1*t1 + c2*t2
er2.3 | d1*t1 + d2*t2; er2.5 | d1*t1 + d2*t2; er2.7 | d1*t1 + d2*t2
er3.3 | e1*t1 + e2*t2; er3.5 | e1*t1 + e2*t2; er3.7 | e1*t1 + e2*t2
er5.3 | f1*t1 + f2*t2; er5.5 | f1*t1 + f2*t2; er5.7 | f1*t1 + f2*t2
isr4.3 | g1*t1 + g2*t2; isr4.5 | g1*t1 + g2*t2; isr4.7 | g1*t1 + g2*t2
isr5.3 | h1*t1 + h2*t2; isr5.5 | h1*t1 + h2*t2; isr5.7 | h1*t1 + h2*t2
task.3 | i1*t1 + i2*t2; task.5 | i1*t1 + i2*t2; task.7 | i1*t1 + i2*t2
think.3 | j1*t1 + j2*t2; think.5 | j1*t1 + j2*t2; think.7 | j1*t1 + j2*t2
# residual covariances
er1.3 ~~ er1.5 + er1.7
er1.5 ~~ er1.7
er2.3 ~~ er2.5 + er2.7
er2.5 ~~ er2.7
er3.3 ~~ er3.5 + er3.7
er3.5 ~~ er3.7
er5.3 ~~ er5.5 + er5.7
er5.5 ~~ er5.7
isr4.3 ~~ isr4.5 + isr4.7
isr4.5 ~~ isr4.7
isr5.3 ~~ isr5.5 + isr5.7
isr5.5 ~~ isr5.7
think.3 ~~ think.5 + think.7
think.5 ~~ think.7
task.3 ~~ task.5 + task.7
task.5 ~~ task.7
# residual variances
er1.3 ~~ 1*er1.3
er2.3 ~~ 1*er2.3
er3.3 ~~ 1*er3.3
er5.3 ~~ 1*er5.3
er1.5 ~~ NA*er1.5
er2.5 ~~ NA*er2.5
er3.5 ~~ NA*er3.5
er5.5 ~~ NA*er5.5
er1.7 ~~ NA*er1.7
er2.7 ~~ NA*er2.7
er3.7 ~~ NA*er3.7
er5.7 ~~ NA*er5.7
isr4.3 ~~ 1*isr4.3
isr5.3 ~~ 1*isr5.3
task.3 ~~ 1*task.3
think.3 ~~ 1*think.3
isr4.5 ~~ NA*isr4.5
isr5.5 ~~ NA*isr5.5
task.5 ~~ NA*task.5
think.5 ~~ NA*think.5
isr4.7 ~~ NA*isr4.7
isr5.7 ~~ NA*isr5.7
task.7 ~~ NA*task.7
think.7 ~~ NA*think.7 '
fit.strong<- cfa(mod.strong, data=mcs, missing="pairwise",
estimator="WLSMV", parameterization="theta",
ordered =c("isr4.3", "isr4.5", "isr4.7",
"isr5.3", "isr5.5", "isr5.7",
"er1.3", "er1.5", "er1.7",
"er2.3", "er2.5", "er2.7",
"er3.3", "er3.5", "er3.7",
"er5.3", "er5.5", "er5.7",
"task.3", "task.5", "task.7",
"think.3","think.5","think.7"))
summary(fit.strong, fit.measures=TRUE, standardized=TRUE)
# strict measurement invariance
-------------------------------
mod.strict <- '
# measurement part
er.3 =~ er1.3 + a2*er2.3 + a3*er3.3 + a4*er5.3
er.5 =~ er1.5 + a2*er2.5 + a3*er3.5 + a4*er5.5
er.7 =~ er1.7 + a2*er2.7 + a3*er3.7 + a4*er5.7
br.3 =~ isr4.3 + b2*isr5.3 + b3*task.3 + b4*think.3
br.5 =~ isr4.5 + b2*isr5.5 + b3*task.5 + b4*think.5
br.7 =~ isr4.7 + b2*isr5.7 + b3*task.7 + b4*think.7
# mean structure
er.3 ~ 0*1
er.5 ~ NA*1
er.7 ~ NA*1
br.3 ~ 0*1
br.5 ~ NA*1
br.7 ~ NA*1
# thresholds
er1.3 | c1*t1 + c2*t2; er1.5| c1*t1 + c2*t2; er1.7 | c1*t1 + c2*t2
er2.3 | d1*t1 + d2*t2; er2.5| d1*t1 + d2*t2; er2.7 | d1*t1 + d2*t2
er3.3 | e1*t1 + e2*t2; er3.5| e1*t1 + e2*t2; er3.7 | e1*t1 + e2*t2
er5.3 | f1*t1 + f2*t2; er5.5| f1*t1 + f2*t2; er5.7 | f1*t1 + f2*t2
isr4.3 | g1*t1 + g2*t2; isr4.5 | g1*t1 + g2*t2; isr4.7 | g1*t1 + g2*t2
isr5.3 | h1*t1 + h2*t2; isr5.5 | h1*t1 + h2*t2; isr5.7 | h1*t1 + h2*t2
task.3 | i1*t1 + i2*t2; task.5 | i1*t1 + i2*t2; task.7 | i1*t1 + i2*t2
think.3 | j1*t1 + j2*t2; think.5 | j1*t1 + j2*t2; think.7 | j1*t1 + j2*t2
# residual covariances
er1.3 ~~ er1.5 + er1.7
er1.5 ~~ er1.7
er2.3 ~~ er2.5 + er2.7
er2.5 ~~ er2.7
er3.3 ~~ er3.5 + er3.7
er3.5 ~~ er3.7
er5.3 ~~ er5.5 + er5.7
er5.5 ~~ er5.7
isr4.3 ~~ isr4.5 + isr4.7
isr4.5 ~~ isr4.7
isr5.3 ~~ isr5.5 + isr5.7
isr5.5 ~~ isr5.7
think.3 ~~ think.5 + think.7
think.5 ~~ think.7
task.3 ~~ task.5 + task.7
task.5 ~~ task.7 '
fit.strict<- cfa(mod.strict, data=mcs, missing="pairwise",
estimator="WLSMV", parameterization="theta",
ordered =c("isr4.3", "isr4.5", "isr4.7",
"isr5.3", "isr5.5", "isr5.7",
"er1.3", "er1.5", "er1.7",
"er2.3", "er2.5", "er2.7",
"er3.3", "er3.5", "er3.7",
"er5.3", "er5.5", "er5.7",
"task.3", "task.5", "task.7",
"think.3","think.5","think.7"))
summary(fit.strict, fit.measures=TRUE, standardized=TRUE)
# testing the difference between the configural vs. strong MI model
-------------------------------------------------------------------
anova(fit.configural, fit.strong, method="satorra.bentler.2010")