Passing Covariance Matrix in Likelihood Maximization

4 次查看(过去 30 天)
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.

采纳的回答

Jeff Miller
Jeff Miller 2021-2-27
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
  1 个评论
Marco Lago
Marco Lago 2021-5-13
I was thinking about it again. One could pass the LogLik function a lower triangular matrix P and then build it in a covariance matrix such as Sigma = P*P'

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Least Squares 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by