How to resolve the fminunc problem

2 views (last 30 days)
Houda
Houda on 5 Jul 2017
Commented: Houda on 6 Jul 2017
Hey everybody, I am runing the post maximization of a financial friction model but each time I run it I have the following errors:
Error in ==> post_minus at 3
x = trans2(xtrans);
??? Error using ==> feval
Output argument "min_post" (and maybe others) not assigned during call to "F:\new
folders\67bis\Restricted Models (Table 3)\Fin Frictions Mod\Post
Maximization\post_minus.m>post_minus".
Error in ==> lineSearch>bracketingPhase at 103
f_alpha =
feval(funfcn{3},reshape(xInitial(:)+alpha*dir(:),sizes.xRows,sizes.xCols),varargin{:});
Error in ==> lineSearch at 48
[a,b,f_a,fPrime_a,f_b,fPrime_b,alpha,f_alpha,grad,exitflagBrckt,funcCountBrckt] = ...
Error in ==> fminusub at 208
[alpha,f,grad,exitflagLnSrch,funcCountLnSrch] = ...
Error in ==> fminunc at 367
[x,FVAL,GRAD,HESSIAN,EXITFLAG,OUTPUT] = fminusub(funfcn,x, ...
Error in ==> max_run_loop at 72
[xtrans,fval,exitflag,output,grad,hessian]...
When I run this code with the original data of the author it works and even with another set of variable, but using this data I didn't succeed to obtain the posterior mode and the inverse of the Hessian matrix to finish the estimation procedure (the original code can be found in the homepage of Andrés Fernandez).
Please hepl me
Thanks in advance
Houda
  3 Comments
Houda
Houda on 5 Jul 2017
Edited: Walter Roberson on 5 Jul 2017
Dear Walter, yes right the website is"https://sites.google.com/site/andresfernandezmartin8/research" then you search for the title of his publication "On the Sources of Aggregate Fluctuations in Emerging Economies", the author mention the link of the code "Link to codes and data" click on https://sites.google.com/site/andresfernandezmartin8/Codes%20without%20MCMC.zip?attredirects=0 to download the code "codewithoutMCMC" then you move to restrected models=>financial friction model.
Walter Roberson
Walter Roberson on 5 Jul 2017
Could you clarify which routine you are calling, and with what parameters?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 5 Jul 2017
The code in post_minus includes the line
if logprior(1) == NaN
It is not possible to use "==" to compare to NaN . NaN == NaN is false. NaN has the strange property of being the only value for which x ~= x . The test should be
if isnan(logprior(1))
and likewise further down for elseif logdata(1) == NaN
Further down the code has
if ind == 1 % ind. is a flag signaling the inexistence of solution
return;
end
It does this without having assigned a value to min_post. It should probably be
if ind == 1 % ind. is a flag signaling the inexistence of solution
min_post = 0;
return;
end
This is probably what you are encountering, that it is detecting that there is no feasible solution.
  1 Comment
Houda
Houda on 6 Jul 2017
Dear Walter, it works you saved me, many thannnnnnnnnnnnnnnnks

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!