%DIPOSMV    prediction of the direct investment positions using market values.
%           Run this code after running main.m.

%           Ellen McGrattan, 3-11-09


usawgtdom = Nu.*kTdun./(Nu.*kTdun+Nr.*kTdrn);
rowwgtdom = Nr.*kTfrn./(Nr.*kTfrn+Nu.*kTfun);
usawgtfor = 1-usawgtdom;
rowwgtfor = 1-rowwgtdom;
vddom     = (1-taud).*(Nu.*(kTdun+(1-taupu).*kIdun)+(1-taupu).*usawgtdom.*Mdn);
vdfor     = (1-taud).*(Nr.*(kTdrn+(1-taupr).*kIdrn)+(1-taupu).*usawgtfor.*Mdn);
vfdom     = (1-taud).*(Nr.*(kTfrn+(1-taupr).*kIfrn)+(1-taupr).*rowwgtdom.*Mfn);
vffor     = (1-taud).*(Nu.*(kTfun+(1-taupu).*kIfun)+(1-taupr).*rowwgtfor.*Mfn);

DIPOS0    = [vdfor./GNPu,vffor./GNPu,(vdfor-vffor)./GNPu]*nyr*100;
[n,m]     = size(DIPOS0);
for i=1:m;
  DIPOS1(:,i) = interp(DIPOS0(:,i),nyr);
end;
t1        = t(1):t(1)-1+nyr*T;
plot(t1,DIPOS1)
title('Model Predictions of DI Market Values and Net Position')
legend('Market value of USDIA/US GNP', ...
       'Market value of FDIUS/US GNP', ...
       'DI net position at market value','Location','Northwest')
axis([1982,2006,0,40])
