function [ y_adv, y_mid, y_poor ] = country_groups_prob(num_page, num_var, x)

% 
% PURPOSE: CREATE COUNTRY GROUPS OF A VARIABLE FOR THE PROBABILITIES
% 
% INPUT:
%     -num_var: NUMBER OF TIME SERIES FOR THE VARIABLE OF INTEREST
%     -x: VARIABLE OF INTEREST TO BE DIVIDED IN COUNTRY GROUPS
% 
% OUTPUT:
%     -y_adv: VARIABLE OF INTEREST ONLY FOR ADVANCED ECONOMIES
%     -y_mid: VARIABLE OF INTEREST ONLY FOR EMERGING MARKETS
%     -y_poor: VARIABLE OF INTEREST ONLY FOR DEVELOPING ECONOMIES


%Recall variable defined in the main script
global num_c vect_adv num_adv vect_mid num_mid vect_poor num_poor

    for a=1:num_page
    for j=1:num_var
    for i=1:num_c
        for k=1:num_adv
            if i==vect_adv(1,k)
                y_adv(k,:,j,a)=x(i,:,j,a);
            end
        end
        for k=1:num_mid
            if i==vect_mid(1,k)
                y_mid(k,:,j,a)=x(i,:,j,a);
            end
        end
        for k=1:num_poor
            if i==vect_poor(1,k)
                y_poor(k,:,j,a)=x(i,:,j,a);
            end
        end
    end
    end
    end

end

