Hello, I am trying to replicate or come up with a very close estimate of the indirect effects in a mediation analysis with only 2 independent vars and 1 random intercept.
I found a user-written command to do this:
ml_mediation,dv(wheeze) iv(logfullkeyplus) mv(fac2) l2id(service)
basically it ran 4 mixed models as i would have run them myself.
mixed wheeze logfullkeyplus ||service:,
mixed wheeze fac2 ||service:,
mixed fac2 logfullkeyplus ||service:,
mixed wheeze logfullkeyplus fac2 ||service:,
the variable for service identifies 2 groups essentially that had different mean fac2 scores and different mean logfullkeyplus estimates.
The user-written command returns the following results after going through the mixed models shown above. note the bold value of ind_eff
The mediator, fac2, is a level 1 variable
c_path = .13245328
a_path = .08470836
b_path = .06471541
c_prime = .11837593 same as dir_eff
ind_eff = .00548194
dir_eff = .11837593
tot_eff = .12385786
proportion of total effect mediated = .04425989
ratio of indirect to direct effect = .04630955
ratio of total to direct effect = 1.0463095
Now I tried replicating this using gsem with the following commands:
gsem (wheeze<-logfullkeyplus M1[service]) ///
(wheeze<-fac2 M1[service]) ///
(fac2<- logfullkeyplus M2[service]), ///
cov(M1[service]*M2[service]@0) nolog
and when I calculate the indirect effect manually I get a very different result
nlcom _b[wheeze:logfullkeyplus]*_b[fac2:logfullkeyplus]
. nlcom _b[wheeze:logfullkeyplus]*_b[fac2:logfullkeyplus]
_nl_1: _b[wheeze:logfullkeyplus]*_b[fac2:logfullkeyplus]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .0147013 .0134135 1.10 0.273 -.0115886 .0409912
------------------------------------------------------------------------------
Could anyone tell me why the results are so different? I understand that I may not have specified the gsem correctly and that there is a warning on the website where the ml_mediation command can be found but which one is likely to be specified correctly?
thank you,
J-M
I found a user-written command to do this:
ml_mediation,dv(wheeze) iv(logfullkeyplus) mv(fac2) l2id(service)
basically it ran 4 mixed models as i would have run them myself.
mixed wheeze logfullkeyplus ||service:,
mixed wheeze fac2 ||service:,
mixed fac2 logfullkeyplus ||service:,
mixed wheeze logfullkeyplus fac2 ||service:,
the variable for service identifies 2 groups essentially that had different mean fac2 scores and different mean logfullkeyplus estimates.
The user-written command returns the following results after going through the mixed models shown above. note the bold value of ind_eff
The mediator, fac2, is a level 1 variable
c_path = .13245328
a_path = .08470836
b_path = .06471541
c_prime = .11837593 same as dir_eff
ind_eff = .00548194
dir_eff = .11837593
tot_eff = .12385786
proportion of total effect mediated = .04425989
ratio of indirect to direct effect = .04630955
ratio of total to direct effect = 1.0463095
Now I tried replicating this using gsem with the following commands:
gsem (wheeze<-logfullkeyplus M1[service]) ///
(wheeze<-fac2 M1[service]) ///
(fac2<- logfullkeyplus M2[service]), ///
cov(M1[service]*M2[service]@0) nolog
and when I calculate the indirect effect manually I get a very different result
nlcom _b[wheeze:logfullkeyplus]*_b[fac2:logfullkeyplus]
. nlcom _b[wheeze:logfullkeyplus]*_b[fac2:logfullkeyplus]
_nl_1: _b[wheeze:logfullkeyplus]*_b[fac2:logfullkeyplus]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .0147013 .0134135 1.10 0.273 -.0115886 .0409912
------------------------------------------------------------------------------
Could anyone tell me why the results are so different? I understand that I may not have specified the gsem correctly and that there is a warning on the website where the ml_mediation command can be found but which one is likely to be specified correctly?
thank you,
J-M