www.gusucode.com > stats 源码程序 matlab案例代码 > stats/JackknifeResamplingExample.m
%% Jackknife Resampling % % Copyright 2015 The MathWorks, Inc. %% % Similar to the bootstrap is the jackknife, which uses resampling to % estimate the bias of a sample statistic. Sometimes it is also used to % estimate standard error of the sample statistic. The jackknife is % implemented by the Statistics and Machine Learning Toolbox(TM) function % |jackknife|. %% % The jackknife resamples systematically, rather than at random as the % bootstrap does. For a sample with |n| points, the jackknife computes % sample statistics on |n| separate samples of size |n|-1. Each sample is % the original data with a single observation omitted. %% % In the bootstrap example, you measured the uncertainty in estimating the % correlation coefficient. You can use the jackknife to estimate the bias, % which is the tendency of the sample correlation to over-estimate or % under-estimate the true, unknown correlation. First compute the sample % correlation on the data. load lawdata rhohat = corr(lsat,gpa) %% % Next compute the correlations for jackknife samples, and compute their % mean. rng default; % For reproducibility jackrho = jackknife(@corr,lsat,gpa); meanrho = mean(jackrho) %% % Now compute an estimate of the bias. n = length(lsat); biasrho = (n-1) * (meanrho-rhohat) %% % The sample correlation probably underestimates the true correlation by % about this amount.