load law
lsat=law(:,1);
gpa=law(:,2);
B=1000;
%bootstrap
[bootstat,bootsam]=bootstrp(B,'corrcoef',lsat,gpa);
n=length(gpa);
jreps=zeros(1,n);
%jackknife
for i=1:n
[I,J]=find(bootsam==i);
%remove column containing i-th sample,
jacksam=setxor(J,1:B);
bootrep=bootstat(jacksam,2);
jreps(i)=std(bootrep);
end
varjack = (n-1)/n * sum((jreps-mean(jreps)).^2);
sejack = sqrt(varjack)
gamma=std(bootstat(:,2))
lsat=law(:,1);
gpa=law(:,2);
B=1000;
%bootstrap
[bootstat,bootsam]=bootstrp(B,'corrcoef',lsat,gpa);
n=length(gpa);
jreps=zeros(1,n);
%jackknife
for i=1:n
[I,J]=find(bootsam==i);
%remove column containing i-th sample,
jacksam=setxor(J,1:B);
bootrep=bootstat(jacksam,2);
jreps(i)=std(bootrep);
end
varjack = (n-1)/n * sum((jreps-mean(jreps)).^2);
sejack = sqrt(varjack)
gamma=std(bootstat(:,2))
0.1332
sejack =
0.0839
The result can be interpreted as follows. The standard error of the correlation coefficient for this simulation is $\hat\gamma_B=\hat{SE}_{Boot}(\hat\rho)=0.133$ and the estimated error of this value is $\hat{SE}_{Jack}(\hat\gamma_B)=0.084$.
No comments:
Post a Comment