用于 R 的 lavaan 中的模型识别
Model identification in lavaan for R
我正在尝试使用 R 的包 lavaan 进行潜在变量分析。但是,我收到以下错误消息:
Warning messages:
1: In lav_data_full(data = data, group = group,
cluster = cluster, : lavaan WARNING: some observed variances are
(at least) a factor 1000 times larger than others; use varTable(fit)
to investigate
2: In lav_model_vcov(lavmodel = lavmodel,
lavsamplestats = lavsamplestats, : lavaan WARNING: could not
compute standard errors! lavaan NOTE: this may be a symptom that the
model is not identified.
3: In lav_object_post_check(object) : lavaan WARNING: some estimated
ov variances are negative
4: In lav_object_post_check(object) :
lavaan WARNING: some estimated lv variances are negative
我的模型结构如下:
model <- "
# regressions
eigenvector.frug ~ Size + Morphology
# latent variables
Size =~ Mass + Forearm
Morphology =~ LMT + BUM
# covariances and variances
Mass ~~ Forearm
LMT ~~ BUM
Mass ~~ Mass
Forearm ~~ Forearm
LMT ~~ LMT
BUM ~~ BUM
"
我 运行ning 的代码是:
fit <- sem(model, data=data,
orthogonal=TRUE)
我得到以下摘要:
lavaan (0.5-23.1097) converged normally after 141 iterations
Number of observations 41
Estimator ML
Minimum Function Test Statistic 88.676
Degrees of freedom 2
P-value (Chi-square) 0.000
Parameter Estimates:
Information Expected
Standard Errors Standard
Latent Variables:
Estimate Std.Err z-value P(>|z|)
Size =~
Mass 1.000
Forearm 4.941 NA
Morphology =~
LMT 1.000
BUM 1.349 NA
Regressions:
Estimate Std.Err z-value P(>|z|)
eigenvector.frug ~
Size -0.000 NA
Morphology -2.774 NA
Covariances:
Estimate Std.Err z-value P(>|z|)
.Mass ~~
.Forearm 59.805 NA
.LMT ~~
.BUM 2.926 NA
Size ~~
Morphology 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.Mass 272.184 NA
.Forearm -518.752 NA
.LMT 3.283 NA
.BUM 5.871 NA
.eigenvectr.frg 0.344 NA
Size 26.894 NA
Morphology -0.038 NA
由于数据在不同尺度下变化,我尝试使用尺度函数和 运行 模型再次标准化所有变量。
data2 = scale(data)
然后我收到以下错误信息:
Warning message:
In lav_model_vcov(lavmodel = lavmodel, lavsamplestats
= lavsamplestats, : lavaan WARNING: could not compute standard errors!
lavaan NOTE: this may be a symptom that the model is not identified.
以及以下摘要:
lavaan (0.5-23.1097) converged normally after 69 iterations
Number of observations 41
Estimator ML
Minimum Function Test Statistic 87.973
Degrees of freedom 2
P-value (Chi-square) 0.000
Parameter Estimates:
Information Expected
Standard Errors Standard
Latent Variables:
Estimate Std.Err z-value P(>|z|)
Size =~
Mass 1.000
Forearm 0.940 NA
Morphology =~
LMT 1.000
BUM 0.181 NA
Regressions:
Estimate Std.Err z-value P(>|z|)
eigenvector.frug ~
Size 0.536 NA
Morphology -0.042 NA
Covariances:
Estimate Std.Err z-value P(>|z|)
.Mass ~~
.Forearm 0.389 NA
.LMT ~~
.BUM 0.541 NA
Size ~~
Morphology 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.Mass 0.404 NA
.Forearm 0.471 NA
.LMT 0.394 NA
.BUM 0.957 NA
.eigenvectr.frg 0.819 NA
Size 0.571 NA
Morphology 0.581 NA
你能帮我找出问题所在吗?非常感谢。
我认为问题在于同一结构上指标之间的相关残差。您正试图以冗余的方式解释同一结构上指标之间的关系。
例如,潜在构造 "size" 可以解释指标变量 "mass" 和 "forearm." 之间的关系,那里的残差将被概念化为指标中的方差,即不是 由潜在结构解释。
但是你所做的是让残差相关,这模拟了 "mass" 和 "forearm" 之间的共享方差,这不是由潜在因素解释的。
问题在于您的潜在构造仅由这两个变量组成。你基本上是在告诉 lavaan
:"Model the variance between these two indicators as a latent construct... No wait! Also model that same variance as a residual!" 所以 lavaan
基本上是在告诉你,"That doesn't make sense, I can't do that!" 我会试试这个代码:
model2 <- "
# regressions
eigenvector.frug ~ Size + Morphology
# latent variables
Size =~ Mass + Forearm
Morphology =~ LMT + BUM
# covariances and variances
Mass ~~ Mass
Forearm ~~ Forearm
LMT ~~ LMT
BUM ~~ BUM
"
此代码隐式地将残差协方差固定为零。
您可能 运行 仍然遇到的另一个问题是未识别每个子模型。对于每个潜在变量,您正在尝试从 2 个未识别的指标中估计一个潜在构造(即,您有 3 个方差相关元素可供使用,但您正在估计 2 个残差、一个载荷和一个潜在方差) .为了解决这个问题,您可以将每个潜在因子的载荷限制为彼此相等。我们可以通过为因子载荷分配相同的标签来做到这一点(这里,每个因子 "a" 和 "b")。
model3 <- "
# regressions
eigenvector.frug ~ Size + Morphology
# latent variables
Size =~ a*Mass + a*Forearm
Morphology =~ b*LMT + b*BUM
# covariances and variances
Mass ~~ Mass
Forearm ~~ Forearm
LMT ~~ LMT
BUM ~~ BUM
"
我正在尝试使用 R 的包 lavaan 进行潜在变量分析。但是,我收到以下错误消息:
Warning messages: 1: In lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate 2: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: could not compute standard errors! lavaan NOTE: this may be a symptom that the model is not identified. 3: In lav_object_post_check(object) : lavaan WARNING: some estimated ov variances are negative 4: In lav_object_post_check(object) :
lavaan WARNING: some estimated lv variances are negative
我的模型结构如下:
model <- "
# regressions
eigenvector.frug ~ Size + Morphology
# latent variables
Size =~ Mass + Forearm
Morphology =~ LMT + BUM
# covariances and variances
Mass ~~ Forearm
LMT ~~ BUM
Mass ~~ Mass
Forearm ~~ Forearm
LMT ~~ LMT
BUM ~~ BUM
"
我 运行ning 的代码是:
fit <- sem(model, data=data,
orthogonal=TRUE)
我得到以下摘要:
lavaan (0.5-23.1097) converged normally after 141 iterations
Number of observations 41
Estimator ML
Minimum Function Test Statistic 88.676
Degrees of freedom 2
P-value (Chi-square) 0.000
Parameter Estimates:
Information Expected
Standard Errors Standard
Latent Variables:
Estimate Std.Err z-value P(>|z|)
Size =~
Mass 1.000
Forearm 4.941 NA
Morphology =~
LMT 1.000
BUM 1.349 NA
Regressions:
Estimate Std.Err z-value P(>|z|)
eigenvector.frug ~
Size -0.000 NA
Morphology -2.774 NA
Covariances:
Estimate Std.Err z-value P(>|z|)
.Mass ~~
.Forearm 59.805 NA
.LMT ~~
.BUM 2.926 NA
Size ~~
Morphology 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.Mass 272.184 NA
.Forearm -518.752 NA
.LMT 3.283 NA
.BUM 5.871 NA
.eigenvectr.frg 0.344 NA
Size 26.894 NA
Morphology -0.038 NA
由于数据在不同尺度下变化,我尝试使用尺度函数和 运行 模型再次标准化所有变量。
data2 = scale(data)
然后我收到以下错误信息:
Warning message: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: could not compute standard errors! lavaan NOTE: this may be a symptom that the model is not identified.
以及以下摘要:
lavaan (0.5-23.1097) converged normally after 69 iterations
Number of observations 41
Estimator ML
Minimum Function Test Statistic 87.973
Degrees of freedom 2
P-value (Chi-square) 0.000
Parameter Estimates:
Information Expected
Standard Errors Standard
Latent Variables:
Estimate Std.Err z-value P(>|z|)
Size =~
Mass 1.000
Forearm 0.940 NA
Morphology =~
LMT 1.000
BUM 0.181 NA
Regressions:
Estimate Std.Err z-value P(>|z|)
eigenvector.frug ~
Size 0.536 NA
Morphology -0.042 NA
Covariances:
Estimate Std.Err z-value P(>|z|)
.Mass ~~
.Forearm 0.389 NA
.LMT ~~
.BUM 0.541 NA
Size ~~
Morphology 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.Mass 0.404 NA
.Forearm 0.471 NA
.LMT 0.394 NA
.BUM 0.957 NA
.eigenvectr.frg 0.819 NA
Size 0.571 NA
Morphology 0.581 NA
你能帮我找出问题所在吗?非常感谢。
我认为问题在于同一结构上指标之间的相关残差。您正试图以冗余的方式解释同一结构上指标之间的关系。
例如,潜在构造 "size" 可以解释指标变量 "mass" 和 "forearm." 之间的关系,那里的残差将被概念化为指标中的方差,即不是 由潜在结构解释。
但是你所做的是让残差相关,这模拟了 "mass" 和 "forearm" 之间的共享方差,这不是由潜在因素解释的。
问题在于您的潜在构造仅由这两个变量组成。你基本上是在告诉 lavaan
:"Model the variance between these two indicators as a latent construct... No wait! Also model that same variance as a residual!" 所以 lavaan
基本上是在告诉你,"That doesn't make sense, I can't do that!" 我会试试这个代码:
model2 <- "
# regressions
eigenvector.frug ~ Size + Morphology
# latent variables
Size =~ Mass + Forearm
Morphology =~ LMT + BUM
# covariances and variances
Mass ~~ Mass
Forearm ~~ Forearm
LMT ~~ LMT
BUM ~~ BUM
"
此代码隐式地将残差协方差固定为零。
您可能 运行 仍然遇到的另一个问题是未识别每个子模型。对于每个潜在变量,您正在尝试从 2 个未识别的指标中估计一个潜在构造(即,您有 3 个方差相关元素可供使用,但您正在估计 2 个残差、一个载荷和一个潜在方差) .为了解决这个问题,您可以将每个潜在因子的载荷限制为彼此相等。我们可以通过为因子载荷分配相同的标签来做到这一点(这里,每个因子 "a" 和 "b")。
model3 <- "
# regressions
eigenvector.frug ~ Size + Morphology
# latent variables
Size =~ a*Mass + a*Forearm
Morphology =~ b*LMT + b*BUM
# covariances and variances
Mass ~~ Mass
Forearm ~~ Forearm
LMT ~~ LMT
BUM ~~ BUM
"