FloSchuberth / cSEM

Composite-based SEM
https://floschuberth.github.io/cSEM/
GNU General Public License v3.0
28 stars 8 forks source link

`vcov()` for cSEM models? #542

Closed ihrke closed 2 months ago

ihrke commented 2 months ago

I am trying to extract the estimated covariance matrix of the parameter estimates from the fitted model in cSEM. In lavaan, the vcov() method returns this matrix but the function is not implemented for the class cSEMResults. I could not find it in the Estimates field of the fitted model either. Is there a way to extract that matrix from the model object?

emstruong commented 2 months ago

Hi,

Is res$Estimates$Proxy_VCV or res$Estimates$Construct_VCV what you're looking for?

Michael

ihrke commented 2 months ago

I don't think so - these seem to be the covariances between the latent variables/constructs themselves but not between the estimated regression coefficients, right?

emstruong commented 2 months ago

True, I didn't even know this was a thing--I was under the impression that this isn't something to be computed. I think someone else would be better suited to answer

FloSchuberth commented 2 months ago

@ihrke : Hey, there is no function to extract the variance-covariance matrix of the parameters. The main reason for that is that there is no closed-form expression for that and the SEs of the parameters are determined via bootstrap. What you could do is run the model with bootstrap, i.e., .resample_method = 'bootstrap' The resulting cSEM object contains now the bootstrap results: fit$Estimates$Estimates_resample Using these estimates, you can estimate the variance-covariance matrix of the parameters estimates. In the following a small example for the variance-covariance matrix of the path coefficients: model <- " EXPE ~ IMAG QUAL ~ EXPE VAL ~ EXPE + QUAL SAT ~ IMAG + EXPE + QUAL + VAL LOY ~ IMAG + SAT

IMAG <~ imag1 + imag2 + imag3 EXPE <~ expe1 + expe2 + expe3 QUAL <~ qual1 + qual2 + qual3 + qual4 + qual5 VAL <~ val1 + val2 + val3

SAT =~ sat1 + sat2 + sat3 + sat4 LOY =~ loy1 + loy2 + loy3 + loy4 "

res <- csem(.data = satisfaction, .model = model,.resample_method = 'bootstrap') cov(res$Estimates$Estimates_resample$Estimates1$Path_estimates$Resampled)

Does this help?

ihrke commented 2 months ago

That's what I was looking for, thanks a lot @FloSchuberth!