我正在尝试在Matlab中计算FAMA MacBeth斜率系数的Newey West t统计量。我应该在每个横截面回归中计算标准误差吗?
for j=1:T
....
Result=regstats2(y(:,T),x(:,T),'linear',{'beta' 'r' 'tstat' 'rsquare'});
BETAS1(j,DUMMY_AVAILABILITY_INDEX) = Result.beta;
TSTAT(j,DUMMY_AVAILABILITY_INDEX) = Result.tstat.t;
PVAL(j,DUMMY_AVAILABILITY_INDEX) = Result.tstat.pval;
SE(j,DUMMY_AVAILABILITY_INDEX) = Result.tstat.se;
RSQ(j) = 1 - ((1-Result.rsquare)* (size(NR_INDEX,1)-1) / (size(NR_INDEX,1) - (size(x,2)-1)));
FIT(NR_INDEX,j) = x * BETAS1(j,DUMMY_AVAILABILITY_INDEX)' ;
RESIDUALS(NR_INDEX,j)=y - FIT(NR_INDEX,j); % The residuals
RESIDUALS_PERCENT(NR_INDEX,j)=y ./ FIT(NR_INDEX,j); % The residuals
end
end
otherwise
error('BASE_CASE input should be true or false')
end % end switch
RESULT.beta = nanmean(BETAS1);
RESULT.tstat = nanmean((TSTAT));
RESULT.pval = nanmean(PVAL);
RESULT.se = nanmean(SE);
RESULT.rsq = nanmean(RSQ);
RESULT.FMB_SE = sqrt(nansum(((BETAS1 -
RESULT.beta).^2)/(size(VALUE_INDEX,2)-1))/size(VALUE_INDEX,2)); % =
sqrt(nanstd(BETAS1) / size(VALUE_INDEX,2)))
RESULT.FMB_TSTAT = RESULT.beta ./ RESULT.FMB_SE;
RESULT.BETAS = BETAS1;
RESULT.RSQ = RSQ;
RESULT.TSTAT = TSTAT;