如何在 lavaan 的多组测量不变性中为某些组指定不同的模型?
How to specify different model for certain groups in multigroup measurement invariance in lavaan?
我有一个数据集,其中一些(但不是全部)受试者在时间 2 参与。我想 运行 跨时间 和 跨组的测量不变性分析.当然,对于那些只参加时间1的人,时间2的潜变量不会为他们估计。
在 lavaan
中,您可以为模型中的每个变量指定不同的权重,方法是在其前面加上权重向量。例如,c(0.5, 0.2) 将为第一组赋予 0.5 的权重,为第二组赋予 0.2 的权重。我的问题是我不能对潜在变量这样做。 我的问题:如何告诉 lavaan
只为一组而不是另一组估计潜在变量?
示例代码:
model <- '
# Measurement model ---
factor1_time1 =~ 1*var1_t1 + var2_t1 + var3_t1
factor2_time1 =~ 1*var4_t1 + var5_t1 + var6_t1
factor3_time1 =~ 1*var7_t1 + var9_t1 + var9_t1
# !! Note: I only want this to apply to one of the groups !!
factor1_time2 =~ 1*var1_t2 + var2_t2 + var3_t2
factor2_time2 =~ 1*var4_t2 + var5_t2 + var6_t2
factor3_time2 =~ 1*var7_t2 + var9_t2 + var9_t2
# Factor Covariances ---
# all time 1 factors with each other
factor1_time1 ~~ factor2_time1
factor1_time1 ~~ factor3_time1
factor2_time1 ~~ factor3_time1
# all time 2 factors with each other
factor1_time2 ~~ factor2_time2
factor1_time2 ~~ factor3_time2
factor2_time2 ~~ factor3_time2
# factor1_time1 with all Time 2 factors
factor1_time1 ~~ factor1_time2
factor1_time1 ~~ factor2_time2
factor1_time1 ~~ factor3_time2
# factor2_time1 with all Time 2 factors
factor2_time1 ~~ factor1_time2
factor2_time1 ~~ factor2_time2
factor2_time1 ~~ factor3_time2
# factor3_time1 with all Time 2 factors
factor3_time1 ~~ factor1_time2
factor3_time1 ~~ factor2_time2
factor3_time1 ~~ factor3_time2
# Lag item residuals ---
#factor1 items
var1_t1 ~~ var1_t2
var2_t1 ~~ var2_t2
var3_t1 ~~ var3_t2
#factor2 items
var4_t1 ~~ var4_t2
var5_t1 ~~ var5_t2
var6_t1 ~~ var6_t2
#factor 3 times
var7_t1 ~~ var7_t2
var8_t1 ~~ var8_t2
var9_t1 ~~ var9_t2
'
(此答案归功于阿姆斯特丹大学的 Jorgensen 博士)
library(lavaan)
HS.model <- '
group: 1
visual =~ x1 + a*x2 + b*x3
textual =~ x4 + x5 + x6
group: 2
visual =~ x1 + a*x2 + b*x3
speed =~ x7 + x8 + x9
'
fit <- cfa(HS.model, data=HolzingerSwineford1939, group="school")
我有一个数据集,其中一些(但不是全部)受试者在时间 2 参与。我想 运行 跨时间 和 跨组的测量不变性分析.当然,对于那些只参加时间1的人,时间2的潜变量不会为他们估计。
在 lavaan
中,您可以为模型中的每个变量指定不同的权重,方法是在其前面加上权重向量。例如,c(0.5, 0.2) 将为第一组赋予 0.5 的权重,为第二组赋予 0.2 的权重。我的问题是我不能对潜在变量这样做。 我的问题:如何告诉 lavaan
只为一组而不是另一组估计潜在变量?
示例代码:
model <- '
# Measurement model ---
factor1_time1 =~ 1*var1_t1 + var2_t1 + var3_t1
factor2_time1 =~ 1*var4_t1 + var5_t1 + var6_t1
factor3_time1 =~ 1*var7_t1 + var9_t1 + var9_t1
# !! Note: I only want this to apply to one of the groups !!
factor1_time2 =~ 1*var1_t2 + var2_t2 + var3_t2
factor2_time2 =~ 1*var4_t2 + var5_t2 + var6_t2
factor3_time2 =~ 1*var7_t2 + var9_t2 + var9_t2
# Factor Covariances ---
# all time 1 factors with each other
factor1_time1 ~~ factor2_time1
factor1_time1 ~~ factor3_time1
factor2_time1 ~~ factor3_time1
# all time 2 factors with each other
factor1_time2 ~~ factor2_time2
factor1_time2 ~~ factor3_time2
factor2_time2 ~~ factor3_time2
# factor1_time1 with all Time 2 factors
factor1_time1 ~~ factor1_time2
factor1_time1 ~~ factor2_time2
factor1_time1 ~~ factor3_time2
# factor2_time1 with all Time 2 factors
factor2_time1 ~~ factor1_time2
factor2_time1 ~~ factor2_time2
factor2_time1 ~~ factor3_time2
# factor3_time1 with all Time 2 factors
factor3_time1 ~~ factor1_time2
factor3_time1 ~~ factor2_time2
factor3_time1 ~~ factor3_time2
# Lag item residuals ---
#factor1 items
var1_t1 ~~ var1_t2
var2_t1 ~~ var2_t2
var3_t1 ~~ var3_t2
#factor2 items
var4_t1 ~~ var4_t2
var5_t1 ~~ var5_t2
var6_t1 ~~ var6_t2
#factor 3 times
var7_t1 ~~ var7_t2
var8_t1 ~~ var8_t2
var9_t1 ~~ var9_t2
'
(此答案归功于阿姆斯特丹大学的 Jorgensen 博士)
library(lavaan)
HS.model <- '
group: 1
visual =~ x1 + a*x2 + b*x3
textual =~ x4 + x5 + x6
group: 2
visual =~ x1 + a*x2 + b*x3
speed =~ x7 + x8 + x9
'
fit <- cfa(HS.model, data=HolzingerSwineford1939, group="school")