% Comapre model prediction with Duffee (2008) results

clear all;
clc;
format short;
%--------------------------------------------------------------------------
% load eveything we need etc
%--------------------------------------------------------------------------
global Y 
load('THETAMCMC');
yc=[3,12,24,36,48,60;]; 
ndraws=1000;

% restart stuff
% XOPT=[];
load('XOPT');


%Get ndraws from MCMC

ra = max(size(THETAMCMC));
f = ceil(ra.*rand(ndraws,1));


for j=1:ndraws
    
    THETA=THETAMCMC(:,f(j,1));
    Y=BondSim(THETA);
    Y=Y(2:end,2:end);

LB=[-1*ones(1,5),-10*ones(1,10),0,-1e2*ones(1,30);]';
UB=[0.99999*ones(1,5),10*ones(1,10),1,1e2*ones(1,30);]';

load('xoptSIM');
x=xoptSIM;

sa_t= 5;
sa_rt=.2;
sa_nt=5;
sa_ns=5;
warning off all;
try
[xoptDUFF]=simannb('DuffeeFacLL', x, LB, UB, sa_t, sa_rt, sa_nt, sa_ns, 1);
XOPT=[XOPT xoptDUFF];

save('XOPT','XOPT');  
catch
ModelAndDuffee    
end
length(XOPT)


    
end

