fmincon with constraints on eigenvalues

Hello everybody, I need to perform an optimization on matlab, I'm using fminsearch, but I realized that I need to put some constraints on a part of the parameter vector.
my parameter vector size is 20*1, I need the matrix :
K= Vec2mat(param(1:9),3) to have eigenvalues with positive real parts.
I wrote: [param, ML] = fmincon(@(param) Myfct(param,maturity,Data),param0,[],[],[],[],[],[],@Myconstr, options)
with the function Myconstr being:
function [c,ceq] = Myconstr(x) c = -real(eig(vec2mat(x(1:9),3)))'; ceq=[]; end
but it doesn't seem to work. Appreciate any help.
Thanks

5 commentaires

Shashank Prasanna
Shashank Prasanna le 3 Mar 2013
'but it doesn't seem to work' is not enough information. What is the error message? What is the expected output? What does Myfct look like?
Ben
Ben le 3 Mar 2013
Any thoughts ?
Matt J
Matt J le 3 Mar 2013
Modifié(e) : Matt J le 3 Mar 2013
My thought is that Shashank's questions above are worth answering.
Also, what is Vec2mat(a,b)? Is it the same as reshape(a,[],b) ?
Ben
Ben le 3 Mar 2013
Thanks Shashank for your reply, I didn't see your comment while posting my message. Here is my error msg:
??? Error using ==> eig Input to EIG must not contain NaN or Inf.
Error in ==> Myconstr at 3 c = -real(eig(vec2mat(x(1:9),3)))';
Error in ==> nlconst at 816 [nctmp,nceqtmp] = feval(confcn{3},x,varargin{:});
Error in ==> fmincon at 720 [X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
Error in ==> Main at 22 [param, ML] = fmincon(@(param) KalmanFilterCorr(param,maturity,Data),param0,[],[],[],[],[],[],@Myconstr, options)
I'm trying to implement a model (an affine 3-factors IR model, the 3 factors are level slope and curvature), I did KalmanFilter+MLE to estimate the model parameters (K: mean reversion matrix, sigma: volatility matrix, theta: mean vector and lambda: decay)
Model : dXt = K(theta-Xt)*dt + sigma*dWt
where: Xt=(Lt, St, Ct)
my parameter vector contains the elements of the matrix K (9 elements) and theta (3) and the volatility matrix (6, inf triangular)
Matt, Vec2mat is there to convert a vector into a matrix, same as reshape
Thanks for your help.
Matt J
Matt J le 3 Mar 2013
Modifié(e) : Matt J le 3 Mar 2013
What does (6, inf triangular) mean? Do you mean that it is lower triangular?

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 3 Mar 2013
Modifié(e) : Matt J le 3 Mar 2013

0 votes

As Shashank said, we need to see KalmanFilterCorr to know what's going on, but it looks like you have reached values for params(1:9) that are not finite and therefore EIG complains.
Using the DBSTOP command ("dbstop if naninf") will force MATLAB to pause execution at the point in the code where nan/inf values for params are generated. Then you can see what's going on.

Catégories

Tags

Question posée :

Ben
le 3 Mar 2013

Community Treasure Hunt

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

Start Hunting!

Translated by