Passing Covariance Matrix in Likelihood Maximization

3 Ansichten (letzte 30 Tage)
Marco Lago
Marco Lago am 27 Feb. 2021
Kommentiert: Marco Lago am 13 Mai 2021
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.

Akzeptierte Antwort

Jeff Miller
Jeff Miller am 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
  1 Kommentar
Marco Lago
Marco Lago am 13 Mai 2021
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'

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by