Passing Covariance Matrix in Likelihood Maximization

조회 수: 1 (최근 30일)
Marco Lago
Marco Lago 2021년 2월 27일
댓글: Marco Lago 2021년 5월 13일
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