2013-09-25 37 views
1

CIR MODEL初期參數

% Optimization using fminsearch 
if ~isfield(Model, 'MatlabDisp'), Model.MatlabDisp = 'off'; end; 

options = optimset('LargeScale', 'off', 'MaxIter', 300, 'MaxFunEvals',300,'Display',Model.MatlabDisp, 'TolFun', 1e-4, 'TolX', 1e-4, 'TolCon', 1e-4); 
if ~isfield(Model, 'Method'), Model.Method = 'besseli'; end; 
if strcmp(Model.Method, 'ncx2pdf') 
    [Params, Fval, Exitflag] = fminsearch(@(Params) CIRobjective2(Params, Model), InitialParams, options); 
else 
    [Params, Fval, Exitflag] = fminsearch(@(Params) CIRobjective1(Params, Model), InitialParams, options); 
end 
%tol = 1e-6; 
%lb = [ tol, tol, tol]; 
%ub = [ inf, inf, inf];  
%[Params, Fval, Exitflag] = fmincon(@(Params) CIRobjective1(Params, Model),                 
InitialParams, [], [], [], [], lb, ub, [], options); 

Results.Params = Params; 
Results.Fval = -Fval/Nobs; 
Results.Exitflag = Exitflag; 

if strcmp(Model.Disp, 'y') 
    fprintf('\n alpha = %+3.6f\n mu = %+3.6f\n sigma = %+3.6f\n', Params(1), Params(2), Params(3)); 
    fprintf(' log-likelihood = %+3.6f\n', -Fval/Nobs); 
end 

我有用於類型「結構」的輸入參數

未定義的函數或方法「mtimes」的對數似然估計。

Error in ==> CIRobjective2 at 26 
u = c*exp(-alpha*TimeStep)*DataL; 

Error in ==> @(Params)CIRobjective2(Params,Model) 


Error in ==> fminsearch at 205 
fv(:,1) = funfcn(x,varargin{:}); 

這是實際的源文件

http://www.mathworks.com/matlabcentral/fileexchange/37297-maximum-likelihood-estimation-of-the-cox-ingersoll-ross-process-the-matlab-implementation/content/CIRestimation.m

能否請你幫我,爲什麼我得到這些錯誤?

問候, 馬蘇德

回答

0

你確定你把所有的功能權限,並定義它呢? 它可能是你的功能不正確的路徑。

嘗試首先執行初始參數,定義InitialParams,使其出現在您的變量中。然後做CIRObjective1然後2然後你可以使用fminsearch進行優化。希望有所幫助。我是matlab的新用戶,但是已經將它用於我的論文。

問候,麗塔。