# How to generate A matrice and S matrice for the second stage of TSSEM?

1 post / 0 new
Offline
Joined: 10/16/2021 - 12:33
How to generate A matrice and S matrice for the second stage of TSSEM?

Hi Milke and all,

I'm trying to run a TSSEM to examine the mediation effect for a meta-analysis. However, I'm not sure what's the appropriate way to create the A matrice and S matrice needed for stage 2. Would you please advise?

On your Cheung & Cheung 2014 paper, I saw that the A matrice and S matrice were created manually by typing in the code. Each correlation coefficient was listed in the code. Please see below for an example taken from the supplementary info of that paper. In your introduction of the metaSEM package (see the link below), you have first specified the model via the RAM formulation, you then used lavaan to generate the A and S matrices.

May I know whether I can use the second method to generate the matrices (by specifying a model first)? If not, would you please explain how can I determine 1) the value in weighting the correlation coefficient in the first method and 2) the correct order for the 0 and the weighted correlation coefficient? E.g., If I used the terms incorrectly, I was talking about the 0.2 in the "0.2b","0.2c" below.

Best wishes,
Iana

Example from Cheung & Cheung 2014 paper:
A1 <- create.mxMatrix(c(0,"0.2b","0.2c",
0,0,"0.2*a",
0,0,0),
type="Full", ncol=3, nrow=3, as.mxMatrix=FALSE, byrow=TRUE)
dimnames(A1) <- list(c("LS","JS","JA"), c("LS","JS","JA"))

Example from the introduction of the metaSEM package:

#### Prepare models for stage 2 analysis

model2 <- "## Math is modeled by Spatial and Verbal
Math ~ Spatial2MathSpatial + Verbal2MathVerbal
## Variances of predictors are fixed at 1
Spatial ~~ 1Spatial
Verbal ~~ 1
Verbal
## Correlation between the predictors
Spatial ~~ SpatialCorVerbalVerbal
## Error variance
Math ~~ ErrorVarMath
Math"

RAM2 <- lavaan2RAM(model2)

Cheung, M.W.-L., and Cheung, S.-F. (2014). Random effects models for meta-analytic structural equation modeling: Review, issues, and illustrations. Manuscript submitted for publication.

Introduction of the metaSEM package
https://cran.r-project.org/web/packages/metaSEM/vignettes/Examples.html#random-effects-tssem