function CAPM_CI_subeig(R,F,index,width,step)
%{
    This function plots C.I.'s of the i-th risk premium 
    
    INPUT 
    R       : n by T, a matrix of asset returns
    F       : k by T, a matrix of risk factors
    index   : the index of risk premium whose C.I. is to be plotted
    width   : width of graph, e.g. 10
    step    : intervel between two points, e.g. 0.01
    
    OUTPUT  
    a graph with 95% confidence intervals of the indexed parameter
%}

    % update F: move the indexed factor to the end for convenience
    if (index>size(F,1))||(index<1)
        disp('Error: check 0<index<=k.')
        return;
    end
    if index~=1 
        temp=F(index,:);
        F(index,:)=F(1,:);
        F(1,:)=temp;
    end
   
   

    % initialize the plots: you can choose width and step
    x_seq=(-width):step:(width);
    far_seq=ones(1,length(x_seq));
    far_seq2=ones(1,length(x_seq));
    y_bench=ones(1,length(x_seq)).*0.05;
    
    [n, T]=size(R);                       % get n, T
    k=size(F,1);                          % get k
    for j=1:length(x_seq)
        lambda_null=x_seq(:,j);
        [far_stat, ~, ~]=subset_eig(R,F,lambda_null); 
        far_seq(:,j)=1-chi2cdf(far_stat,n-k); 
        stat_FAR=far_stat/T*(T-n)/(n-k);
        far_seq2(:,j)=1-fcdf(stat_FAR,n-k,T-n);
    end
    
    % plot the outcome for our paper only
    figure(4);
    subplot(1,3,index);
    hold on
    plot(x_seq, y_bench,'k');
    plot(x_seq, far_seq,'r-');
    plot(x_seq, far_seq2,'k-');
    hold off
    ylim([0 0.4]);
    if (index==1) title('\Delta Consumption'); end
    if (index==2) title('cay'); end;
    if (index==3) title('\Delta Consumption \times cay'); end;
end
    