%table_ar1_cbc.m 
%Country-by-country estimates of the TOT process, 
%Table 1  in  ``How Important Are Terms of Trade Shocks?''  by Stephanie Schmitt-Grohe and Martín Uribe. 
%(c) Stephanie Schmitt-Grohé and Martín Uribe, September 2016.
clear all

%Baseline Case: Quadratic Detrending: 
load sgu_tot_run.mat 
%produced by runnning sgu_tot_run.m in the directory z:\uribe\tot\ier\mfiles 

%Robustness: HP Filtering (percentage out the next command to run this case)
%load sgu_tot_run_HP.mat 
%produced by runnning sgu_tot_run.m in the directory z:\uribe\tot\ier\mfiles  and
%loading: detrend_data_HP.mat

clc
for k=1:ncou %for each country 
a = [country_name{k} ' '  num2str([hx(1,1,k) PI(1,1,k) R2(1,k)])];
disp(a);
end

hx11 = median(hx(1,1,:));
PI11 = median(PI(1,1,:));
R21 = median(R2(1,:));
x = [hx11 PI11 R21];

b = ['Median ' num2str(x)];

disp(b);

hx11 = mad(hx(1,1,:),1);
PI11 = mad(PI(1,1,:),1);
R21 = mad(R2(1,:),1);
x = [hx11 PI11 R21];
b = ['Median Absolute Deviation' num2str(x)];

disp(b)
