You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suspect this error from the observation of a counterintuitive output for a simple mediation analysis with these 3 vectors as X, M, and Y variables. There is a significant negative effect after BCa correction of path c; however, the CI output always spans from negative to slightly positive number (e.g. -0.0213 to 0.0034). Please see the attached output saved from the "stats" variable.
I narrow this issue to the code from this script “bootbca_ci.m”. I understand this script works well for the positive effect, but maybe with a negative effect, the ci_upper and ci_lower should switched to obtain the asymmetric confidence interval before BCa manipulation.
% lower tail is smaller for positive effect. is_lowertail == 1 effects
% should be positive.
is_lowertail = pct_lowertail < pct_uppertail;
ci = [ci_lower ci_upper];
clear ci
for i=1:size(ci_lower, 1)
if is_lowertail(i) == 1
ci(i,1) = ci_lower(i,i);
ci(i,2) = ci_upper(i,i);
else
ci(i,1) = ci_lower_n(i,i);
ci(i,2) = ci_upper_n(i,i);
end
end
I suspect this error from the observation of a counterintuitive output for a simple mediation analysis with these 3 vectors as X, M, and Y variables. There is a significant negative effect after BCa correction of path c; however, the CI output always spans from negative to slightly positive number (e.g. -0.0213 to 0.0034). Please see the attached output saved from the "stats" variable.
I narrow this issue to the code from this script “bootbca_ci.m”. I understand this script works well for the positive effect, but maybe with a negative effect, the ci_upper and ci_lower should switched to obtain the asymmetric confidence interval before BCa manipulation.
a1 = z_0 + ( (z_0 + zalpha1) ./ (1 - a .* (z_0 + zalpha1)) );
p1 = normcdf(a1);
a2 = z_0 + ( (z_0 + zalpha2) ./ (1 - a .* (z_0 + zalpha2)) );
p2 = normcdf(a2);
ci_lower = prctile(bstat, 100 .* p1);
ci_upper = prctile(bstat, 100 .* p2);
% SC added: ------
ci_lower_n = prctile(bstat, 100 .* (1.-p2));
ci_upper_n = prctile(bstat, 100 .* (1.-p1));
testvalue = 0;
% prctile of the distribution below nullvalue (2-tailed)
% pct = min( [sum(bstat < testvalue); sum(bstat > testvalue)] ) ./ B;
pct_lowertail = sum(bstat < testvalue) ./ B;
pct_uppertail = sum(bstat > testvalue) ./ B;
% lower tail is smaller for positive effect. is_lowertail == 1 effects
% should be positive.
is_lowertail = pct_lowertail < pct_uppertail;
ci = [ci_lower ci_upper];
clear ci
for i=1:size(ci_lower, 1)
if is_lowertail(i) == 1
ci(i,1) = ci_lower(i,i);
ci(i,2) = ci_upper(i,i);
else
ci(i,1) = ci_lower_n(i,i);
ci(i,2) = ci_upper_n(i,i);
end
end
example data input and output file
https://drive.google.com/file/d/1X2iIecCE2WjQpyh2bqz3QmlmjsnT3i-0/view?usp=sharing
The text was updated successfully, but these errors were encountered: