@ DEFIMOB16.PRG @
@ @
@ 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\defimob16.out RESET; @
OUTPUT FILE = c:\Programs_DEK_IMF\Gauss_Program\defimob16.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 = 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;
exprt = sumc(xbilat);
@ data from the UN (national accounts and UNIDO) @
load undata[43,3] = c:\Programs_DEK_IMF\Gauss_Program\undata.raw;
betavec = undata[.,1];
betavec = 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 @
casurp = catb[.,1];
tsurp = catb[.,2];
@ implied manufacturing production @
ym = vm./betavec;
xnn = ym - exprt;
xnimat = diagrv(xbilat,xnn);
@ 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*xnimat*aggmat';
gdp = aggmat*gdp;
vm = aggmat*vm;
casurp = aggmat*casurp;
tsurp = aggmat*tsurp;
betavec = aggmat*betavec;
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));
" ";
@ income term for counterfactual @
y0 = vm;
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;
bigcoeff = (1-alphavec)./alphavec + mygamma*(1-betavec)./(alphavec.*betavec);
@ calculate the change in the non-manufacturing wage, based on the manufacturing wage @
proc nonmanu(wf);
local temp,wfn;
temp = bigcoeff.*vm.*wf + defmc./alphavec - deftc;
wfn = temp./vn;
retp(wfn);
endp;
@ mapping from one log price change vector to another given wf0 @
proc lpmap(lpf);
local lpf0,lpf1,lwf0,lwfpf0,elwfpf0,wnf0,lwnf0;
lpf0 = lpf;
wnf0 = nonmanu(wf0);
lwnf0 = ln(wnf0);
lwf0 = ln(wf0);
lwfpf0 = betavec.*lwf0 + mygamma*(1-betavec).*lwnf0 + 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,wnf,wnftb;
wftb = wf^(-mytheta*betavec);
wnf = nonmanu(wf);
wnftb = wnf^(-mytheta*mygamma*(1-betavec));
pftb = pf^(-mytheta*pcoeff);
wfpftb = wftb.*wnftb.*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;
zw = (pimat1'*(y1./betavec + defmc) - y1./betavec)./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;
@ calculate non-manufacturing wage @
wnf1 = nonmanu(wf1);
@ correct for numeraire @
gdpnew = wf1.*vm + wnf1.*vn;
fgdpw =sumc(gdpnew)/sumc(gdp);
" fgdpw ";
fgdpw;
wnf1 = wnf1/fgdpw;
wf1 = wf1/fgdpw;
pf0 = pf0/fgdpw;
@ calculate new mfg GDP @
vmnew = wf1.*vm;
@calculate new nonmftr GDP @
vnnew = wnf1.*vn;
" sumc(vm) ";
sumc(vm);
" sumc(vmnew) ";
sumc(vmnew);
" sumc(vn) ";
sumc(vn);
" sumc(vnnew) ";
sumc(vnnew);
gdpnew = vmnew + vnnew;
" sumc(gdpnew) ";
sumc(gdpnew);
" sumc(gdp) ";
sumc(gdp);
@ calculate change in GDP @
gdp1 = (vmnew + vnnew)./gdp;
" ";
" TABLE 4 ";
"country, chng mfg wage, chng nmfg wage, chng gdp, chng mfg price ";
call printfmt((cnty~wf1~wnf1~gdp1~pf0),(0~1~1~1~1));
" ";
@ overall increase in prices @
pricef = (pf0^alphavec).*(wnf1^(1-alphavec));
@ Calculate new real wages @
wfreal = wf1./pricef;
wnfreal = wnf1./pricef;
@ factor increase in real GDP @
gdpreal = gdp1./pricef;
" ";
" TABLE 5 (continued below) ";
"country, chng real mfg wage, chng real nmfg wage, chng real gdp, chng agg. price ";
call printfmt((cnty~wfreal~wnfreal~gdpreal~pricef),(0~1~1~1~1));
" ";
@ Calculate welfare change @
welf1 = ((vmnew + vnnew + deftc)./pricef)./xgdp;
" ";
" TABLE 5 (continued) ";
" num, country, change in welfare ";
call printfmt((cntynum~cnty~welf1),(1~0~1));
" ";
cadshr = deficitc./gdp;
relwage = wf1./wnf1;
" ";
" NSF TABLE ";
"country, cadefshare, chng gdp, chng rel wage mfg, chng real gdp ";
call printfmt((cnty~cadshr~gdp1~relwage~gdpreal),(0~1~1~1~1));
" ";