You are here

Mediation analysis

9 posts / 0 new
Last post
jode's picture
Offline
Joined: 08/21/2015 - 08:02
Mediation analysis

Hi,
I would like to perform a mediation analysis by defining the indirect effects with mx.algebras in the wls() funktion.
I tried mx.algebras= list( ind=mxAlgebra(b410*b14, name="ind"))), where b410 and b14 refer to the paths in the A matrix. However, I get the following error in the analysis:

Error in running the mxModel:

Error in wls(Cov = R, asyCov = acov, n = n, Smatrix = S, Amatrix = A, :
object 'out' not found
In addition: Warning message:
In runHelper(model, frontendStart, intervals, silent, suppressWarnings, :
SLSQP: Failed due to singular matrix E or C in LSQ subproblem or rank-deficient equality constraint subproblem or positive directional derivative in line search

What I am doing wrong?
Looking forward to your help. Thanks!

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Hi, Johannes. Could you

Hi, Johannes.

Could you please include the data and R code so that we can replicate the error?

Mike

jode's picture
Offline
Joined: 08/21/2015 - 08:02
Thanks, I atteched the R

Thanks, I atteched the R file.

Johannes

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Hi, Johannes. I have

Hi, Johannes.

I have identified two issues: (1) the variances of the independent variables are not fixed at 1; and (2) some of the independent variables are not correlated.

Based on your A matrix, I have modified the S matrix. Attached are the results. Hope it helps.

Mike

jode's picture
Offline
Joined: 08/21/2015 - 08:02
Hi Mike, Thank you very much!

Hi Mike,

Thank you very much! That helps a lot!

Johannes

jode's picture
Offline
Joined: 08/21/2015 - 08:02
I just saw that you specified

I just saw that you specified in the S matrix ".3cor106" and ".3cor116" twice. Was that intendet?
When I change it to ".3cor106" and ".3cor107" and ".3cor116" and ".3cor11t" I have a model with df = 0. Then I cannot check my model fit right? Therefore, I would leave some correlations out that also make not really sense from a theoretical perspective?

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Oh, yes. It was a mistake.

Oh, yes. It was a mistake. They should be different. The model becomes saturated. Residuals are usually uncorrelated. You may consider this model.

jode's picture
Offline
Joined: 08/21/2015 - 08:02
Ok thanks. So how would you

Ok thanks. So how would you suggest to specify the model? Without correlated residuals?
Thanks for your help.

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
The models should be

The models should be specified based on your theories (hypotheses). If your theories hypothesize that all the association among the dependent variables can be explained by the independent variables, the residuals should be uncorrelated; otherwise, they can be correlated.

Mike