lavaan 纵向不变性 CFA 与 R 中的 2 因子模型

Gor*_*orp 5 r r-lavaan

我使用该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)
Run Code Online (Sandbox Code Playgroud)

但是,在模型中添加第二个因子时会产生错误。下面是一个二因素模型的示例代码:

  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)
Run Code Online (Sandbox Code Playgroud)

生成的错误是:

   Error in longInvariance(model.twoFactor, auto = 1, constrainAuto = TRUE,  : 
    The factor names of the same element of the 'varList' are not the same.
Run Code Online (Sandbox Code Playgroud)

phx*_*phx 2

我想您也在lavaan Google 群组上提出了您的问题。

semTools 正如它在文档中所回答和写入的那样,semTools仅提供longInvariance()一种规模。如果您有两个秤,则需要手动指定模型。