Error: Failure in initial user-supplied objective function evaluation when using fminunc ?
11 次查看(过去 30 天)
显示 更早的评论
Hi, I plan to calculate a minimum distance estimator using fminunc function.
[b,fun,flag] = fminunc(@cov,b0);
However, during execution, Matlab send me an error message:
Error: Failure in initial user-supplied objective function evaluation
Following some suggestion from previous thread, I command
dbstop if caught error
And then run my code again. Matlab located the error at
Caught-error breakpoint was hit in optimget>optimgetfast at line 102. The error was:
Reference to non-existent field 'DiffMinChange'.
102 value = options.(name);
the cov function is defined as
%******************************
% Minimum Distance Procedure
%******************************
function f=cov(b):
fmm = fcn(b); %parameterized moment
peso= diag(diag(var));
f = (m-fmm)'*inv(peso)*(m-fmm); %m is vector of actual covariances - fmm is implied covariances
end
0 个评论
回答(1 个)
Walter Roberson
2016-11-15
It appears to me that your installation somehow combines multiple versions of the fmincon support routines, as if someone had copied some of them instead of doing a complete installation.
At the very least you should
rehash toolboxcache
and if the problem continues then you will need to check your MATLAB path and possibly reinstall the Optimization Toolbox
2 个评论
Walter Roberson
2016-11-16
I just noticed that you are using dbstop if caught error. The error you are detecting is not necessarily a problem, since it is caught and potentially dealt with smoothly. Sometimes Mathworks writes "try it and see" code instead of checking more directly for errors.
Where is your cov getting m from? Is your cov a nested function grabbing from a shared variable?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!