我有一个数据集,其中一些(但不是全部)受试者在时间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
'
答案 0 :(得分:0)
(相信这个答案归阿姆斯特丹大学的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")