% Panel a:  Full Sample
clist = {'ARG';'DEU';'IND';'MEX';'USA'};
fig=figure;

subplot(2,3,1);
% Values to plot
str1 = clist(1);
[~,ii] = ismember(str1,country_code);
off_set = 0.35;
trnd_ofset = 0.2;
con_ofset = 1.2;
A_fs_plot = squeeze(yfit_reg(:,:,ii));
for i = 1:q+2;
    oo = (i-1)*off_set;
    if i == 1;
      A_fs_plot(:,i) = A_fs_plot(:,i)+trnd_ofset;
    elseif i == 2;
      A_fs_plot(:,i) = A_fs_plot(:,i)-con_ofset;
    else;
      A_fs_plot(:,i) = A_fs_plot(:,i) - oo;
    end;
end;

plot(calvec,A_fs_plot(:,1:2),'- b','LineWidth',1);
hold on;
  plot(calvec,A_fs_plot(:,3:end),'- r','LineWidth',1);
hold off;
xlim([1900 2020]);
%ylim([-5 2]);
set(gca,'ytick',[])
title(['Low-frequency regressors']);
% ax = gca;
% ax.FontSize = ax_fs;

for ic = 1:size(clist,1);
    str1 = clist(ic);
    [~,ii] = ismember(str1,country_code);
    str1 = char(str1);
    str2 = char(country(ii));
    y_raw = y_mat(:,ii);
    y_fit = yfit_mat(:,ii);
    subplot(2,3,ic+1);
    plot(calvec,y_raw,'LineWidth',1,'Color',rgb('Black'));
    hold on
      plot(calvec,y_fit,'LineWidth',1,'Color',rgb('Blue'));
    hold off;
    xlim([1900 2020]);
    title([str2]);
    if ic == 1;
     ylabel('Logarithm');
    end;
%     ax = gca;
%     ax.FontSize = ax_fs;
end;

orient landscape;
print(fig, [figdir, 'Figure_3_Panel_a'], '-dpdf','-bestfit');
close(gcf);

% Panel b:  Full Sample
clist = {'LBR';'SAU'};
fig=figure;

subplot(2,3,1);
% Values to plot
str1 = clist(1);
[~,ii] = ismember(str1,country_code);
off_set = 0.35;
trnd_ofset = 0.2;
con_ofset = 1.2;
A_fs_plot = squeeze(yfit_reg(:,:,ii));
for i = 1:q+2;
    oo = (i-1)*off_set;
    if i == 1;
      A_fs_plot(:,i) = A_fs_plot(:,i)+trnd_ofset;
    elseif i == 2;
      A_fs_plot(:,i) = A_fs_plot(:,i)-con_ofset;
    else;
      A_fs_plot(:,i) = A_fs_plot(:,i) - oo;
    end;
end;

plot(calvec,A_fs_plot(:,1:2),'- b','LineWidth',1);
hold on;
  plot(calvec,A_fs_plot(:,3:end),'- r','LineWidth',1);
hold off;
xlim([1900 2020]);
%ylim([-5 2]);
set(gca,'ytick',[])
title(['Low-frequency regressors']);
% ax = gca;
% ax.FontSize = ax_fs;

for ic = 1:size(clist,1);
    str1 = clist(ic);
    [~,ii] = ismember(str1,country_code);
    str1 = char(str1);
    str2 = char(country(ii));
    y_raw = y_mat(:,ii);
    y_fit = yfit_mat(:,ii);
    subplot(2,3,ic+1);
    plot(calvec,y_raw,'LineWidth',1,'Color',rgb('Black'));
    hold on
      plot(calvec,y_fit,'LineWidth',1,'Color',rgb('Blue'));
    hold off;
    xlim([1900 2020]);
    title([str2]);
    if ic == 1;
     ylabel('Logarithm');
    end;
%     ax = gca;
%     ax.FontSize = ax_fs;
end;
orient landscape;
print(fig, [figdir, 'Figure_3_Panel_b'], '-dpdf','-bestfit');
close(gcf);

% Panel b:  Full Sample
clist = {'CHN'};
fig=figure;

subplot(2,3,1);
% Values to plot
str1 = clist(1);
[~,ii] = ismember(str1,country_code);
off_set = 0.35;
trnd_ofset = 0.2;
con_ofset = 1.2;
A_fs_plot = squeeze(yfit_reg(:,:,ii));
for i = 1:q+2;
    oo = (i-1)*off_set;
    if i == 1;
      A_fs_plot(:,i) = A_fs_plot(:,i)+trnd_ofset;
    elseif i == 2;
      A_fs_plot(:,i) = A_fs_plot(:,i)-con_ofset;
    else;
      A_fs_plot(:,i) = A_fs_plot(:,i) - oo;
    end;
end;

plot(calvec,A_fs_plot(:,1:2),'- b','LineWidth',1);
hold on;
  plot(calvec,A_fs_plot(:,3:end),'- r','LineWidth',1);
hold off;
xlim([1900 2020]);
%ylim([-5 2]);
set(gca,'ytick',[])
title(['Low-frequency regressors']);
% ax = gca;
% ax.FontSize = ax_fs;

for ic = 1:size(clist,1);
    str1 = clist(ic);
    [~,ii] = ismember(str1,country_code);
    str1 = char(str1);
    str2 = char(country(ii));
    y_raw = y_mat(:,ii);
    y_fit = yfit_mat(:,ii);
    subplot(2,3,ic+1);
    plot(calvec,y_raw,'LineWidth',1,'Color',rgb('Black'));
    hold on
      plot(calvec,y_fit,'LineWidth',1,'Color',rgb('Blue'));
    hold off;
    xlim([1900 2020]);
    title([str2]);
    if ic == 1;
     ylabel('Logarithm');
    end;
%     ax = gca;
%     ax.FontSize = ax_fs;
end;
orient landscape;
print(fig, [figdir, 'Figure_3_Panel_c'], '-dpdf','-bestfit');
close(gcf);