
load euro_rates.dat ;
data = euro_rates ;
clear euro_rates ;
onem = data(:,4)/100 ;

n=length(onem) ;

diff = onem(2:n) - onem(1:n-1) ;
rate = onem(1:n-1) ;


newdata = sortrows([diff rate],2) ;
diff = newdata(:,1) ;
rate = newdata(:,2) ;



fit = PsplineDR05(rate,diff,struct('nknots',15,'degree',3) ) ;
fsize=16 ;
figure(1)
subplot(2,1,1) ;
p = plot(rate,fit.yhat, ...
	rate,fit.ulimit,'--', ...
	rate,fit.llimit,'--', ...
	[0 .25], [0 0]) ;
set(p(1),'linewidth',4) ;
set(p(2:3),'linewidth',2.5) ;
set(p(1),'color','red') ;
set(p(2:3),'color','blue') ;
set(p(4),'color','black') ;
set(p(4),'linewidth',2) ;
set(gca,'fontsize',fsize) ;
legend('Est','95% CI',0) ;
ylabel('drift') ;
xlabel('rate') ;

subplot(2,1,2) ;
p=plot(rate,fit.yhatder, ...
	rate,fit.ulimitder,'--', ...
	rate,fit.llimitder,'--', ...
	[0 .25],[0 0] ) ;
set(p(1),'linewidth',4) ;
set(p(2:3),'linewidth',2.5) ;
set(p(1),'color','red') ;
set(p(2:3),'color','blue') ;
set(p(4),'color','black') ;
set(p(4),'linewidth',2) ;
set(gca,'fontsize',fsize) ;
legend('Est','95% CI',0) ;
ylabel('derivative of drift') ;
xlabel('rate') ;

orient portrait ;
print Euros_drift.ps -deps ;


fit_vol = PsplineDR03(rate,(diff-fit.yhat).^2, ...
	struct('nknots',15,'degree',3) ) ;

figure(2)
subplot(2,1,1) ;
p = plot(rate,fit_vol.yhat, ...
	rate,fit_vol.ulimit,'--', ...
	rate,fit_vol.llimit,'--', ...
	[0 .25], [0 0]) ;
set(p(1),'linewidth',4) ;
set(p(2:3),'linewidth',2.5) ;
set(p(1),'color','red') ;
set(p(2:3),'color','blue') ;
set(p(4),'color','black') ;
set(p(4),'linewidth',2) ;
set(gca,'fontsize',fsize) ;
legend('Est','95% CI',0) ;
ylabel('volatility') ;
xlabel('rate') ;

subplot(2,1,2) ;
p=plot(rate,fit_vol.yhatder, ...
	rate,fit_vol.ulimitder,'--', ...
	rate,fit_vol.llimitder,'--', ...
	[0 .25],[0 0] ) ;
set(p(1),'linewidth',4) ;
set(p(2:3),'linewidth',2.5) ;
set(p(1),'color','red') ;
set(p(2:3),'color','blue') ;
set(p(4),'color','black') ;
set(p(4),'linewidth',2) ;
set(gca,'fontsize',fsize) ;
legend('Est','95% CI',0) ;
ylabel('derivative of volatility') ;
xlabel('rate') ;

orient portrait ;
print Euros_vol.ps -deps ;
