canlab / MediationToolbox

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.
https://canlabweb.colorado.edu/wiki/doku.php/help/mediation/m3_mediation_fmri_toolbox
78 stars 28 forks source link

bootbca_pval.m when distribution is to the left of Zero #2

Open steffejr opened 7 years ago

steffejr commented 7 years ago

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