function [fNoRejectSim,numberFalseModelsGoodFitFSim] = fTestModelsv2(Y,X,setSelected,alpha,activeSet)


fNoRejectSim=0;
s=size(activeSet,1);
modelSize=min(5,size(setSelected,1));
[n,~]=size(X);
[~,~,residBig]=regress(Y,[ones(n,1), X(:,setSelected)]);
    RSSBig=residBig'*residBig;
    dfBig=n-(size(setSelected,1)+1);
    countModelsF=0;
    for j=1:modelSize
        combinationMatrix=combntns(setSelected',j);
        logicFitVectorF=zeros(size(combinationMatrix,1),1);
        for l=1:size(combinationMatrix,1)
           XSelect=X(:,combinationMatrix(l,:));
           [~,~,residSmall]=regress(Y,[ones(n,1), XSelect]);
           RSSSmall=residSmall'*residSmall;
           diffRSS=RSSSmall-RSSBig;
           dfSmall=n-(size(XSelect,2)+1);
           fCrit=finv(1-alpha,dfSmall-dfBig,dfBig);
           if isnan(fCrit)
              logicFitVectorF(l,1)=1;
           else
                if (diffRSS/(dfSmall-dfBig))/(RSSBig/dfBig)<=fCrit
                    logicFitVectorF(l,1)=1;
                end
           end
           if ((j==s)&&(all(ismember(activeSet,combinationMatrix(l,:)))))
              fNoRejectSim=logicFitVectorF(l,1);
           end
        end
        countModelsF=countModelsF+sum(logicFitVectorF,1);
    end
    if fNoRejectSim>0
        numberFalseModelsGoodFitFSim=countModelsF-fNoRejectSim;
    else
        numberFalseModelsGoodFitFSim=countModelsF;
    end
end

