%PLOTS    plot final figures related to intangible investments on
%         R&D, advertising, and business market value.

%         Ellen McGrattan, 2-4-2012


t0  = 2004;
t1  = 2011;

randd,close all
i1  = find(t==t0);
i2  = find(t==t1);
rd  = rdind(i1:i2);
hgains,close all
i1  = find(t==t0);
i2  = find(t==t1);
mv  = mvbusa(i1:i2);
adexps,close all
i1  = find(tr==t0);
i2  = find(tr==t1);
ar  = r(i1:i2);
i1  = find(t==t0);
i2  = find(t==t1);
ae  = exps(i1:i2);

load ../CPS/avghrsa.dat
t   = avghrsa(:,1);
i1  = find(t==t0);
i2  = find(t==t1);
pop = avghrsa(i1:i2,4)/1000;

load ../BEA/NIPA/dgdp4711.dat
i   = find(dgdp4711(1,:)>=t0 & dgdp4711(1,:)<=t1);
def = dgdp4711(4,i)';
p   = zeros(4,length(def)/4);
p(:)= def;
p   = mean(p)'/100;

t   = [t0:t1]';
gr  = 1.019.^[t-2004];

drd = rd./(p.*pop.*gr);
dmv = mv./(p.*pop.*gr);
dar = ar./(p.*pop.*gr);
dae = ae./(p.*pop.*gr);

figure(1)
plot(t,drd/drd(1)*100,'-bo',t,dae/dae(1)*100,'-r+')
title('R&D and Advertising Expenditures Relative to Trend','Fontsize',16) 
figure(2)
plot(t,dmv/dmv(1)*100,'-r+')
title('Market Value of US Businesses Relative to Trend','Fontsize',16)

tab = [t,[drd/drd(1),dae/dae(1),dar/dar(1),dmv/dmv(1)]*100];
disp('===========================================================')
disp('                 Intangible Expenditures                   ')
disp('            --------------------------------               ')
disp('                           Advertising           Business  ')
disp('     Year      R&D   Expenditures  Revenues    Market Value')
disp('===========================================================')
disp(' ')
disp(sprintf('%9g%10.2f%11.2f%11.2f%15.2f\n',tab'))
disp('===========================================================')
