我使用longInvariance函数来处理区间数据的两个时间点之间的纵向不变性;我想知道正确的lavaan/semTools R-code应该是什么样的。
当我一次看一个因素时,它会起作用;但是当我检查一个双因素模型时,它会产生一个错误。
下面一个因素的示例代码:
model.oneFactor <- '
Factor1T1 =~ Item1 + Item2 + Item3
Factor1T2 =~ Item1t2 + Item2t2 + Item3t2
'
# Create list of variables
var1 <- c("Item1", "Item2", "Item3")
var2 <- c("Item1t2", "Item2t2", "Item3t2")
constrainedVar <- list(var1, var2)
# Invariance of the same factor across timepoints
longInvariance(model.oneFactor, auto=1, constrainAuto=TRUE, varList=constrainedVar, data=data, estimator="MLM", strict=TRUE)但是,当在模型中添加第二个因素时,会产生一个错误。下面是一个双因素模型的示例代码:
model.twoFactor <- '
Factor1T1 =~ Item1 + Item2 + Item3
Factor2T1 =~ Item4 + Item5 + Item6 + Item7
Factor1T2 =~ Item1t2 + Item2t2 + Item3t2
Factor2T2 =~ Item4t2 + Item5t2 + Item6t2 + Item7t2
'
# Create list of variables
var1 <- c("Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7")
var2 <- c("Item1t2", "Item2t2", "Item3t2", "Item4t2", "Item5t2", "Item6t2", "Item7t2")
constrainedVar <- list(var1, var2)
# Invariance of the same factor across timepoints
longInvariance(model.twoFactor, auto=1, constrainAuto=TRUE, varList=constrainedVar, data=data, estimator="MLM", strict=TRUE)生成的错误是:
Error in longInvariance(model.twoFactor, auto = 1, constrainAuto = TRUE, :
The factor names of the same element of the 'varList' are not the same.https://stackoverflow.com/questions/41099149
复制相似问题