%phi_pssi_cbc.m
% produce a table displaying the parameter estimates  PHIM, PHIX, PHINT, and PSSI 
% in the MXN model developed in paper  ``How Important Are Terms of Trade Shocks?,'' by Stephanie Schmitt-Grohé and Martín Uribe, 
%©  Stephanie Schmitt-Grohé and Martín Uribe, October 2016.

clear all
format compact

%load country by country values for PHIM PHIX PHINT and PSSI
load probe.mat MXPAR
%produced by running probe.m  in directory
%z:\uribe\tot\ier\mfiles\mxn_with_spread
% Note. Running  probe.m may not deliver exactly the parameter values stored in probe.mat 
% because the estimation procedure relies on a Metropolis-Hastings searching method, which is random in nature. 
% The 38x4 matrix MXPAR contains the estimates of the 4 parameter values [PHIM  PHIX  PHINT  PSSI]  for each of the 38 countries in the panel.

xs = MXPAR; 

PHIM_cbc = xs(:,1);
PHIX_cbc = xs(:,2);
PHINT_cbc = xs(:, 3);
PSSI_cbc = xs(:,4);

clear MXPAR xs

%Moments implied by the SVAR + Baaff model

load sgu_tot_run_baaff.mat  hx  PI country_name  ncou
%produced by running 
%sgu_tot_run_baaff.m in
%z:\uribe\tot\ier\mfiles

%The Tot  and Baaff process
RHO_TOTTOT_cbc = squeeze(hx(1,1,:));
RHO_TOTS_cbc = squeeze(hx(1,2,:));%parameter of AR(1) coeff of (totms) process 
RHO_STOT_cbc = squeeze(hx(2,1,:));%parameter of AR(1) coeff of (totms) process 
RHO_SS_cbc = squeeze(hx(2,2,:));%parameter of AR(1) coeff of (totms) process 

STD_TOTTOT_cbc = squeeze(PI(1,1,:)); 
STD_TOTS_cbc = squeeze(PI(1,2,:)); 
STD_STOT_cbc = squeeze(PI(2,1,:)); 
STD_SS_cbc = squeeze(PI(2,2,:)); 

clear hx PI

%This .mat file is later used in the program mxn_var.m 
save phi_pssi_cbc.mat PHIM_cbc PHIX_cbc PHINT_cbc PSSI_cbc RHO_TOTTOT_cbc RHO_TOTS_cbc RHO_STOT_cbc RHO_SS_cbc  STD_TOTTOT_cbc  STD_TOTS_cbc STD_STOT_cbc STD_SS_cbc ncou

[PHIM_cbc PHIX_cbc PHINT_cbc PSSI_cbc ]

