Documentation |
Jackknife sampling
jackstat = jackknife(jackfun,X)
jackstat = jackknife(jackfun,X,Y,...)
jackstat = jackknife(jackfun,...,'Options',option)
jackstat = jackknife(jackfun,X) draws jackknife data samples from the n-by-p data array X, computes statistics on each sample using the function jackfun, and returns the results in the matrix jackstat. jackknife regards each row of X as one data sample, so there are n data samples. Each of the n rows of jackstat contains the results of applying jackfun to one jackknife sample. jackfun is a function handle specified with @. Row i of jackstat contains the results for the sample consisting of X with the ith row omitted:
s = x; s(i,:) = []; jackstat(i,:) = jackfun(s);
If jackfun returns a matrix or array, then this output is converted to a row vector for storage in jackstat. If X is a row vector, it is converted to a column vector.
jackstat = jackknife(jackfun,X,Y,...) accepts additional arguments to be supplied as inputs to jackfun. They may be scalars, column vectors, or matrices. jackknife creates each jackknife sample by sampling with replacement from the rows of the non-scalar data arguments (these must have the same number of rows). Scalar data are passed to jackfun unchanged. Non-scalar arguments must have the same number of rows, and each jackknife sample omits the same row from these arguments.
jackstat = jackknife(jackfun,...,'Options',option) provides an option to perform jackknife iterations in parallel, if the Parallel Computing Toolbox™ is available. Set 'Options' as a structure you create with statset. jackknife uses the following field in the structure:
'UseParallel' | If true and if a parpool of the Parallel Computing Toolbox is open, use multiple processors to compute jackknife iterations. If the Parallel Computing Toolbox is not installed, or a parpool is not open, computation occurs in serial mode. Default is false, or serial computation. |
Estimate the bias of the MLE variance estimator of random samples taken from the vector y using jackknife. The bias has a known formula in this problem, so you can compare the jackknife value to this formula.
sigma = 5; y = normrnd(0,sigma,100,1); m = jackknife(@var, y, 1); n = length(y); bias = -sigma^2 / n % known bias formula jbias = (n - 1)*(mean(m)-var(y,1)) % jackknife bias estimate bias = -0.2500 jbias = -0.3378