悬赏 10 个论坛币 未解决
程序如下:
function L = LikOneVasci(mu,psai,sig,lam, sige,y)
T=size(y,1);
m=7/365;
A(1)=0;
B(1)=1;
for n=2:3
B(n)=B(n-1)*psai;
A(n)=A(n-1)+B(n-1)*(mu*(1-psai)+sig*lam)-0.5*B(n-1)^2*sig^2;
end
for t=1:T
r(t)=[y(t,2)*2*m-A(2)]/B(2);
end
%pricing error of one-week rate
for t=1:T
yhat(t,1)=[A(1)+B(1)*r(t)]/(1*m);
e(t,1)=y(t,1)-yhat(t,1);
end
for t=1:T
yhat(t,3)=[A(3)+B(3)*r(t)]/(3*m);
e(t,3)=y(t,3)-yhat(t,3);
end
for t=2:T
er(t)=r(t)-(1-psai)*mu-psai*r(t-1);
end
for t=2:T
Lr(t)=log(sig)+0.5*er(t)^2/sig^2;
end
for t=1:T
Le1(t)=log(sige)+0.5*e(t,1)^2/sige^2;
end
for t=1:T
Le3(t)=log(sige)+0.5*e(t,3)^2/sige^2;
end
L=sum(Lr)+sum(Le1)+sum(Le3)
为什么run的结果错误,原因是: evalin('caller', [script ';']);