You are here

Specifying a Mediation Model in OpenMx using metaSEM

3 posts / 0 new
Last post
xander's picture
Joined: 11/09/2013 - 21:36
Specifying a Mediation Model in OpenMx using metaSEM

Hello All,

First of all thank you for your hard work over the years to provide us with unique ways to combine meta-analytic principles with SEM--and providing a conduit to do this in R. My research team and I really appreciate it.

I am doing a two stage MASEM with the metaSEM package, and am having some difficulty specifying a mediation analysis in the A/Smatrix. I have four variables: w,x,y,z. And my linear equations are as follows:

X ~ W + e
Z ~ W + e
Y ~ W + X + Z + e

I would like to see if X or Z (or X and Z) mediate the relationship between W and Y.

I specified the Amatrix and Smatrix as follows:
A1 <- mxMatrix("Full", nrow=4, ncol=4, byrow =TRUE, values=c(rep(0,4),1,rep(0,3),1,rep(0,3),1,1,1, 0),
free=c(rep(FALSE,4),TRUE,rep(FALSE,3),TRUE,rep(FALSE,3),TRUE,TRUE,TRUE, rep(FALSE,1)),
labels=c(rep(NA,4),"ethint",rep(NA,3),"ethind",rep(NA,3),"ethnicity","inter","indep", rep(NA,1)),

S1 <- mxMatrix(type="Symm",nrow=4,ncol=4,byrow=TRUE,values=c(1, 0, 0, 0, 0, 1, .5, 0, 0,.5, 1, 0, 0, 0, 0, 1),
labels=c("vareth",NA,NA, NA,NA,"varint","covintind", NA, NA, "covintind","varind", NA, NA, NA, NA, "residual"),

Is this the correct way to specify this mediation? I modeled it after the multivariate regression shown on (
When I run it with tssem2(), my model fit indices are all 0, 1, or Inf.

Thank you so much for your help!


xander's picture
Joined: 11/09/2013 - 21:36
Fixed!: Over-specifed Model

Sorry everyone,

I looked back and it seems like my model was overspecified. I simply put in an identity matrix for S1 and it works now.

Thank you anyways!


Mike Cheung's picture
Joined: 10/08/2009 - 22:37
Hi Xander, I assume that you

Hi Xander,

I assume that you are analyzing correlation matrices. It is correct to fix the variance of W (an independent variable) at 1. However, it is incorrect to fix the error variances of X, Z and Y (dependent variables) at 1. You may need to free these error variances. Moreover, the covariance between the errors of X and Z may also be freed.

BTW, there is a forum for the metaSEM package at Feel free to post questions related to metaSEM there.