首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从lavaan中提取误差协方差矩阵

从lavaan中提取误差协方差矩阵
EN

Stack Overflow用户
提问于 2021-02-18 23:37:25
回答 1查看 50关注 0票数 1

我想从sem()中提取误差协方差矩阵,但我不知道我做得是否正确。我使用了inspect("cov.ov"),对于"cov.ov",文档中写着“模型隐含的方差-协方差矩阵”。因此,这与误差协方差矩阵相同吗?代码如下:

代码语言:javascript
复制
# convert vector of correlations into matrix
   wisc4.cor <- lav_matrix_lower2full(c(1,0.72,1,0.64,0.63,1,0.51,0.48,0.37,1,0.37,0.38,0.38,0.38,1))
# enter the SDs
   wisc4.sd <- c(3.01 , 3.03 , 2.99 , 2.89 , 2.98)
# name the variables
   colnames(wisc4.cor) <- rownames(wisc4.cor) <- c("Information", "Similarities", "Word.Reasoning", "Matrix.Reasoning", "Picture.Concepts")
   names(wisc4.sd) <-  c("Information", "Similarities", "Word.Reasoning", "Matrix.Reasoning", "Picture.Concepts")
# convert correlations and SDs to covarainces
   wisc4.cov <- cor2cov(wisc4.cor,wisc4.sd)
# specify single factor model
   wisc4.model<-'
   g =~ a*Information + b*Similarities + c*Word.Reasoning + d*Matrix.Reasoning + e*Picture.Concepts
'
# fit model
   wisc4.fit <- sem(model=wisc4.model, sample.cov=wisc4.cov, sample.nobs=550,  std.lv=FALSE)
#does this extract the error covariance matrix?
   inspect(wisc4.fit, "cov.ov")
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-19 08:07:08

你想要残差的覆盖矩阵:

代码语言:javascript
复制
residuals(wisc4.fit)$cov
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66263180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档