Obtaining Asymptotic Covariance Matrices using lavaan in R

61 views
Skip to first unread message

huiyuan gao

unread,
Nov 16, 2023, 2:15:01 AM11/16/23
to lavaan
I have a question regarding the use of the lavaan package in R for obtaining asymptotic covariance matrices (covariances of the regression coefficients). Is it possible to obtain asymptotic covariance matrices using lavaan  package?

Here are my syntax of my model, I am not sure whether is it correct? The output could be seen in attached figure.

setwd("D:/华为云盘/R_")
library(openxlsx)
usedata=read.xlsx("data.xlsx","data")
names(usedata)
library(psych)
describe(usedata[,c(3,63:66,81:82,77,80)])
mycor=corr.test(usedata[,c(3,63:66,81:82,77,80)])
lowerMat(mycor$r,digits=2)
lowerMat(mycor$p,digits=4)

library(lavaan)
mome="ZDMEAN~Dumgender+ZAFHf1+ZAMHf1+ZAFAMHf1+ZAFHf2+ZAMHf2+ZAFAMHf2
         ZER~Dumgender+ZAFHf1+ZAMHf1+ZAFAMHf1+ZAFHf2+ZAMHf2+ZAFAMHf2
         ZDMEAN~~ZER"
set.seed(1234)
mome.fit=sem(mome,data=usedata,
             se="bootstrap",
             bootstrap=1000,
             mimic="mplus")
summary(mome.fit,standardized=TRUE,
        fit.measures=TRUE,
        rsquare=TRUE)
cov_matrix <- vcov(mome.fit)
print(cov_matrix)


output.png

Christian Arnold

unread,
Nov 16, 2023, 2:52:22 AM11/16/23
to lavaan
This should work. lavInspect allows a few additional options (for example, the variance covariance matrix of the standardized estimated model parameters). In your case lavInspect(mome.fit, "vcov").
Reply all
Reply to author
Forward
0 new messages