how to use fminunc to get Hessian matrix
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I tried to use "fminunc" to get Hessian matrix, but received error information such as - ____________________________________________________________________________
Error using Agarch. Too many output arguments ... Error in rho1_H01_noplots (line 139) [theta,fval,exitflag,output,grad,hessian] = fminunc(@(theta)Agarch(theta,z,zx),theta0,opts);
Caused by: Failure in initial user-supplied objective function evaluation. FMINUNC cannot continue. ____________________________________________________________________________
And I defined "opts" as - ____________________________________________________________________________
opts = optimset('GradObj','on','Hessian','on','Algorithm','sqp','Display', 'off'); ____________________________________________________________________________
I have been reading the online documents relevant to "fminunc" and "hessian" and adjusted my code correspondingly, but still can't make it work. So I am wondering if anyone could help me fix this issue.
Thanks very much!
Xiao
0 Kommentare
Antworten (1)
Alan Weiss
am 2 Sep. 2014
Your options don't make sense, and may indicate a deeper problem. As explained in the options section of the fminunc documentation, the sqp algorithm does not take an input Hessian; the only algorithm that accepts an input Hessian is the trust-region algorithm. So it is possible that your objective function is trying to return the objective, gradient, and Hessian, but fminunc does not use the Hessian. So if you did not conditionalize your code to only give the number of outputs requested, then you can get this error.
That said, all algorithms can produce an output Hessian estimate.
There might be something else going on. Without more details, I don't know.
Alan Weiss
MATLAB mathematical toolbox documentation
12 Kommentare
Yulong Deng
am 28 Okt. 2014
I have the same question with you about the same error, while I tried to divide the function by some integers which can let the result show, but I also don't know how to let the original function run without any problem.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!