function [LL]=BondLL(theta);

global Y 
[EE,M,MH,N,NN,R,D1,D2,D3,P,F1]=termsolve(theta);

Z=Y;
if EE==0;
    LL=5e+030; % Asssign very low likelihood when no solution exists
else
DD1=D1(3:end,:);
DD2=D2(3:end,:);
DD3=[0,0;D3;];

n=length(DD1(:,1)); %dimension of observables;

R1=R(3:end,1:end);R1(4:5,:)=0;
Zadj=Z(:,3:end)-[F1(1,:);D3*F1;]*[Z(1,2:end-1);Z(1,1:end-2);];
try
    [LL]=KalmanLagLL(M,N,DD1,DD2,R1,Zadj);
    LL=-LL;
catch
       LL=8e+030;
end
  
end