Passing Covariance Matrix in Likelihood Maximization
2 views (last 30 days)
Show older comments
I've a question about code design for a numerical optimization of the likelihood function of the sort:
LL = LogLik(x,y,Param,L,Ps,P)
My objective function makes use of the multivariate normal probability density in the following fashion:
eta = mvnpdf(y,x*Phi,Sigma);
Where sigma is passed throug the parameter vector 'Param' (together with Phi). I then try to numerically optimize that through fmincon but then Sigma shoud be a positive-definite covariance matrix, condition that is not always defined and causes an error.
Results = fmincon(@(Param)LogLik(X,Y1,Param,L,Ps,P),x0,[],[],Aeq',beq,[],[],[],options)
I'm asking your help as I suspect this is not the right approach to solve the problem at hand.
0 Comments
Accepted Answer
Jeff Miller
on 27 Feb 2021
Sometimes this kind of problem can be solved by adding code within the LogLik function to make sure that a legal (i.e., positive definite) value of Sigma is computed from any possible combination of Param values. So, the Param values are not themselves elements of Sigma, but rather values that determine the elements of Sigma. As an example with Sigma determined by parameters 2-4:
function LL = LogLik(...
VarX = Param(2)^2; % Make sure positive
VarY = Param(3)^2; % Make sure positive
rhoXY = Param(4) / (abs(Param(4)+1)); % Make sure correlation between +/- 1
covarXY = rhoXY*sqrt(VarX)*sqrt(VarY);
Sigma = [VarX covarXY;
covarXY VarY]
eta = mvnpdf(y,x*Phi,Sigma);
...
Hope that helps
More Answers (0)
See Also
Categories
Find more on Get Started with Optimization Toolbox 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!