Borrar filtros
Borrar filtros

Getting different values for an optimisation problem fmincon

2 visualizaciones (últimos 30 días)
ABDULAZIZ ALTUN
ABDULAZIZ ALTUN el 24 de Mzo. de 2020
I have the following function that I want to minimize
%% Liklihood: function description
function [outputs] = Liklihood_TCL(mu, sigma_epsilon,x_lf,c,N,C, S_inter)
Omega=(mu.^abs(repmat((1:c),c,1)'-repmat((1:c),c,1)))*(sigma_epsilon^2)/(1-mu^2);
% Compute the TCL
phi=C'*inv(C*Omega*C');
delta=inv(S_inter'*phi*C*S_inter)*S_inter'*phi;
Log_likelihood = (-N/2)*log(2*pi) - (1/2)*log(det(Omega)) - (1/2)*x_lf'*inv(C*Omega*C')*(eye(N)-C*S_inter*delta)*x_lf;
outputs=-Log_likelihood;
end
I wrote the following code assuming that x_lf, c, N, C, S_inter are given
loglik_TCL= @(a)Liklihood_TCL(a(1), a(2), x_lf*1000,c,N,C, S_inter);
% Generate many potential input variables that may insure that the log-likelihood is finite and not complex
% Furthermore, that also ensures that the model is stationary
v_x_lf=5;
fd=[];
fd1=[];
while length(fd)<10
% if we assume mu to be a number between -1 and 1 such that is is N(0,2)
mu_init=2*trandn(0,1/2);
sigma_epsilon_init=v_x_lf*trandn(0,1);
b=[mu_init, sigma_epsilon_init];
k=loglik_TCL(b);
while isinf(k)||~isreal(k)||mu_init<0
mu_init=2*trandn(-1/2,1/2);
sigma_epsilon_init=v_x_lf*trandn(0,1);
b=[mu_init, sigma_epsilon_init];
k=loglik_TCL(b);
end
fd1=[fd1; k];
fd=[fd; b];
end
% Set Initial values to the likelihood function
[M,I] = min(fd1);
input_1=fd(I,:);
% Linear Constraint
A = zeros(2,2);
A(1,1)=1;
A(2,1)=-1;
b = [1,-0.8];
% Constraint Optimization
[b_min_TCL,fval,exitflag,output] = fmincon(loglik_TCL,input_1,A,b);
% loglik_TCL(b_min_TCL)
% Variables that need estimation using likelihood functions
mu=b_min_TCL(1); %Error autoregressive parameter
sigma_epsilon=b_min_TCL(2); %Error of the AR(1) error model
The outcome are mu and sigma_epsilon. I assumed for the same datasets and initial constants I should get the values that always minimize the function. However, this is not ture. As can be seen in the attached files.
In particular it is giving me a different maximume variable everytime I run it. for example once it gives me [0.8008 0.5442] as the optimal point however changing it gives me a lower likelihood function.
Results:
>> loglik_TCL= @(a)Liklihood_TCL(a(1), a(2), x_lf,c,N,C, S_inter);
>> loglik_TCL([0.9 0.5])
ans =
-Inf
>> loglik_TCL([0.8008 0.5442])
ans =
-340.6327

Respuestas (0)

Categorías

Más información sobre Nonlinear Optimization en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by