Single-level and multi-level mediation analyses for any kind of data, with bootstrap-based significance testing. Neuroimaging-oriented functions allow for mediation effect parametric mapping (mapping of mediation effects across the brain) and multivariate mediation.
I am using this function in my own code and found that it was not giving the correct Z values at times. I narrowed down the problem to situations when the effect is negative.
I changed my version of this function to do the following:
% adjust for acceleration
Z_1 = (ZPCTlower.(1-acc.zh0)-zh0)./(1+acc.ZPCTlower);
Z_2 = (ZPCTupper.(1-acc.zh0)-zh0)./(1+acc.ZPCTupper);
% which tail are we in?
% If there is more of the distribution to the left of zero, then we
% are in the lower tail
if PCTlower < PCTupper
Z = Z_2;
else
% otherwise we are in the other tail
Z = -Z_1;
end
I am using this function in my own code and found that it was not giving the correct Z values at times. I narrowed down the problem to situations when the effect is negative.
I changed my version of this function to do the following: % adjust for acceleration Z_1 = (ZPCTlower.(1-acc.zh0)-zh0)./(1+acc.ZPCTlower); Z_2 = (ZPCTupper.(1-acc.zh0)-zh0)./(1+acc.ZPCTupper);