@ DEFICIT16.PRG @
@ (MOBILE LABOR) @
@ Aggregate Malaysia, Phillipines, and Singapore @
@ Incorporate the new bilateral trade matrix (DEKTRADEDEC97.xls) @
@ Net of 42 Countries @
@ Country-specific Alpha's and Beta's @
@ spread world's deficit in proportion to GDP's @
@ Take account of nonmanufactures used as intermediates @
@ @
@ Try some new Counterfactuals @
@ @
@ Solve for the Equilibrium change in wages @
@ that eliminates all current account deficits @
@ @
@ 1. Back to EKK definition of alpha. @
@ 2. Perfect competition. @
@ 3. Incorporate current account. @
@ 4. Incorporate overall trade balance. @
@ @
@ Fixed iteration stopping criteria @
@ @
@ Dekle, Eaton, and KORTUM 02/09/08 @
@ @
@ Start with 44 country dataset @
@ @
new;
cls;
@ OUTPUT FILE = c:\kortum\research\DEK\IMF\deficit16.out RESET; @
OUTPUT FILE = c:\Programs_DEK_IMF\Gauss_Program\deficit16.out RESET;
vfactor = .001; @ wage iteration term @
maxit = 10000; @ maximum iterations for wage or price mappings @
@ tolerances for wage and price iteration @
wtol = .000001;
ptol = .000001;
@ parameter @
mytheta = 8.28;
@mytheta = 1;@ @ here representing sigma-1 @
mygamma = .43; @ share of nonmanufactured goods in intermediates @
" ";
" ********************** ";
" parameter values ";
" mytheta " mytheta;
" mygamma " mygamma;
" ********************** ";
" ";
ncnty = 42;
cntynum = seqa(1,1,42);
@ list of 42 country names @
let cnty = "ALGERIA" "ARGENTIN" "AUSTRALI" "AUSTRIA" "BELUXNE"
"BRAZIL" "CANADA" "CHILE" "CHINAHK" "COLOMBIA" "DENMARK"
"EGYPT" "FINLAND" "FRANCE" "GERMANY" "GREECE" "INDIA" "INDONSIA" "IRELAND" "ISRAEL"
"ITALY" "JAPAN" "KOREA" "MAPHSING" "MEXICO" "NETRLNDS" "NEWZEAL" "NORWAY" "PAKISTAN" "PERU"
"PORTUGAL" "RUSSIA" "SOUTHAFR" "SPAIN" "SWEDEN" "SWITZER"
"THAILAND" "TURKEY" "UK" "US" "VENEZUEL" "ROW";
@ load the matrix of bilateral trade (0 on diagonal) in $ billions with exporters as rows @
@ last country is ROW @
@ From Comtrade, as reported by importing countries @
load xbilat[44,44] = c:\Programs_DEK_IMF\Gauss_Program\trade04c.txt; @ from DEKTradeDec97.xls @
xbilat = xbilat'; @ want exporters as columns @
@ subtract from ROW imports trade between Belgium and Lux and between China and HK @
xbilat[44,5] = xbilat[44,5] - 3.81 - 1.21;
xbilat[44,9] = xbilat[44,9] - 10.7 - 114;
xbilat[5,44] = xbilat[5,44] - 3.81 - 1.21;
xbilat[9,44] = xbilat[9,44] - 10.7 - 114;
exprt1 = sumc(xbilat);
@ data from the UN (national accounts and UNIDO) @
load undata[43,3] = c:\DEK_IMF\IMF_Final\undata.raw;
betavec = undata[.,1];
betavec1 = betavec|meanc(betavec);
unmfg = undata[.,2];
ungdp = undata[.,3];
unmfgt = sumc(unmfg);
ungdpt = sumc(ungdp);
@ United Nations world totals @
unmfgw = 7126981031554;
ungdpw = 41609769169981;
unmfg = unmfg|(unmfgw-unmfgt);
ungdp = ungdp|(ungdpw-ungdpt);
gdp = ungdp/1000000000; @ in $ billions @
vm = unmfg/1000000000; @ in $ billions @
gdpshr = gdp/sumc(gdp);
@ current account surplus and overall trade surplus ($ billions) @
load catb[44,2] = c:\Programs_DEK_IMF\Gauss_Program\catb04.txt;
catbw = catb[44,.]; @ world totals @
catb[44,.] = catbw - sumc(catb[1:43,.])'; @ fill in ROW @
catb = catb - gdpshr*catbw; @ spread the discrepancy in proportion to gdp @
casurp1 = catb[.,1];
tsurp1 = catb[.,2];
@ implied manufacturing production @
ym1 = vm./betavec1;
xnn1 = ym1 - exprt1;
xnimatf = diagrv(xbilat,xnn1);
@ Aggregate Malaysia (24), Phillipines (31), and Singapore (34) @
@ in the end we have 42 countries @
aggmat = eye(44);
aggmat[24,31] = 1;
aggmat[24,34] = 1;
deletit = zeros(44,1);
deletit[31] = 1;
deletit[34] = 1;
aggmat = delif(aggmat,deletit);
xnimat = aggmat*xnimatf*aggmat';
gdp = aggmat*gdp;
vm = aggmat*vm;
casurp = aggmat*casurp1;
tsurp = aggmat*tsurp1;
betavec = aggmat*betavec1;
betavec[24] = betavec[24]/3;
@ implied manufacturing production @
ym = vm./betavec;
vn = gdp - vm;
deficitc = -casurp; @ current account deficit @
deficitt = -tsurp; @ total deficit in goods and services @
xgdp = gdp - tsurp; @ aggregate final spending @
@ coefficients in the cost function @
incoeff = mygamma*(1-betavec);
pcoeff = (1-mygamma)*(1-betavec);
@ create some trade statistics @
xnn = diag(xnimat);
imprt = sumc(xnimat') - xnn;
exprt = sumc(xnimat) - xnn;
deficitm = imprt - exprt;
xn = sumc(xnimat');
pimat = xnimat./xn;
pimax = maxc(pimat);
locmax = maxindc(pimat);
" cntynum, cnty, locmax ";
call printfmt((cntynum~cnty~locmax),(1~0~1));
pidiag = diag(pimat);
pidiff = pimax - pidiag;
" ";
" TABLE A1: Check trade shares ";
"exporting country, maximum share abroad, homeshare, difference ";
call printfmt((cnty~pimax~pidiag~pidiff),(0~1~1~1));
" ";
@ implied alpha's @
alphavec = (vm + mygamma*(1-betavec).*ym + deficitm)./xgdp;
@ export share @
shexprt = exprt./ym;
@ manufacturing share @
mfgshare = vm./gdp;
" ";
" TABLE 0 ";
" num, country, vm, imprt, exprt ";
call printfmt((cntynum~cnty~vm~imprt~exprt),(1~0~1~1~1));
" ";
" TABLE 1 ";
" country, gdp, cadeficit, totdeficit, mfgdeficit ";
call printfmt((cnty~gdp~deficitc~deficitt~deficitm),(0~1~1~1~1));
" ";
" ";
" TABLE 2 ";
"country, mfgshare gdp, exportshare gprod, alphavec, betavec ";
call printfmt((cnty~mfgshare~shexprt~alphavec~betavec),(0~1~1~1~1));
" ";
@ coefficients in the cost function @
wcoeff = betavec + mygamma*(1-betavec);
pcoeff = (1-mygamma)*(1-betavec);
@ income term for counterfactual @
y = gdp;
y0 = y;
xnimat0 = xnimat;
@ ***********************************************************************@
@ counterfactual mfg deficit will lead to current account surplus of 0 @
@ holding fixed the non-mfg deficit (including net payments to foreign factors @
@ ***********************************************************************@
defmc = casurp + deficitm; @ counterfactual defit in mfg @
deftc = casurp + deficitt; @ counterfactual total deficit in goods and services @
@ ****** Eliminate China's deficit and use to pay off US deficit **** @
@ defmc = deficitm;
defmc[9] = casurp[9] + deficitm[9];
defmc[42] = -casurp[9] + deficitm[42];
deftc = deficitt + (defmc - deficitm);
@
adeftc = alphavec.*deftc;
" ";
" TABLE 3 ";
"country, tot deficit, mfg deficit, cfactual tot. deficit, cfactual mfg deficit ";
call printfmt((cnty~deficitt~deficitm~deftc~defmc),(0~1~1~1~1));
" ";
@ initialize vectors of ex-post wage and price factors @
wf0 = ones(ncnty,1);
pf0 = ones(ncnty,1);
pf00 = ones(ncnty,1);
lpf00 = ln(pf00);
pimat1 = 0;
y1 = 0;
@ mapping from one log price change vector to another given wf0 @
proc lpmap(lpf);
local lpf0,lpf1,lwf0,lwfpf0,elwfpf0;
lpf0 = lpf;
lwf0 = ln(wf0);
lwfpf0 = wcoeff.*lwf0 + pcoeff.*lpf0;
elwfpf0 = exp(-mytheta*lwfpf0);
lpf1 = -ln((pimat*elwfpf0))/mytheta;
retp(lpf1);
endp;
@ calculate new bilateral trade shares @
proc pimatnew(wf,pf);
local wftb,pftb,wfpftb,xnimat1;
wftb = wf^(-mytheta*wcoeff);
pftb = pf^(-mytheta*pcoeff);
wfpftb = wftb.*pftb;
xnimat1 = xnimat0.*wfpftb';
pimat1 = xnimat1./sumc(xnimat1');
retp(pimat1);
endp;
@ mapping from one wage change vector to another, given pf0 @
proc wmap(wf);
local zw,tw,ay1;
pimat1 = pimatnew(wf,pf0);
y1 = wf.*y0;
ay1 = alphavec.*y1;
zw = (pimat1'*((ay1 + adeftc - pcoeff.*defmc)./wcoeff) - (ay1 + adeftc - defmc)./wcoeff)./wf;
tw = wf.*(1+vfactor*zw./y0);
retp(tw);
endp;
@ ******************************************* @
@ iteration on wages and prices @
@ ******************************************* @
wfmax = 2*wtol;
i = 0;
do while i <= maxit and wfmax > wtol;
@ first calculate prices consistent with wf0 @
pfmax = 2*ptol;
j = 0;
do while j <= maxit and pfmax > ptol;
@ iterate to find log price @
lpf0 = lpmap(lpf00);
pfdev = abs(lpf0 - lpf00);
pfmax = maxc(pfdev);
lpf00 = lpf0;
j = j+1;
if j==maxit;
" *****************************";
" error: prices did not converge ";
"******************************";
endif;
endo;
pf0 = exp(lpf0);
wf1 = wmap(wf0);
wfdev = abs(ln(wf1./wf0));
wfmax = maxc(wfdev);
wf0 = wf1;
i = i+1;
if i==maxit;
" *****************************";
" error: wages did not converge ";
"******************************";
endif;
endo;
pinn0 = diag(pimat);
pinn1 = diag(pimat1);
realwf = (pinn1./pinn0)^(-alphavec./(betavec*mytheta));
realwm = (wf1./pf0);
pricef = (pf0^(alphavec)).*(wf1^(1-alphavec));
wfreal = wf1./pricef;
vshare0 = (alphavec.*(y0 + deficitt) - deficitm)./y0;
vshare1 = (alphavec.*(y1 + deftc) - defmc)./y1;
rvshare = vshare1./vshare0;
" ";
" TABLE 4 ";
"country, chng mfg wage, chng mfg price, change agg. price ";
call printfmt((cnty~wf1~pf0~pricef),(0~1~1~1));
" ";
" ";
" TABLE 5 ";
"country, chng real mfg wage, change in mfg share ";
call printfmt((cnty~wfreal~rvshare),(0~1~1));
" ";
@ take into account loss of deficit @
welf1 = wfreal.*((1+deftc./y1)./(1+deficitt./y0));
" ";
" TABLE 6 ";
" num, country, change in welfare ";
call printfmt((cntynum~cnty~welf1),(1~0~1));
" ";
xnimat1 = pimat1.*((alphavec./wcoeff).*(y1 + deftc) - pcoeff.*defmc./wcoeff);