系数方向都调对了.
init values很重要(花较多时间)
%%%%%%%%%
load in_sample
X=in_sample/100;
n=length(X);
dt=1/260;
% option settings for optimization algorithm
opts=optimset( 'Display', 'notify', ...
'MaxIter', 1000, ...
'MaxFunEvals', 4000, ...
'LargeScale', 'off', ...
'HessUpdate', 'bfgs', ...
'TolX', 1e-8, ...
'TolFun', 1e-11 ...
);
ini_P=[0.3;-10;50;2];
%%%%%%%%%%%%CKLS
low_P=[0.3;-50;0.1;0.1];
up_P=[5;-0.3;400;4];
[P1,lnL1]=fmincon(@(P)CKLS_Calibration(P,X,dt),ini_P,[],[],[],[],low_P,up_P,[],opts)
%%%%%%%%%%%%Merton
low_P2=[0.3;0;0.1;0];
up_P2=[5;0;400;0];
[P2,lnL2]=fmincon(@(P)Merton_Calibration(P,X,dt),ini_P,[],[],[],[],low_P2,up_P2,[],opts)
%%%%%%%%%%%%VASICEK
low_P3=[0.3;-50;0.1;0];
up_P3=[5;-0.3;400;0];
[P3,lnL3]=fmincon(@(P)VASICEK_Calibration(P,X,dt),ini_P,[],[],[],[],low_P3,up_P3,[],opts)
%%%%%%%%%%%%CIR
low_P4=[0.3;-50;0.1;0.5];
up_P4=[5;-0.3;400;0.5];
[P4,lnL4]=fmincon(@(P)CIR_Calibration(P,X,dt),ini_P,[],[],[],[],low_P4,up_P4,[],opts)
%%%%%%%%%%%% Dothan
low_P5=[0;-50;0.1;1];
up_P5=[0;-0.3;400;1];
[P5,lnL5]=fmincon(@(P)Dothan_Calibration(P,X,dt),ini_P,[],[],[],[],low_P5,up_P5,[],opts)
%%%%%%%%%%%%Brennan_Schwartz
low_P6=[0.3;-100;0.1;1];
up_P6=[5;-0.3;400;1];
[P6,lnL6]=fmincon(@(P)Brennan_Schwartz_Calibration(P,X,dt),ini_P,[],[],[],[],low_P6,up_P6,[],opts)
%%%%%%%%%%%
%%result
P1 =
0.3000
-21.4332
110.1831
2.1431
lnL1 =
-1.0449e+004
%%
P2 =
0.3000
0
0.1000
0
lnL2 =
-5.0625
%%
P3 =
1.0333
-50.0000
0.1000
0
lnL3 =
-8.6186e+003
%%
P4 =
0.3000
-14.5800
0.2428
0.5000
lnL4 =
-9.7769e+003
%%
P5 =
0
-1.5481
0.1000
1.0000
lnL5 =
-9.1663
%%
P6 =
1.6587
-100.0000
0.1000
1.0000
lnL6 =
-9.3434