function [stats_std, stats_corr] = des_statistics(num_country, num_var, x)


% PURPOSE: CALCULATE STANDARD DEVIATION AND AUTOCORRELATION FOR OUTPUT GAP, REAL 
% EFFECTIVE EXCHANGE RATE AND CURRENT ACCOUNT 
% 
% INPUT:
%     -num_country:NUMBER OF COUNTRIES
%     -num_var:NUMBER OF TIME SERIES FOR THE VARIABLE OF INTEREST
%     _x: VARIABLE OF INTEREST
% 
% OUTPUT:
%     -stats_std: STANDARD DEVIATION
%     -stats_corr: TEMPORAL CORRELATION


    %Calculate volatility(standard deviation) for each country over the period of study
    for j=1:num_var
        for i=1:num_country
            stats_std(i,j)=nanstd(x(i,:,j),0,2);
        end
    end
    
    %Calculate persistency(correlation between t and t-1) for each country over the period of study
    xt_aux1=x(:,1:end-1,:);
    xt_aux2=x(:,2:end,:);

    for j=1:num_var
        for i=1:num_country
            stats_corr(i,j)=corr(xt_aux1(i,:,j)',xt_aux2(i,:,j)');
        end
    end

    %Eliminate the NaN values from the correlation vector because Matlab
    %returns this result in case of nonvarying value for the index
    for i=1:num_country
        for j=1:num_var
            if isnan(stats_corr(i,j))
                stats_corr(i,j)=0;
            end
        end
    end

end

