Skip to content

Commit 593b056

Browse files
author
acp29
committed
Update bootnhst.m
1 parent 5926a0c commit 593b056

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

inst/bootnhst.m

+27-26
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
% Bootstrap null hypothesis significance test (NHST)
44
%
55
% p = bootnhst(DATA,GROUP)
6-
% p = bootnhst(DATA,GROUP,ref)
7-
% p = bootnhst(DATA,GROUP,ref,bootfun,nboot)
8-
% p = bootnhst(DATA,GROUP,ref,bootfun,nboot)
9-
% p = bootnhst(DATA,GROUP,ref,bootfun,nboot,paropt)
6+
% p = bootnhst(DATA,GROUP,bootfun)
7+
% p = bootnhst(DATA,GROUP,bootfun,nboot)
8+
% p = bootnhst(DATA,GROUP,bootfun,nboot,ref)
9+
% p = bootnhst(DATA,GROUP,bootfun,nboot,ref,paropt)
1010
% [p,c] = bootnhst(DATA,GROUP,...)
1111
% [p,c,stats] = bootnhst(DATA,GROUP,...)
1212
% bootnhst(DATA,GROUP,...);
@@ -46,13 +46,7 @@
4646
% consideration in hypothesis testing but they will still contribute to
4747
% the estimate of the pooled (weighted mean) sampling variance.
4848
%
49-
% p = bootnhst(DATA,GROUP,ref) also sets the GROUP to use as the reference
50-
% GROUP for post hoc tests. For one-way ANOVA-like experimental designs this
51-
% will usually be the control GROUP. If all pairwise comparisons are desired,
52-
% then set ref to 'pairwise' or leave empty. By default, pairwise comparisons
53-
% are computed for post hoc tests.
54-
%
55-
% p = bootnhst(DATA,GROUP,ref,bootfun) also sets the statistic calculated
49+
% p = bootnhst(DATA,GROUP,bootfun) also sets the statistic calculated
5650
% from the bootstrap samples. This can be a function handle or string
5751
% corresponding to the function name. If empty, the default is @mean or
5852
% 'mean'. If DATA is multivariate, bootfun is the grand mean, which is
@@ -62,15 +56,22 @@
6256
% implements a smoothed version of the median (see function help for
6357
% smoothmedian).
6458
%
65-
% p = bootnhst(DATA,GROUP,ref,bootfun,nboot) sets the number of bootstrap
66-
% resamples. Increasing nboot reduces the monte carlo error of the p-value
67-
% estimates but the calculations take longer to complete. When nboot is
68-
% empty or not provided, the default (and minimum allowable nboot to
69-
% to compute two-tailed p-values down to 0.001) is 1000 - an error is
70-
% returned if the nboot provided by the user is lower than this.
59+
% p = bootnhst(DATA,GROUP,bootfun,nboot) sets the number of bootstrap
60+
% resamples. Increasing nboot reduces the monte carlo error of the p-
61+
% value estimates but the calculations take longer to complete. When
62+
% nboot is empty or not provided, the default (and minimum allowable
63+
% nboot to compute two-tailed p-values down to 0.001) is 1000 - an
64+
% error is returned if the nboot provided by the user is lower than
65+
% this.
66+
%
67+
% p = bootnhst(DATA,GROUP,bootfun,nboot,ref) also sets the GROUP to
68+
% use as the reference GROUP for post hoc tests. For one-way ANOVA-like
69+
% experimental designs this will usually be the control GROUP. If all
70+
% pairwise comparisons are desired, then set ref to 'pairwise' or leave
71+
% empty. By default, pairwise comparisons are computed for post hoc tests.
7172
%
72-
% p = bootnhst(DATA,GROUP,ref,bootfun,nboot,paropt) specifies options that
73-
% govern if and how to perform bootstrap iterations using multiple
73+
% p = bootnhst(DATA,GROUP,bootfun,nboot,ref,paropt) specifies options
74+
% that govern if and how to perform bootstrap iterations using multiple
7475
% processors (if the Parallel Computing Toolbox or Octave Forge package
7576
% is available). If empty, calculations are performed in serial.
7677
%
@@ -176,7 +177,7 @@
176177
% along with this program. If not, see <http://www.gnu.org/licenses/>.
177178

178179

179-
function [p, c, stats] = bootnhst (data, group, ref, bootfun, nboot, paropt)
180+
function [p, c, stats] = bootnhst (data, group, bootfun, nboot, ref, paropt)
180181

181182
% Check and process bootnhst input arguments
182183
nvar = size(data,2);
@@ -194,10 +195,7 @@
194195
group = cell2mat(group);
195196
end
196197
end
197-
if (nargin < 3) || strcmpi(ref,'pairwise')
198-
ref = [];
199-
end
200-
if (nargin < 4) || isempty(bootfun)
198+
if (nargin < 3) || isempty(bootfun)
201199
bootfun = @mean;
202200
end
203201
if isa(bootfun,'function_handle')
@@ -234,10 +232,10 @@
234232
bootfun = @smoothmedian;
235233
end
236234
elseif strcmpi(bootfun,'median')
237-
%error('bootfun cannot be the median, use ''robust'' instead.')
235+
error('bootfun cannot be the median, use ''robust'' instead.')
238236
end
239237
end
240-
if (nargin < 5) || isempty(nboot)
238+
if (nargin < 4) || isempty(nboot)
241239
nboot = 1000;
242240
else
243241
if nboot < 1000
@@ -247,6 +245,9 @@
247245
if any(size(nboot)>1)
248246
error('nboot must be scalar. bootnhst is not compatible with bootstrap iteration')
249247
end
248+
if (nargin < 5) || strcmpi(ref,'pairwise')
249+
ref = [];
250+
end
250251
if (nargin < 6) || isempty(paropt)
251252
paropt = struct;
252253
paropt.UseParallel = false;

0 commit comments

Comments
 (0)