Skip to content

Commit

Permalink
made calculation method of influence values consistent with the empin…
Browse files Browse the repository at this point in the history
…f function in the R 'boot' package
  • Loading branch information
acp29 committed May 13, 2024
1 parent d9cd6ce commit 510c1a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: statistics-resampling
version: 5.5.10
date: 2024-04-27
version: 5.5.11
date: 2024-05-13
author: Andrew Penn <[email protected]>
maintainer: Andrew Penn <[email protected]>
title: A statistics package with a variety of resampling tools
Expand Down
19 changes: 10 additions & 9 deletions inst/bootci.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,10 @@
otherwise

% Other interval types are natively supported in bootknife function
% Undocumented input argument for simple bootstrap resampling
% Use undocumented input argument 'loo' = false for simple bootstrap
% resampling (instead of bootknife resampling)
[stats, bootstat, bootsam] = bootknife (data, nboot, bootfun, alpha, ...
strata, ncpus, [], [], ISOCTAVE, true, loo);
strata, ncpus, [], [], ISOCTAVE, true, loo);

end

Expand Down Expand Up @@ -763,9 +764,9 @@
%! % normal | 81.5% | 3.0% | 15.5% | 0.77 | 1.21 |
%! % percentile | 81.5% | 0.9% | 17.6% | 0.76 | 0.91 |
%! % basic | 81.1% | 2.5% | 16.4% | 0.78 | 1.09 |
%! % BCa | 84.2% | 5.4% | 10.4% | 0.86 | 1.82 |
%! % BCa | 83.9% | 5.2% | 10.9% | 0.83 | 1.84 |
%! % bootstrap-t | 89.2% | 4.3% | 6.5% | 0.99 | 2.15 |
%! % calibrated | 87.4% | 4.2% | 8.4% | 0.91 | 2.03 |
%! % calibrated | 88.9% | 3.7% | 7.4% | 0.89 | 2.04 |
%! % ---------------------|----------|--------|--------|--------|-------|
%! % parametric - exact | 90.8% | 3.7% | 5.5% | 0.99 | 2.52 |

Expand Down Expand Up @@ -852,8 +853,8 @@
%! ci = bootci(1999,{{@var,1},A},'alpha',0.1,'type','bca','seed',1);
%! if (isempty (regexp (which ('boot'), 'mex$')))
%! % test boot m-file result
%! assert (ci(1), 115.3439904214919, 1e-07);
%! assert (ci(2), 254.8041855869813, 1e-07);
%! assert (ci(1), 115.9276292059273, 1e-07);
%! assert (ci(2), 255.789475809047, 1e-07);
%! end
%!
%! % Nonparametric 90% bootstrap-t confidence intervals (double bootstrap)
Expand Down Expand Up @@ -883,7 +884,7 @@
%! % Probability 57 (Springer)
%! LSAT = [576 635 558 578 666 580 555 661 651 605 653 575 545 572 594].';
%! GPA = [3.39 3.3 2.81 3.03 3.44 3.07 3 3.43 ...
%! 3.36 3.13 3.12 2.74 2.76 2.88 2.96].';
%! 3.36 3.13 3.12 2.74 2.76 2.88 2.96].';
%!
%! % Nonparametric 90% percentile confidence intervals (single bootstrap)
%! % Percentile intervals on page 266 are 0.524 - 0.928
Expand All @@ -899,8 +900,8 @@
%! ci = bootci(1999,{@cor,LSAT,GPA},'alpha',0.1,'type','bca','seed',1);
%! if (isempty (regexp (which ('boot'), 'mex$')))
%! % test boot m-file result
%! assert (ci(1), 0.4107777334127511, 1e-07);
%! assert (ci(2), 0.9234715078308394, 1e-07);
%! assert (ci(1), 0.4132871532174259, 1e-07);
%! assert (ci(2), 0.9237685885933666, 1e-07);
%! end
%!
%! % Nonparametric 90% calibrated percentile confidence intervals
Expand Down
10 changes: 5 additions & 5 deletions inst/bootclust.m
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@
end
end
% Calculate empirical influence function
U = (nx - 1) * bsxfun (@minus, mean (T, 2), T);
U = (nx - 1) * bsxfun (@minus, T0, T);
a = sum (U.^3, 2) ./ (6 * sum (U.^2, 2) .^ 1.5);
catch
% Revert to bias-corrected (BC) bootstrap confidence intervals
Expand Down Expand Up @@ -1058,8 +1058,8 @@ function print_output (stats, nboot, nalpha, alpha, probs, m, bootfun_str, ...
%! assert (stats.original, 171.534023668639, 1e-08);
%! assert (stats.bias, -6.916841556872669, 1e-08);
%! assert (stats.std_error, 42.5668171689963, 1e-08);
%! assert (stats.CI_lower, 117.0129329921189, 1e-08);
%! assert (stats.CI_upper, 269.5860065995567, 1e-08);
%! assert (stats.CI_lower, 117.211853429442, 1e-08);
%! assert (stats.CI_upper, 270.1620774419748, 1e-08);
%! end
%!
%! % Exact intervals based on normal theory are 118.4 - 305.2 (Table 14.2)
Expand Down Expand Up @@ -1097,6 +1097,6 @@ function print_output (stats, nboot, nalpha, alpha, probs, m, bootfun_str, ...
%! assert (stats.original, 0.7763744912894071, 1e-08);
%! assert (stats.bias, -0.007472442917410338, 1e-08);
%! assert (stats.std_error, 0.1355235987517371, 1e-08);
%! assert (stats.CI_lower, 0.4179653612679617, 1e-08);
%! assert (stats.CI_upper, 0.9240227537437981, 1e-08);
%! assert (stats.CI_lower, 0.4193007209659811, 1e-08);
%! assert (stats.CI_upper, 0.9242671615802232, 1e-08);
%! end
19 changes: 10 additions & 9 deletions inst/bootknife.m
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@
% Calculate empirical influence function
if (~ isempty (strata))
gk = sum (g .* repmat (nk, n, 1), 2).';
U = bsxfun (@times, gk - 1, bsxfun (@minus, mean (T, 2), T));
U = bsxfun (@times, gk - 1, bsxfun (@minus, T0, T));
else
U = (n - 1) * bsxfun (@minus, mean (T, 2), T);
U = (n - 1) * bsxfun (@minus, T0, T);
end
a = sum (U.^3, 2) ./ (6 * sum (U.^2, 2) .^ 1.5);
catch
Expand Down Expand Up @@ -1443,7 +1443,7 @@ function print_output (stats, nboot, alpha, l, m, bootfun_str, strata)
%! % method | 0.05 | 0.95 | length | shape |
%! % --------------------------------------|--------|--------|--------|-------|
%! % ci2 - percentile (equal-tailed) | 96.2 | 237.2 | 141.0 | 0.87 |
%! % ci4 - BCa | 115.3 | 263.8 | 148.5 | 1.64 |
%! % ci4 - BCa | 116.1 | 265.1 | 149.0 | 1.69 |
%! % ci6a - calibrated (equal-tailed) | 83.0 | 252.9 | 169.9 | 0.92 |
%! % ci6b - calibrated | 113.2 | 282.4 | 169.2 | 1.90 |
%! % --------------------------------------|--------|--------|--------|-------|
Expand All @@ -1458,13 +1458,14 @@ function print_output (stats, nboot, alpha, l, m, bootfun_str, strata)
%! % method | coverage | lower | upper | length | shape |
%! % ---------------------------|----------|--------|--------|--------|-------|
%! % percentile (equal-tailed) | 81.9% | 1.3% | 16.8% | 0.78 | 0.91 |
%! % BCa | 85.6% | 5.2% | 9.2% | 0.87 | 1.84 |
%! % BCa | 85.0% | 4.6% | 10.4% | 0.85 | 1.82 |
%! % calibrated (equal-tailed) | 90.0% | 0.1% | 9.9% | 1.01 | 1.04 |
%! % calibrated | 90.3% | 4.5% | 5.2% | 0.99 | 2.21 |
%! % ---------------------------|----------|--------|--------|--------|-------|
%! % parametric - exact | 90.8% | 3.7% | 5.5% | 0.99 | 2.52 |
%!
%! % Summary of bias statistics from 'boot' package in R
%! % Summary of bias statistics computed using the 'statistics-resampling'
%! % package for Octave/Matlab
%! %
%! % method | original | bias | bias-corrected |
%! % -----------------------------------|----------|---------|----------------|
Expand Down Expand Up @@ -1607,8 +1608,8 @@ function print_output (stats, nboot, alpha, l, m, bootfun_str, strata)
%! assert (stats.original, 171.534023668639, 1e-08);
%! assert (stats.bias, -6.916841556872669, 1e-08);
%! assert (stats.std_error, 42.5668171689963, 1e-08);
%! assert (stats.CI_lower, 117.0129329921189, 1e-08);
%! assert (stats.CI_upper, 269.5860065995567, 1e-08);
%! assert (stats.CI_lower, 117.211853429442, 1e-08);
%! assert (stats.CI_upper, 270.1620774419748, 1e-08);
%! end
%!
%! % Nonparametric 90% calibrated equal-tailed percentile confidence intervals
Expand Down Expand Up @@ -1670,8 +1671,8 @@ function print_output (stats, nboot, alpha, l, m, bootfun_str, strata)
%! assert (stats.original, 0.7763744912894071, 1e-08);
%! assert (stats.bias, -0.008589727569214833, 1e-08);
%! assert (stats.std_error, 0.1440139406035633, 1e-08);
%! assert (stats.CI_lower, 0.3954734403669555, 1e-08);
%! assert (stats.CI_upper, 0.9323937461477884, 1e-08);
%! assert (stats.CI_lower, 0.3970241602178715, 1e-08);
%! assert (stats.CI_upper, 0.9326378952057675, 1e-08);
%! end
%!
%! % Nonparametric 90% calibrated equal-tailed percentile confidence intervals
Expand Down

0 comments on commit 510c1a7

Please sign in to comment.