SIMULATION: BOOTSTRAP t TEST
(1)使用 matlab 编写程序
t分布计算函数:
function t=t_func(y,x)
n=length(x);
b=pinv(x'*x)*x'*y;
beta2=0.9;
e=y-x*b;
se=(e'*e)*pinv(x'*x)./(n-2);
se=se(2,2)^(1/2);
t=(b(2,2)-beta2)./se;
end
T分布检验主函数:
p为最终回报的p值序列
sample_size=[10,14,20,28,40,56,80,113,160,226,320,452,640,905,1280];
p=zeros(15,1);
for i=1:15
len=sample_size(i);
% sample的大小
y=zeros(10000,1);
for t=(1:10000)
x = zeros(len+100,2);
x(:,1)=1;
% 定义向量x的行数
for n=(2:len+100)
x(n,2)=0.9.*x(n-1,2)+1+randn(1,1);
% x的值
end
y(t,1)=t_func(x(100:len+100,:),x(99:len+99,:));
end
p(i,1)=sum(abs(y