You are here

Residual Covariance Matrix

8 posts / 0 new
Last post
Sedat KANADLI's picture
Joined: 08/15/2022 - 04:58
Residual Covariance Matrix
Image icon path diagram26.42 KB

Dear Mike,
A colleague and I studied the factor structure of a scale using the metaSEM package. The reviewers asked us for residual covariance matrice of structural model we construct. I couldn't see a command for this in the metaSEM package. There is vcov but this command gives sampling covariance matrices. Is there a way to see residual covariance matrices?

The script that we used to construct our model is ad follow:
sdeğ <- 6
değad <- c("m1","m2","m3","m4","m5","m6")
etiket <- list(değad,değad)
korver <- list()

for (i in 1:nrow(veri)){
korver[[i]] <- vec2symMat(as.matrix(veri[i,3:17]),diag = FALSE)
dimnames(korver[[i]]) <- etiket
REM1 <- tssem1(Cov=korver, n=veri$N, method="REM", RE.type="Diag")

RAM <- lavaan2RAM(model, obs.variables=c("M1","M2","M3","M4","M5", "M6"),
A.notation="on", S.notation="with")

REM2 <- tssem2(REM1, RAM=RAM, intervals="LB")

wls(Cov = pooledS, aCov = aCov, n = tssem1.obj$total.n, RAM = RAM,
Amatrix = Amatrix, Smatrix = Smatrix, Fmatrix = Fmatrix,
diag.constraints = diag.constraints, cor.analysis = cor.analysis,
intervals.type = intervals.type, mx.algebras = mx.algebras, =, suppressWarnings = suppressWarnings,
silent = silent, run = run)

95% confidence intervals: Likelihood-based statistic
Estimate Std.Error lbound ubound z value Pr(>|z|)
M1onFaktor1 0.75023 NA 0.69404 0.80902 NA NA
M2onFaktor1 0.81600 NA 0.75594 0.87878 NA NA
M3onFaktor1 0.72925 NA 0.67467 0.78664 NA NA
M4onFaktor2 0.79731 NA 0.72519 0.87357 NA NA
M5onFaktor2 0.80009 NA 0.72521 0.87772 NA NA
M6onFaktor2 0.79901 NA 0.72891 0.87430 NA NA
Faktor1withFaktor2 0.17314 NA 0.13774 0.20912 NA NA

Goodness-of-fit indices:
Sample size 5769.0000
Chi-square of target model 11.0801
DF of target model 8.0000
p value of target model 0.1972
Number of constraints imposed on "Smatrix" 0.0000
DF manually adjusted 0.0000
Chi-square of independence model 2034.0182
DF of independence model 15.0000
RMSEA 0.0082
RMSEA lower 95% CI 0.0000
RMSEA upper 95% CI 0.0186
SRMR 0.0193
TLI 0.9971
CFI 0.9985
AIC -4.9199
BIC -58.2020
OpenMx status1: 0 ("0" or "1": The optimization is considered fine.
Other values indicate problems.)


The path diagram is attached.

Mike Cheung's picture
Joined: 10/08/2009 - 22:37
The attached approach should

The attached approach should work.

File attachments: 
Sedat KANADLI's picture
Joined: 08/15/2022 - 04:58
Thank you very much. it

Thank you very much. it worked!

Sedat KANADLI's picture
Joined: 08/15/2022 - 04:58
Random effect Subgroup analysis

Dear Cheung,
We want to investigate whether and how the regression coefficients of the structural models differ across studies with sample of children or adult. In other words, is it possible to do Random effect model subgroup analysis?

Mike Cheung's picture
Joined: 10/08/2009 - 22:37
Yes, but not straightforward.

Yes, but not straightforward.

Instead of running the stage 2 model with tssem2(...), you may export the model and data to a mxmodel with tssem2(..., run=FALSE).

You may then use mxFitFunctionMultigroup() in OpenMx to conduct a multiple-group analysis directly.

Sedat KANADLI's picture
Joined: 08/15/2022 - 04:58
Random effect Subgroup analysis

Dear Mike,
Thank you very much for your replay. I'm pretty new to openmx. How to export my model and data to mxModel(). If we have stage 1 result (REM), RAM model and data file (ls), how can we write the mxModel and conduct tssem2.
if you don't mind can you write me the script or send me an example?
Best regards.

Mike Cheung's picture
Joined: 10/08/2009 - 22:37
It can be complicated.

It can be complicated.

It is easier to apply the OSMASEM approach by using a dummy code of children or adults as a predictor. There are a couple of examples, e.g.,

Sedat KANADLI's picture
Joined: 08/15/2022 - 04:58

Thanks, I'm reviewing both the codes and your article "Emotional Intelligence Mediates the Connection Between Mindfulness and Gratitude".