Error: Failure in initial user-supplied objective function evaluation when using fminunc ?
6 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 15 Nov 2016
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 Comments
Walter Roberson
on 16 Nov 2016
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?
See Also
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!