You are here

Mediation Model

4 posts / 0 new
Last post
Kwabenaaaddo's picture
Offline
Joined: 02/01/2021 - 08:16
Mediation Model
AttachmentSize
PDF icon Model142.1 KB

Hello all,

I am trying to fit a mediation model where each of my main variables (BS, IND, WOB, DUA, BMEET and DIROWN) is mediated by another variable(BNKRISK). I have been following the model following Cheung (2021): Synthesizing Indirect Effects in Mediation Models with Meta-Analytic Methods: Supplementary Materials 2. I will proceed sequentially using to help you to follow the steps and where I encountered the error. This the model is

#Step 1##Mediation Model
model10 <- "PERF ~ c*BS + b*BNKRISK+f*IND+i*WOB+l*DUA+o*BMEET+r*DIROWN+BSIZE+LEV
BNKRISK ~ a*BS
BNKRISK ~ d*IND
BNKRISK ~ g*WOB
BNKRISK ~ j*DUA
BNKRISK ~ m*BMEET
BNKRISK ~ p* DIROWN
BS ~~ 1*BS
IND ~~ 1*IND
WOB ~~ 1*WOB
DUA ~~ 1*DUA
BMEET ~~ 1*BMEET
DIROWN ~~ 1*DIROWN
BSIZE ~~ 1*BSIZE
LEV ~~ 1*LEV
## Define indirect and direct effects
Ind_BS := a*b
Ind_IND := d*b
Ind_WOB := g*b
Ind_DUA := j*b
Ind_BMEET := m*b
Ind_DIROWN := p*b
Dir_BS := c
Dir_IND := f
Dir_WOB := i
Dir_DUA := l
Dir_BMEET := o
Dir_DIROWN := r"

When I plot the model using the syntax below, it is represented as I expect graphically (see the attached)
#Step 2##Display model
plot(model10)

However, when I attempt to fit the tssem, I face the following error, which is from the model I specified. The syntax to fit the model is this:

#Step 3# Convert the lavaan syntax to RAM specification used in metaSEM
RAM1 <- lavaan2RAM(model10, obs.variables= varnames)
RAM1
## Request the likelihood-based confidence interval

tssem.fit <- tssem2(stage1random, RAM=RAM1, intervals.type = "LB",
mx.algebras = list(ind_BS=mxAlgebra(a*b, name="ind_BS"),ind_IND=mxAlgebra(d*b, name="ind_IND"),ind_WOB=mxAlgebra(g*b, name="ind_WOB"),ind_DUA=mxAlgebra(j*b, name="ind_DUA"),ind_BMEET=mxAlgebra(m*b, name="ind_BMEET"),ind_DIROWN=mxAlgebra(p*b, name="ind_DIROWN"),
Dir_BS=mxAlgebra(c, name="Dir_BS"),Dir_IND=mxAlgebra(f, name="Dir_IND"),Dir_WOB=mxAlgebra(i, name="Dir_WOB"),Dir_DUA=mxAlgebra(l, name="Dir_DUA"),Dir_BMEET=mxAlgebra(o, name="Dir_BMEET"),Dir_DIROWN=mxAlgebra(r, name="Dir_DIROWN")))

The error report as :
Error in running the mxModel:

Warning messages:
1: In .solve(x = object$mx.fit@output$calculatedHessian, parameters = my.name) :
Error in solving the Hessian matrix. Generalized inverse is used. The standard errors may not be trustworthy.

2: Unknown reference 'd' detected in the entity 'ind_IND' in model 'TSSEM2 Correlation' .

Can anyone help me with where I specified the model wrongly? Thanks in advance

Regards.

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Please provide the data and R

Please provide the data and R code for reproducibility.

Kwabenaaaddo's picture
Offline
Joined: 02/01/2021 - 08:16
Dear Prof Cheung,

Dear Prof Cheung,

Many thanks for your response. I have attached the data and codes as requested.
Could you let me know if it is still good to run my 2nd stage (model) with the stage1 or stage1_rerun estimates.

Kindest Regards.

File attachments: 
Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
As there are only a few data

As there are only a few data points in some of these cells, there are not enough data to compute the average correlation matrix.

> pattern.na(cordat, show.na = FALSE)
         BS IND WOB DUA BMEET DIROWN BNKRISK BSIZE LEV PERF
BS      142 108  29  36    17     14      78    96  89  111
IND     108 146  30  34    20     14      95    90  77  113
WOB      29  30  36   9     7      2      23    25  22   29
DUA      36  34   9  54     5      3      34    35  32   36
BMEET    17  20   7   5    25      1      14    19  10   21
DIROWN   14  14   2   3     1     19       7     8  11   13
BNKRISK  78  95  23  34    14      7     127    81  72   97
BSIZE    96  90  25  35    19      8      81   143  88  114
LEV      89  77  22  32    10     11      72    88 127   99
PERF    111 113  29  36    21     13      97   114  99  169