format long;
load CRSP_SENT_value_weighted_new.mat  % orthogonal sentiment index



%% the high-low sentiment month defined in Stambaugh_Yu_Yuan_JFE_12

aaa = sort(Xt, 'descend');
RegimeSYY=zeros(546,1);
Cut_no=110; %20%:110  30%:164 40%:218   50%:273    60%:328   80%:437
for i=1:546
    if Xt(i)<aaa(Cut_no) 
        RegimeSYY(i)=-9;
    else
        RegimeSYY(i)=3;
    end
end
NoHigh=0;
NoMedian=0;
NoLow=0;
Regime3=zeros(546,1);
for i=1:546
    if Xt(i)<=aaa(382) %30%
        Regime3(i)=-1; % low
        NoLow=NoLow+1;
    elseif Xt(i)>=aaa(218) %40%
        Regime3(i)=1; % high
        NoHigh=NoHigh+1;
    else
        Regime3(i)=0; % median
        NoMedian=NoMedian+1;
    end
end

save('Para_sent_20percent.mat','RegimeSYY','Cut_no','Regime3','NoHigh','NoMedian','NoLow');

