Skip to content

Commit

Permalink
minor changes to printed output of bootknife
Browse files Browse the repository at this point in the history
- corrected printed function name when bootfun is provided as function name and additional input arguments in a cell array
- corrected printed nominal coverage of interval when bootfun is @mean or 'mean'
  • Loading branch information
acp29 committed Jan 7, 2023
1 parent c10929f commit 5a54051
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: statistics-bootstrap
version: 5.1.0
date: 2022-12-13
version: 5.1.1
date: 2023-01-07
author: Andrew Penn <[email protected]>
maintainer: Andrew Penn <[email protected]>
title: A statistics package with a variety of bootstrap resampling tools
Expand Down
27 changes: 15 additions & 12 deletions inst/bootknife.m
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,24 @@
if (iscell (bootfun))
if (ischar (bootfun{1}))
% Convert character string of a function name to a function handle
bootfun_str = bootfun{1};
func = str2func (bootfun{1});
else
bootfun_str = func2str (bootfun{1});
func = bootfun{1};
end
args = bootfun(2:end);
bootfun = @(varargin) func (varargin{:}, args{:});
end
if (ischar (bootfun))
elseif (ischar (bootfun))
% Convert character string of a function name to a function handle
bootfun_str = bootfun;
bootfun = str2func (bootfun);
end
if (~ isa (bootfun, 'function_handle'))
error ('bootknife: BOOTFUN must be a function name or function handle');
elseif (isa (bootfun, 'function_handle'))
bootfun_str = func2str (bootfun);
else
error ('bootknife: BOOTFUN must be a function name or function handle')
end
end
% Store bootfun as string for printing output at the end
bootfun_str = func2str (bootfun);
if (iscell (x))
% If DATA is a cell array of equal size colunmn vectors, convert the cell
% array to a matrix and redefine bootfun to parse multiple input arguments
Expand Down Expand Up @@ -733,7 +734,9 @@
if (~ isnan (alpha))
% If bootfun is the arithmetic meam, perform expansion based on t-distribution
if (strcmp (func2str (bootfun), 'mean'))
alpha = (3 - nalpha) * localfunc.ExpandProbs (alpha / (3 - nalpha), n - K);
adj_alpha = (3 - nalpha) * localfunc.ExpandProbs (alpha / (3 - nalpha), n - K);
else
adj_alpha = alpha;
end
state = warning;
if ISOCTAVE
Expand Down Expand Up @@ -787,18 +790,18 @@
'unable to calculate the bias correction constant, reverting to percentile intervals\n');
z0 = 0;
a = 0;
l = [alpha / 2, 1 - alpha / 2];
l = [adj_alpha / 2, 1 - adj_alpha / 2];
end
if (isempty (l))
% Calculate BCa or BC percentiles
z1 = stdnorminv (alpha / 2);
z2 = stdnorminv (1 - alpha / 2);
z1 = stdnorminv (adj_alpha / 2);
z2 = stdnorminv (1 - adj_alpha / 2);
l = cat (2, stdnormcdf (z0 + ((z0 + z1) / (1 - a * (z0 + z1)))),...
stdnormcdf (z0 + ((z0 + z2) / (1 - a * (z0 + z2)))));
end
case 2
% alpha is a vector of probabilities
l = alpha;
l = adj_alpha;
end
% Intervals constructed from kernel density estimate of the bootstrap
% (with shrinkage correction)
Expand Down

0 comments on commit 5a54051

Please sign in to comment.