function [ R_squared_OS,R_squared_OSH,R_squared_OSL,p,pH,pL] = regressions_OOS_Unconstraint(PCres,TrainingSample,mu_t,R_excess)

DataSize=size(mu_t,1);
Rt_hat=zeros(DataSize,1); % predicted return 
Rt_hatH=zeros(1,1); % predicted return 
Rt_hatL=zeros(1,1); % predicted return 
Rt_realH=zeros(1,1);
Rt_realL=zeros(1,1);
MeanRt_H=zeros(1,1);
MeanRt_L=zeros(1,1);
NoH=0;
NoL=0;

for t=TrainingSample:DataSize

    Rtt=R_excess(1:t-1); % that is, use information up to t
    Yt=mu_t(1:t);
    %% regime
    Xtt=PCres(1:t,t-TrainingSample+1);
    pi1=regime_Sentiment(Xtt,t);
    high_m=0;
    for i=2:t
        if pi1(i)>=0.5
            high_m=high_m+1;
        end
    end
    RtH=zeros(high_m,1);
    YtH1=zeros(high_m,1);
    RtL=zeros(t-1-high_m,1);
    YtL1=zeros(t-1-high_m,1);
    NumberH=0;
    NumberL=0;
    for i=1:t-1
        if pi1(i+1)>=0.5
            NumberH=NumberH+1;
            RtH(NumberH)=Rtt(i);
            YtH1(NumberH,:)=Yt(i);
        elseif pi1(i+1)<0.5
            NumberL=NumberL+1;
            RtL(NumberL)=Rtt(i);
            YtL1(NumberL,:)=Yt(i);
        end
    end
    
    %% regressions 
    A1=[ones(t-1,1) Yt(1:end-1)];
    [X1,STDX1]=lscov(A1,Rtt);
    
    Rt_hat(t)=X1(1)+X1(2)*Yt(end); 
    
    A1=[ones(NumberH,1) YtH1];
    [X2,STDX2]=lscov(A1,RtH);
    
    A1=[ones(NumberL,1) YtL1];
    [X3,STDX3]=lscov(A1,RtL);
    
    if pi1(t)>=0.5
        NoH=NoH+1;
        Rt_hatH(NoH)=X2(1)+X2(2)*YtH1(end); 
        Rt_realH(NoH)=R_excess(t);
        MeanRt_H(NoH)=mean(RtH);
    else
        NoL=NoL+1;
        Rt_hatL(NoL)=X3(1)+X3(2)*YtL1(end); 
        Rt_realL(NoL)=R_excess(t);
        MeanRt_L(NoL)=mean(RtL);
    end
    
end
    
%% R squared
denominator=0;
MeanRt=zeros(DataSize-TrainingSample+1,1);
for i=1:DataSize-TrainingSample+1
    denominator=denominator+(R_excess(TrainingSample+i-1)-mean(R_excess(1:TrainingSample+i-1-1)))^2;
    MeanRt(i)=mean(R_excess(1:TrainingSample+i-1-1));
end
R_squared_OS=1-sum((Rt_hat(TrainingSample:DataSize)-R_excess(TrainingSample:DataSize)).^2)/denominator;
p=Perform_CW_test(R_excess(TrainingSample:DataSize),MeanRt,Rt_hat(TrainingSample:DataSize));
R_squared_OSH=1-sum((Rt_hatH-Rt_realH).^2)/sum((Rt_realH-MeanRt_H).^2);
pH=Perform_CW_test(Rt_realH',MeanRt_H',Rt_hatH');
R_squared_OSL=1-sum((Rt_hatL-Rt_realL).^2)/sum((Rt_realL-MeanRt_L).^2);    
pL=Perform_CW_test(Rt_realL',MeanRt_L',Rt_hatL');
    
    
end