function [ci, y] = ciboot(x,theta,method,C,B,p1,p2,p3,p4,p5,p6,p7,p8,p9) %CIBOOT Bootstrap confidence interval. % % ci = ciboot(x,'T',method,C,B) % % Compute a bootstrap confidence interval for T(X) with level % C. Default for C is 0.90. Number of resamples is B, with default % that is different for different methods. The method is % % 1. Normal approximation (std is bootstrap). % 2. Simple bootstrap principle (bad, don't use). % 3. Studentized, std is computed via jackknife (If T is % 'mean' this done the fast way via the routine TEST1B). % 4. Studentized, std is 30 samples' bootstrap. % 5. Efron's percentile method. % 6. Efron's percentile method with bias correction (BC). % % Default method is 5. Often T(X) is a number but it may also % be a vector or even a matrix. Every row of the result ci % is of the form % % [LeftLimit, PointEstimate, RightLimit] % % and the corresponding element of T(X) is found by noting % that t = T(X); t = t(:); is used in the routine. Try for % example X = rand(13,2), C = cov(X), ci = ciboot(X,'cov'). % % See also STDBOOT and STDJACK. % Anders Holtsberg, 1994, 1998 % Copyright (c) Anders Holtsberg % referred from http://www.koders.com if nargin < 5, B = []; end if nargin < 4, C = []; end if nargin < 3, method = []; end arglist = []; for i = 6:nargin arglist = [arglist, ',p', num2str(i-5)]; end if min(size(x)) == 1 x = x(:); end if isempty(method) method = 5; end if isempty(C) C = 0.9; end alpha = (1-C)/2; [n,nx] = size(x); % === 1 ================================================ if method == 1 if isempty(B), B = 500; end s = eval(['stdboot(x,theta,B',arglist,')']); s = s(:); t0 = eval([theta,'(x',arglist,')']); t0 = t0(:); z = qnorm(1-(1-C)/2); ci = [t0-z*s, t0, t0+z*s]; return; end % === 2 5 6 ============================================== if method == 2 | method == 5 | method == 6 if isempty(B), B = 500; end [s,y] = eval(['stdboot(x,theta,B',arglist,')']); t0 = eval([theta,'(x',arglist,')']); t0 = t0(:); if method == 2 | method == 5 q = quantile(y',[alpha, 1-alpha]',1); if method == 2 ci = [2*t0-q(2,:)', t0, 2*t0-q(1,:)']; else ci = [q(1,:)', t0, q(2,:)']; end else t00 = t0(:,ones(size(y,2),1)); J = ((y 1, tic, fprintf('%4.0f %10.0f\n',B-i,flops-nfl), end end q = quantile(y',[alpha, 1-alpha]',1); ci = [t0-s0.*q(2,:)', t0, t0-s0.*q(1,:)']; return end