No BSD License  

Highlights from
Jackknife a statistic

image thumbnail

Jackknife a statistic

by

 

15 Apr 2007 (Updated )

(Extension of JACKKNIFE)

jstats(res,varargin)
function[m,varargout] = jstats(res,varargin)
% JKNIFE     Jackknifed mean and variance 
% INPUTS  :  res   - array or structure array output by JKNIFEP
%            field - if res is a structure array, field storing statistic x
% OUTPUTS  : m     - jackknife mean estimate
%            v     - (optional) jackknife variance estimate 
% EXAMPLE  : See JKNIFEDEMO 
% SEE ALSO : JKNIFE, BSTRAP; JACKKNIFE, BOOTSTRP (Statistics Toolbox)
% REF.     : Shao and Tu (1995), pp. 5-6
% AUTHOR   : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 4/15/07

switch nargin
    case 0
         error('Input argument "res" is undefined') 
    case 1
         if isstruct(res)
            error('Input argument "field" must be provided if "res" is a structure')
         else
            x0 = res(:,:,1);
            x  = res(:,:,2:end);
         end   
    case 2
         if ~isstruct(res)
            error('Input argument "field" is provided, but "res" is not a structure')
         else
            try 
                field = char(varargin);
            catch
                error('Input argument "field" must be a string')
            end
            try
                x = eval(['res(1).' field]);
            catch
                error(['Field ' field ' not found in "res"'])
            end   
            n = length(res);
            x  = repmat(x,[1 1 n-1]);
            x0 = eval(['[res(1).' field ']']);
            for m = 2:n
                x(:,:,m-1) = eval(['[res(m).' field ']']);
            end
         end    
end
n  = size(x,3);
mj = mean(x,3);
m  = n*x0 - (n-1)*mj;
if nargout > 1
   s = 0;
   for j = 1:n
       d = x(:,:,j) - mj;
       s = s + (d.^2);
   end  
   varargout(1) = {((n-1)/n)*s};
end   

Contact us