首页 > 解决方案 > 将代码从一侧 p 值调整为两侧

问题描述

我有一些来自 Rapach、Strauss 和 Zhou (2013),Journal of Finance 的代码。

它计算单边假设检验的引导 p 值,

H0: B=0 against H1: B>0

我是否可以修改此代码来计算假设检验:

H0: B=0 against H1: B\=0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Computing statistics for wild bootstrapped pseudo samples
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

stats_boot=zeros(N+1,N,B);
for b=1:B;
    for j=1:N;
        [results_j_star,R_squared_j_star]=...
            Estimate_Granger_pairwise_GMM(Y_star(:,:,b),...
            Y_star(:,:,b),X_1_star(:,:,b),X_2_star(:,:,b),j);
        for i=1:(N-1);
            if j==1;
                stats_boot(i+1,j,b)=results_j_star(i,2);
            else
                if i<j;
                    stats_boot(i,j,b)=results_j_star(i,2);
                else
                    stats_boot(i+1,j,b)=results_j_star(i,2);
                end;
            end;
        end;
        stats_boot(N+1,j,b)=results_j_star(end,2);
        disp([b j]);
    end;
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Computing wild bootstrapped p-values
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for j=1:N;
    for i=1:N+1;
        stats_boot_i_j=stats_boot(i,j,:);
        stats_p_i_j=stats_boot_i_j>results_all(2,j,i);
        results_all(3,j,i)=sum(stats_p_i_j)/B;
    end;
end;

标签: matlabstatisticsregressionlinear-regression

解决方案


我相信原来的答案是不正确的。

如果我们认为双尾的假设检验是:

H0: b=0, HA:b\=0

那么上面的答案只告诉我们t什么时候不等于临界值,基本上一直都是这样。

但想想 t 检验,

双尾应该是,

Reject H0 is |t|>t_(alpha/2)

因此,OP 需要更改代码以解决此问题。

这应该是评论而不是答案,但我的代表少于 50!


推荐阅读