clear;
load dataPE.mat % original anomaly returns were downloaded from Novy Marx's website, Fama-French factors were downloaded from French's website
for i=1:13
lhv=anomaly(:,i);
rhv=[Ih 1-Ih FF4_2]; 
[bv,sebv,R2v,R2vadj,v,F] = olsWhite(lhv,rhv);
aa(i,1:4)=[bv(1) bv(1)/sebv(1) bv(2) bv(2)/sebv(2)];
end;
for i=1:4
lhv=anomaly1(:,i);
rhv=[Ih(96:end,:) 1-Ih(96:end,:) FF4_2(96:end,:)]; 
[bv,sebv,R2v,R2vadj,v,F] = olsWhite(lhv,rhv);
bb(i,1:4)=[bv(1) bv(1)/sebv(1) bv(2) bv(2)/sebv(2)];
end;
for i=1:13
lhv=anomaly(:,i);
rhv=[Ih 1-Ih FF4_2(:,1:end-1)]; 
[bv,sebv,R2v,R2vadj,v,F] = olsWhite(lhv,rhv);
aa2(i,1:4)=[bv(1) bv(1)/sebv(1) bv(2) bv(2)/sebv(2)];
end;
for i=1:4
lhv=anomaly1(:,i);
rhv=[Ih(96:end,:) 1-Ih(96:end,:) FF4_2(96:end,1:end-1)]; 
[bv,sebv,R2v,R2vadj,v,F] = olsWhite(lhv,rhv);
bb2(i,1:4)=[bv(1) bv(1)/sebv(1) bv(2) bv(2)/sebv(2)];
end;
lhv=combine;
rhv=[Ih 1-Ih FF4_2]; 
[bv,sebv,R2v,R2vadj,v,F] = olsWhite(lhv,rhv);
cc(1,1:4)=[bv(1) bv(1)/sebv(1) bv(2) bv(2)/sebv(2)];
lhv=combine;
rhv=[Ih 1-Ih FF4_2(:,1:end-1)]; 
[bv,sebv,R2v,R2vadj,v,F] = olsWhite(lhv,rhv);
cc2(1,1:4)=[bv(1) bv(1)/sebv(1) bv(2) bv(2)/sebv(2)];
table2=[aa aa2; bb bb2; cc cc2];
