canlab/MediationToolbox

bootbca_pval.m when distribution is to the left of Zero

steffejr opened this issue · 0 comments

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