%R&D     plot R&D estimates from the NSF.
%
%        Ellen McGrattan, 2-4-2012

load battelle.dat 
load NSFtab1cur.dat
load NSFtab1con.dat  
load NSFtab5cur.dat
load NSFtab5con.dat  
load NSFtab13.dat  

t       = [NSFtab13(:,1);battelle(:,1)];
gdp     = [NSFtab13(:,2);battelle(:,7)]*1000;
rgdp    = [NSFtab13(:,4);battelle(:,9)]*1000;
rdind   = [NSFtab5cur(:,12);battelle(:,5)];
rrdind  = [NSFtab5con(:,12);battelle(:,5)./battelle(:,8)];
rdnfed  = [NSFtab5cur(:,2)-NSFtab5cur(:,3);battelle(:,4)];
rrdnfed = [NSFtab5con(:,2)-NSFtab5con(:,3);battelle(:,4)./battelle(:,8)];
rdtind  = [NSFtab1cur(:,4);battelle(:,6)];
rrdtind = [NSFtab1con(:,4);battelle(:,6)./battelle(:,8)];

grate   = 1.029.^[t-2004];
grate2  = 1.054.^[t-2004];
figure(1),plot(t,rdind./gdp*100,'-bo', ...
               t,rdtind./gdp*100,'-k', ...
               t,rdnfed./gdp*100,'-r+');
title('R&D to GDP','Fontsize',16)
legend('Industry Source/Performer','Industry Performer','Nonfederal', ...
       'Location','Southeast')
i = find(t==2004);
figure(2),plot(t,rrdind./grate*grate(i)/rrdind(i)*100,'-bo', ...
               t,rrdtind./grate*grate(i)/rrdtind(i)*100,'-k', ...
               t,rrdnfed./grate*grate(i)/rrdnfed(i)*100,'-r+')
title('Real R&D Relative to a 2.9% Trend','Fontsize',16)
ylabel('Index, 2004=100')
legend('Industry Source/Performer','Industry Performer','Nonfederal', ...
       'Location','Southeast')
figure(3),plot(t,rrdind./grate*grate(i)/rrdind(i)*100,'-bo', ...
               t,rrdtind./grate*grate(i)/rrdtind(i)*100,'-k', ...
               t,rrdnfed./grate*grate(i)/rrdnfed(i)*100,'-r+')
title('Real R&D Relative to a 2.9% Trend','Fontsize',16)
ylabel('Index, 2004=100')
axis([2000,2012,90,120])
legend('Industry Source/Performer','Industry Performer','Nonfederal', ...
       'Location','Southeast')

figure(4),plot(t,rrdind./grate2*grate2(i)/rrdind(i)*100,'-k', ...
               t,rrdnfed./grate2*grate2(i)/rrdnfed(i)*100,'-r+')
title('Real R&D Relative to a 5% Trend','Fontsize',16)
ylabel('Index, 2004=100')
axis([1953,2012,75,140])
legend('Industry Source/Performer','Nonfederal', ...
       'Location','Southeast')
