B = 1000;
n = 100;
x = [ones(n,1) rand(n,1)];
b = [3 5]';
y = x*b + randn(n,1);
disp('Apparent prediction error')
b = regress(y,x);
e = y - x*b;
ape = mean(e.^2)
disp('Bootstrapped prediction error: "simple" bootstrap')
z = [y x];
res = bstrap(B,1,'bpredfun1',z,z);
s = [res.e];
bpe1 = mean(s,2)
disp('Bootstrapped prediction error: 0.632 bootstrap')
z = [(1:n)' y x];
res = bstrap(B,1,'bpredfun2',z,z);
S = [res.e];
s = nanmean(S,2);
bpe2 = .368*ape + .632*mean(s)
Apparent prediction error
ape =
0.6859
Bootstrapped prediction error: "simple" bootstrap
bpe1 =
0.6981
Bootstrapped prediction error: 0.632 bootstrap
bpe2 =
0.7104