function [ interval,interval_minus1, interval_plus1 ] = confidence_int_average_corr( num_var,confidence_int, confidence_int_minus1, confidence_int_plus1)


% PURPOSE: CREATE THE CONFIDENCE INTERVAL FOR THE CORRELATION CALCULATING AS
% AVERAGE OF THE COUNTRY SPECIFIC CORRELATIONS
% 
% INPUT:
%     -num_var: NUMBER OF TIME SERIES FOR THE VARIABLE OF INTEREST
%     -confidence_int: VALUES OF THE CONFIDENCE INTERVAL
%     -confidence_int_minus1: VALUES OF THE CONFIDENCE INTERVAL FOR LAGGED CORRELATION
%     -confidence_int_plus1: VALUES OF THE CONFIDENCE INTERVAL FOR LEAD CORRELATION
%     
% OUTPUT:
%     -interval: STRING WITH THE CONFIDENCE INTERVAL
%     -interval_minus1: STRING WITH THE LAG CONFIDENCE INTERVAL
%     -interval_plus1: STRING WITH THE LEAD CONFIDENCE INTERVAL



    %Create two string vectors with the values of the confidende intervals
    %t=0
    for i=1:num_var
        confidence_int_lower(:,:,i)=num2str(confidence_int(:,1,i));
        confidence_int_upper(:,:,i)=num2str(confidence_int(:,2,i));
    end
    %Create two string vectors with the values of the confidende intervals
    %t=-1
    for i=1:num_var
        confidence_int_lower_minus1(:,:,i)=num2str(confidence_int_minus1(:,1,i));
        confidence_int_upper_minus1(:,:,i)=num2str(confidence_int_minus1(:,2,i));
    end
    %Create two string vectors with the values of the confidende intervals
    %t=+1
    for i=1:num_var
        confidence_int_lower_plus1(:,:,i)=num2str(confidence_int_plus1(:,1,i));
        confidence_int_upper_plus1(:,:,i)=num2str(confidence_int_plus1(:,2,i));
    end

    %Create brackets and comma for the confidence intervals
    for i=1:num_var
        for j=1:4
            open_bracket(j,i)={'('};
        end
    end
    
    for i=1:num_var
        for j=1:4
            close_bracket(j,i)={')'};
        end
    end

    for i=1:num_var
        for j=1:4
            separator(j,i)={','};
        end
    end
    %Concatenate values and brackets
    for i=1:num_var
        interval(:,:,i)=strcat(open_bracket(:,i),confidence_int_lower(:,:,i),separator(:,i),confidence_int_upper(:,:,i),close_bracket(:,i));
    end
    for i=1:num_var
        interval_minus1(:,:,i)=strcat(open_bracket(:,i),confidence_int_lower_minus1(:,:,i),separator(:,i),confidence_int_upper_minus1(:,:,i),close_bracket(:,i));
    end
    for i=1:num_var
        interval_plus1(:,:,i)=strcat(open_bracket(:,i),confidence_int_lower_plus1(:,:,i),separator(:,i),confidence_int_upper_plus1(:,:,i),close_bracket(:,i));
    end

end

