matlab - 将代码从一侧 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;
解决方案
我相信原来的答案是不正确的。
如果我们认为双尾的假设检验是:
H0: b=0, HA:b\=0
那么上面的答案只告诉我们t什么时候不等于临界值,基本上一直都是这样。
但想想 t 检验,
双尾应该是,
Reject H0 is |t|>t_(alpha/2)
因此,OP 需要更改代码以解决此问题。
这应该是评论而不是答案,但我的代表少于 50!
推荐阅读
- ssl - 使用 Wireshark 解密来自应用程序的 SSL/TLS 流量
- tensorflow - Tensorflow OD API - 微调模型时使用 dropout
- javascript - 如何不让'$'影响使用 python 或 JS 在 MongoDB 中插入文档?
- docker - 新模型是否有与 Tensorflow-Serving 中的新版本相同的“加载策略”?
- c# - 禁用 DropDownList 并能够将值传递给更新模型
- c++ - 从对向量中按值擦除元素
- android - Android Studio:如何在布局 xml 文件中自动添加结束/结束标记
- python - 将 Tenor 的索引和值组合成一个新的张量
- javascript - 父位置更改时JQuery删除元素
- ios - 如何使用 React-Native 在 iOS 中禁用屏幕截图